Пример #1
0
        private void AddMakeCommandToSelectedKey()
        {
            if (treeKeys.SelectedNode == null || treeKeys.SelectedNode.Level != 1)
            {
                EnableKeyButtons();
                return;
            }

            bool isPressed = treeKeys.SelectedNode.Text.Equals("Pressed");
            string keyName = treeKeys.SelectedNode.Parent.Name;
            Key currentKey = KeyManager.Keys.Single(k => k.Name.Equals(keyName));


            var configureKeyCode = new MakeCodeDialog();
            configureKeyCode.KeyStroke = new KeyStroke();

            configureKeyCode.ShowDialog(this);

            if (configureKeyCode.DialogResult == DialogResult.OK)
            {

                if (isPressed)
                {
                    currentKey.KeyDownStrokes.Add(configureKeyCode.KeyStroke.Clone());
                }
                else
                {
                    currentKey.KeyUpStrokes.Add(configureKeyCode.KeyStroke.Clone());
                }
                UpdateKeyNode(currentKey, currentKey.Name);
            }
        }
Пример #2
0
        private void ChangeSelectedMakeCommand()
        {
            if (treeKeys.SelectedNode == null || treeKeys.SelectedNode.Level != 2)
            {
                EnableKeyButtons();
                return;
            }

            int codeIndex = Convert.ToInt32(treeKeys.SelectedNode.Name.Substring(treeKeys.SelectedNode.Name.Length - 2, 2));
            bool isPressed = treeKeys.SelectedNode.Parent.Text.Equals("Pressed");
            string keyName = treeKeys.SelectedNode.Parent.Parent.Name;
            Key currentKey = KeyManager.Keys.Single(k => k.Name.Equals(keyName));

            KeyStroke ks;
            if (isPressed)
            {
                ks = currentKey.KeyDownStrokes[codeIndex];
            }
            else
            {
                ks = currentKey.KeyUpStrokes[codeIndex];
            }

            var configureKeyCode = new MakeCodeDialog();
            configureKeyCode.KeyStroke = ks;

            configureKeyCode.ShowDialog(this);

            if (configureKeyCode.DialogResult == DialogResult.OK)
            {
                treeKeys.SelectedNode.Text = configureKeyCode.KeyStroke.ToString();
            }
        }