コード例 #1
0
        private void descriptionTextBox_TextChanged(object sender, EventArgs e)
        {
            if (currentlySelectedNode != null)
            {
                int id = 0;

                //
                // Update the actual node
                //
                if (currentlySelectedNode.Tag is ActionWindow)
                {
                    ActionWindow window = currentlySelectedNode.Tag as ActionWindow;
                    window.Description = descriptionTextBox.Text;
                    id = window.Id;
                }
                else if (currentlySelectedNode.Tag is KeyAction)
                {
                    KeyAction action = currentlySelectedNode.Tag as KeyAction;
                    action.Description = descriptionTextBox.Text;
                    id = action.Id;
                }

                //
                // Update visible stuff
                //
                currentlySelectedNode.Text = String.Format("{0} ({1})", descriptionTextBox.Text, id);
            }
        }
コード例 #2
0
        private void idComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (currentlySelectedNode != null)
            {
                //
                // Update the actual node
                //
                if (currentlySelectedNode.Tag is ActionWindow)
                {
                    ActionWindow window = currentlySelectedNode.Tag as ActionWindow;
                    //          window.Id = Convert.ToInt32(idTextBox.Text);
                    //
                    //          currentlySelectedNode.Text = window.Description + " (" + window.Id + ")";
                }
                else if (currentlySelectedNode.Tag is KeyAction)
                {
                    if (idComboBox.Text != null)
                    {
                        KeyAction action = currentlySelectedNode.Tag as KeyAction;

                        try
                        {
                            Action.ActionType actionType = (Action.ActionType)Enum.Parse(typeof(Action.ActionType), idComboBox.Text);

                            action.Id = (int)actionType;

                            currentlySelectedNode.Text          = action.Description + " (" + action.Id + ")";
                            currentlySelectedNode.Nodes[0].Text = String.Format("Action = " + GetActionName(action.Id));
                        }
                        catch { }
                    }
                }
            }
        }
コード例 #3
0
        private void soundTextBox_TextChanged(object sender, EventArgs e)
        {
            if (currentlySelectedNode != null)
            {
                if (currentlySelectedNode.Tag is KeyAction)
                {
                    KeyAction action = currentlySelectedNode.Tag as KeyAction;

                    action.Sound = soundTextBox.Text;

                    currentlySelectedNode.Nodes[2].Text = String.Format("Sound = " + action.Sound);
                }
            }
        }
コード例 #4
0
        private void keyTextBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            keyTextBox.Text = e.KeyChar.ToString().ToUpper(CultureInfo.CurrentCulture); // keyMappings.GetName(e.KeyValue);

            if (currentlySelectedNode != null)
            {
                if (currentlySelectedNode.Tag is KeyAction)
                {
                    KeyAction action = currentlySelectedNode.Tag as KeyAction;

                    action.Key = keyTextBox.Text;

                    currentlySelectedNode.Nodes[1].Text = String.Format("Key = " + keyTextBox.Text);
                }
            }
        }
コード例 #5
0
        private void keyTextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (keyMappings.IsValid(e.KeyValue))
            {
                keyTextBox.Text = keyMappings.GetName(e.KeyValue);

                if (currentlySelectedNode != null)
                {
                    if (currentlySelectedNode.Tag is KeyAction)
                    {
                        KeyAction action = currentlySelectedNode.Tag as KeyAction;

                        action.Key = keyTextBox.Text;

                        currentlySelectedNode.Nodes[1].Text = String.Format("Key = " + keyTextBox.Text);
                    }
                }
            }
            else
            {
                e.SuppressKeyPress = true;
            }
        }
コード例 #6
0
    private void addButton_Click(object sender, EventArgs e)
    {
      if (currentlySelectedNode != null)
      {
        if (currentlySelectedNode == globalNode)
        {
          //
          // Add an action to the global node
          //
          KeyAction action = new KeyAction(0, "", "<New Action>", "");
          globalActions.Add(action);

          TreeNode actionNode = new TreeNode(action.Description + " (" + action.Id + ")");

          actionNode.Nodes.Add("Action = " + GetActionName(action.Id));
          actionNode.Nodes.Add("Key = " + action.Key);
          actionNode.Nodes.Add("Sound = " + action.Sound);

          actionNode.Tag = action;

          globalNode.Nodes.Add(actionNode);

          //
          // Make node visible and select it
          //
          actionNode.EnsureVisible();
          keyTreeView.SelectedNode = actionNode;
        }
        else if (currentlySelectedNode == windowsNode)
        {
          //
          // Add window
          //
          ActionWindow window = new ActionWindow();
          windowActions.Add(window);

          window.Id = 0;
          window.Description = "<New Window>";

          TreeNode windowNode = new TreeNode(window.Description + " (" + window.Id + ")");

          windowNode.Tag = window;

          windowsNode.Nodes.Add(windowNode);

          //
          // Make node visible and select it
          //
          windowNode.EnsureVisible();
          keyTreeView.SelectedNode = windowNode;
        }
        else if (currentlySelectedNode.Tag is ActionWindow)
        {
          ActionWindow window = currentlySelectedNode.Tag as ActionWindow;

          //
          // Add an action to the selected window
          //
          KeyAction action = new KeyAction(0, "", "<New Action>", "");
          window.Actions.Add(action);

          TreeNode actionNode = new TreeNode(action.Description + " (" + action.Id + ")");

          actionNode.Nodes.Add("Action = " + GetActionName(action.Id));
          actionNode.Nodes.Add("Key = " + action.Key);
          actionNode.Nodes.Add("Sound = " + action.Sound);

          actionNode.Tag = action;

          currentlySelectedNode.Nodes.Add(actionNode);

          //
          // Make node visible and select it
          //
          actionNode.EnsureVisible();
          keyTreeView.SelectedNode = actionNode;
        }
      }
    }
