/// <summary>
        /// Returns the command part from a node text
        /// i.e.  v_pitch - js1_x returns js1_x
        /// </summary>
        /// <param name="nodeText">The node text in 'action - command' notation</param>
        /// <returns>the command part or an empty string</returns>
        public new static String CommandFromNodeText(String nodeText)
        {
            String cmd;

            ActionTreeInputNode.DecompNodeText(nodeText, out cmd);
            return(cmd);
        }
 // ctor
 public ActionTreeInputNode( ActionTreeInputNode srcNode )
     : base(srcNode)
 {
     if ( srcNode == null ) return;
       /*
       this.Name = srcNode.Name;
       this.Text = srcNode.Text;
       this.BackColor = srcNode.BackColor;
       this.ForeColor = srcNode.ForeColor;
       this.NodeFont = srcNode.NodeFont;
       this.ImageKey = srcNode.ImageKey;
       this.Tag = srcNode.Tag;
       this.m_command = srcNode.m_command;
        */
 }
        // ctor
        public ActionTreeInputNode(ActionTreeInputNode srcNode)
            : base(srcNode)
        {
            if (srcNode == null)
            {
                return;
            }

            /*
             * this.Name = srcNode.Name;
             * this.Text = srcNode.Text;
             * this.BackColor = srcNode.BackColor;
             * this.ForeColor = srcNode.ForeColor;
             * this.NodeFont = srcNode.NodeFont;
             * this.ImageKey = srcNode.ImageKey;
             * this.Tag = srcNode.Tag;
             * this.m_command = srcNode.m_command;
             */
        }
Example #4
0
        /// <summary>
        /// Apply an update from the action to the treenode
        /// First apply to the GUI tree where the selection happend then copy it over to master tree
        /// </summary>
        /// <param name="input">The input command</param>
        /// <param name="node">The TreeNode to update</param>
        /// <param name="actionCmd">The actionCommand that carries the update</param>
        /// <param name="inKind">The input device</param>
        private void UpdateInputNodeFromAction( ActionTreeInputNode node, ActionCommandCls actionCmd, ActionCls.ActionDevice inKind )
        {
            log.Debug( "UpdateInputNodeFromAction - Entry" );
              if ( actionCmd == null ) return;
              if ( node.Level != 2 ) return; // applies only to ActionTreeInputNode

              // input is either "" or a valid mapping or a blended mapping
              if ( String.IsNullOrEmpty( actionCmd.input ) ) {
            // new unmapped
            node.Command = ""; node.BackColor = MyColors.UnassignedColor;
              }

              // blended mapped ones - can only get a Blend Background
              else if ( ( inKind == ActionCls.ActionDevice.AD_Joystick ) && ( actionCmd.input == JoystickCls.BlendedInput ) ) {
            node.Command = actionCmd.input; node.BackColor = MyColors.BlendedColor;
              }
              else if ( ( inKind == ActionCls.ActionDevice.AD_Gamepad ) && ( actionCmd.input == GamepadCls.BlendedInput ) ) {
            node.Command = actionCmd.input; node.BackColor = MyColors.BlendedColor;
              }
              else if ( actionCmd.input == DeviceCls.BlendedInput ) {
            // Manually Blended input
            node.Command = actionCmd.input; node.BackColor = MyColors.BlendedColor;
              }
              else {
            // mapped ( regular ones )
            node.Command = actionCmd.input;

            // background is along the input
            if ( inKind == ActionCls.ActionDevice.AD_Joystick ) {
              int jNum = JoystickCls.JSNum( actionCmd.input );
              node.BackColor = JoystickCls.JsNColor( jNum );
            }
            else if ( inKind == ActionCls.ActionDevice.AD_Gamepad ) {
              node.BackColor = GamepadCls.XiColor( );
            }
            else if ( inKind == ActionCls.ActionDevice.AD_Keyboard ) {
              node.BackColor = KeyboardCls.KbdColor( );
            }
            else {
              // ?? what else
              node.BackColor = MyColors.UnassignedColor;
            }
              }
              UpdateMasterNode( node );
        }