コード例 #7
0
        private void addButton_Click(object sender, EventArgs e)
        {
            if (currentlySelectedNode != null)
            {
                if (currentlySelectedNode == globalNode)
                {
                    //
                    // Add an action to the global node
                    //
                    KeyAction action = new KeyAction(0, "", "<New Action>", "");
                    globalActions.Add(action);

                    TreeNode actionNode = new TreeNode(action.Description + " (" + action.Id + ")");

                    actionNode.Nodes.Add("Action = " + GetActionName(action.Id));
                    actionNode.Nodes.Add("Key = " + action.Key);
                    actionNode.Nodes.Add("Sound = " + action.Sound);

                    actionNode.Tag = action;

                    globalNode.Nodes.Add(actionNode);

                    //
                    // Make node visible and select it
                    //
                    actionNode.EnsureVisible();
                    keyTreeView.SelectedNode = actionNode;
                }
                else if (currentlySelectedNode == windowsNode)
                {
                    //
                    // Add window
                    //
                    ActionWindow window = new ActionWindow();
                    windowActions.Add(window);

                    window.Id          = 0;
                    window.Description = "<New Window>";

                    TreeNode windowNode = new TreeNode(window.Description + " (" + window.Id + ")");

                    windowNode.Tag = window;

                    windowsNode.Nodes.Add(windowNode);

                    //
                    // Make node visible and select it
                    //
                    windowNode.EnsureVisible();
                    keyTreeView.SelectedNode = windowNode;
                }
                else if (currentlySelectedNode.Tag is ActionWindow)
                {
                    ActionWindow window = currentlySelectedNode.Tag as ActionWindow;

                    //
                    // Add an action to the selected window
                    //
                    KeyAction action = new KeyAction(0, "", "<New Action>", "");
                    window.Actions.Add(action);

                    TreeNode actionNode = new TreeNode(action.Description + " (" + action.Id + ")");

                    actionNode.Nodes.Add("Action = " + GetActionName(action.Id));
                    actionNode.Nodes.Add("Key = " + action.Key);
                    actionNode.Nodes.Add("Sound = " + action.Sound);

                    actionNode.Tag = action;

                    currentlySelectedNode.Nodes.Add(actionNode);

                    //
                    // Make node visible and select it
                    //
                    actionNode.EnsureVisible();
                    keyTreeView.SelectedNode = actionNode;
                }
            }
        }
コード例 #8
0
        private void keyTreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            currentlySelectedNode = e.Node;

            addButton.Enabled = currentlySelectedNode != null &&
                                (!(currentlySelectedNode.Tag is KeyAction) && currentlySelectedNode.Tag != null);

            if (addButton.Enabled == false)
            {
                addButton.Enabled = currentlySelectedNode == globalNode || currentlySelectedNode == windowsNode;
            }

            //
            // Enable/Disable controls
            //
            deleteButton.Enabled              =
                keyTextBox.Enabled            =
                    fileNameButton.Enabled    =
                        idComboBox.Enabled    =
                            idTextBox.Enabled = soundTextBox.Enabled = descriptionTextBox.Enabled = e.Node.Tag is KeyAction;

            if (deleteButton.Enabled == false)
            {
                deleteButton.Enabled = currentlySelectedNode.Tag is ActionWindow;
            }

            if (e.Node.Tag is ActionWindow)
            {
                //
                // Enable correct controls
                //
                idTextBox.Visible  = true;
                idComboBox.Visible = false;

                idTextBox.Enabled = true;

                ActionWindow window = e.Node.Tag as ActionWindow;

                descriptionTextBox.Text = window.Description;
                idTextBox.Text          = window.Id.ToString();

                keyTextBox.Text   = string.Empty;
                soundTextBox.Text = string.Empty;

                descriptionTextBox.Enabled = idComboBox.Enabled = true;
            }
            else if (e.Node.Tag is KeyAction)
            {
                //
                // Enable correct controls
                //
                idTextBox.Visible  = false;
                idComboBox.Visible = true;

                KeyAction action = e.Node.Tag as KeyAction;

                descriptionTextBox.Text = action.Description;
                idComboBox.Text         = GetActionName(action.Id);
                keyTextBox.Text         = action.Key;
                soundTextBox.Text       = action.Sound;
            }
            else
            {
                //
                // None of the above
                //
            }
        }