Example #5
0
        /// <summary>
        /// Apply the filter to the GUI TreeView
        /// </summary>
        private void ApplyFilter( )
        {
            log.Debug( "ApplyFilter - Entry" );

              ActionTreeNode topNode = null; // allow to backup the view - will carry the first node items

              Ctrl.BeginUpdate( );
              Ctrl.Nodes.Clear( ); // start over

              // traverse the master tree and build the GUI tree from it
              foreach ( ActionTreeNode tn in m_MasterTree.Nodes ) {
            ActionTreeNode tnMap = new ActionTreeNode( tn ); Ctrl.Nodes.Add( tnMap ); // copy level 0 nodes
            if ( topNode == null ) topNode = tnMap;

            // have to search nodes of nodes
            Boolean allHidden = true;
            foreach ( ActionTreeNode stn in tn.Nodes ) {
              if ( ( stn.Tag != null ) && ( ( Boolean )stn.Tag == true ) ) {
            ;  // don't create it i.e hide it - though you cannot hide TreeViewNodes at all...
              }
              else {
            ActionTreeNode tnAction = new ActionTreeNode( stn ); tnMap.Nodes.Add( tnAction ); // copy level 1 nodes
            foreach ( ActionTreeInputNode istn in stn.Nodes ) {
              ActionTreeInputNode tnActionInput = new ActionTreeInputNode( istn ); tnAction.Nodes.Add( tnActionInput ); // copy level 2 nodes
            }
            allHidden = false;
              }
            }
            // make it tidier..
            if ( allHidden ) tnMap.Collapse( );
            else tnMap.ExpandAll( );
              }
              if ( topNode != null ) Ctrl.TopNode = topNode; // set view to topnode

              Ctrl.EndUpdate( ); // enable GUI update
        }
Example #6
0
        /// <summary>
        /// Loads the mappings back into the treeview control
        /// Note: this takes a while as the list grows...
        /// </summary>
        public void ReloadTreeView( )
        {
            log.Debug( "ReloadTreeView - Entry" );

              foreach ( ActionMapCls acm in ActionMaps ) {
            if ( IgnoreMaps.Contains( "," + acm.name + "," ) ) break; // next
            try {
              ActionTreeNode mtn = ( ActionTreeNode )m_MasterTree.Nodes[acm.name]; // get the map node
              // find the item to reload into the treeview
              foreach ( ActionCls ac in acm ) {
            ActionTreeNode matn = ( ActionTreeNode )mtn.Nodes[ac.key];  // get the action node
            Boolean first=true;
            // refresh commands
            foreach ( ActionCommandCls acc in ac.inputList ) {
              try {
                UpdateActionCommandFromInput( acc.input, acc, ac.actionDevice ); // this may apply (un)Blending if needed
                // the first one goes into the node, further must be created if not existing
                if ( first ) {
                  UpdateNodeFromAction( matn, acc, ac.actionDevice );
                  matn.Nodes.Clear( ); // clear add childs - those don't persist from newly loaded actionmaps
                  first = false;
                }
                else {
                  // have to recreate the action child nodes
                  ActionTreeInputNode matin = new ActionTreeInputNode( "UNDEF" ); matin.ImageKey = "Add";
                  acc.nodeIndex = matin.Index; // assign visual reference
                  matn.Nodes.Add( matin ); // add to master tree
                  UpdateInputNodeFromAction( matin, acc, ac.actionDevice );
                }
              }
              catch {
                ; // key not found
              }
            }
              }
            }
            catch {
              ; // map key not found ??
            }
              }

              // finally apply the filter and make it visible
              FilterTree( );
        }
Example #7
0
        /// <summary>
        /// Add a new Action Child to the selected node to apply an addtional mapping
        /// </summary>
        public void AddBinding( )
        {
            if ( Ctrl.SelectedNode == null ) return;
              if ( Ctrl.SelectedNode.Level != 1 ) return; // can only add to level 1 nodes

              ActionTreeNode matn = FindMasterAction( (ActionTreeNode)Ctrl.SelectedNode );
              ActionCls ac = FindActionObject( matn.Parent.Name, matn.Name );   // the related action
              // make new items
              ActionTreeInputNode matin = new ActionTreeInputNode( "UNDEF" ); matin.ImageKey = "Add";
              matn.Nodes.Add( matin ); // add to master tree
              ActionCommandCls acc = ac.AddCommand( "", matin.Index );
              // show stuff
              FilterTree( );
              FindAndSelectCtrlByName( matn.Name );
              // jump to the latest
              if ( m_ctrl.SelectedNode.LastNode != null ) {
            m_ctrl.SelectedNode = m_ctrl.SelectedNode.LastNode;
              }
        }
Example #8
0
 private void UpdateMasterNode( ActionTreeInputNode node )
 {
     // copy to master node
       TreeNode[] masterNode = m_MasterTree.Nodes.Find( node.Name, true ); // find the same node in master
       if ( masterNode.Length == 0 ) throw new IndexOutOfRangeException( "ActionTree ERROR - cannot find synched node in master" ); // OUT OF SYNC
       // could return more than one if the action is the same in different actionmaps
       foreach ( ActionTreeInputNode mtn in masterNode ) {
     if ( mtn.Parent.Name == node.Parent.Name ) {
       mtn.Command = node.Command; mtn.BackColor = node.BackColor;
     }
       }
 }
 // ctor
 public ActionTreeInputNode( string text, ActionTreeInputNode[] children )
     : base(text, children)
 {
 }