Esempio n. 1
0
        private void _list_KeyDown(Object sender, KeyEventArgs e)
        {
            if (UseControlShortcuts && e.KeyCode == Keys.F2 && !e.Control && !e.Alt && !e.Shift)
            {
                if (_list.SelectedItems.Count > 0)
                    _list.SelectedItems[0].BeginEdit();
            }

            if (UseControlShortcuts && e.KeyCode == Keys.Delete && !e.Control && !e.Alt && !e.Shift)
            {
                var delete = new ValueDeleteCommand(Ctx);
                if (delete.CanDoImpl()) Ctx.Execute(delete);
            }

            if (UseControlShortcuts && e.KeyCode == Keys.Apps && !e.Control && !e.Alt && !e.Shift)
            {
                if (_list.SelectedItems.Count > 0)
                {
                    var vpos = _list.SelectedItems[0].Bounds.Location;
                    _list_MouseUp(this, new MouseEventArgs(MouseButtons.Right, 1, vpos.X, vpos.Y, 0));
                }
                else
                {
                    _list_MouseUp(this, new MouseEventArgs(MouseButtons.Right, 1, -1, -1, 0));
                }
            }

            if (UseControlShortcuts && e.KeyData == Keys.Enter && !e.Control && !e.Alt && !e.Shift)
            {
                if (_list.SelectedItems.Count > 0)
                {
                    var vpos = _list.SelectedItems[0].Bounds.Location;
                    _list_MouseDoubleClick(this, new MouseEventArgs(MouseButtons.Left, 2, vpos.X, vpos.Y, 0));
                }
            }

            if (UseControlShortcuts && !UseMenuShortcuts)
            {
                ICommand cmd = null;

                if (e.KeyCode == Keys.C && e.Control && !e.Alt && !e.Shift) cmd = new ValueCopyCommand(Ctx);
                if (e.KeyCode == Keys.X && e.Control && !e.Alt && !e.Shift) cmd = new ValueCutCommand(Ctx);
                if (e.KeyCode == Keys.V && e.Control && !e.Alt && !e.Shift) cmd = new ValuePasteCommand(Ctx);
                if (e.KeyCode == Keys.Y && e.Control && !e.Alt && !e.Shift) cmd = new RedoCommand(Ctx);
                if (e.KeyCode == Keys.Z && e.Control && !e.Alt && !e.Shift) cmd = new UndoCommand(Ctx);

                if (e.KeyCode == Keys.N && e.Control && !e.Alt && !e.Shift) cmd = new VaultNewCommand(Ctx);
                if (e.KeyCode == Keys.O && e.Control && !e.Alt && !e.Shift) cmd = new VaultOpenCommand(Ctx);
                if (e.KeyCode == Keys.S && e.Control && !e.Alt && !e.Shift) cmd = new VaultSaveCommand(Ctx);
                if (e.KeyCode == Keys.I && e.Control && !e.Alt && !e.Shift) cmd = new VaultImportCommand(Ctx);
                if (e.KeyCode == Keys.E && e.Control && !e.Alt && !e.Shift) cmd = new VaultExportCommand(Ctx);

                if (cmd != null)
                {
                    if (cmd.CanDo()) Ctx.Execute(cmd);
                }
            }
        }
Esempio n. 2
0
        private void _tree_KeyDown(Object sender, KeyEventArgs e)
        {
            if (UseControlShortcuts && e.KeyCode == Keys.F2 && !e.Control && !e.Alt && !e.Shift)
            {
                if (_tree.SelectedNode != null)
                    _tree.SelectedNode.BeginEdit();
            }

            if (UseControlShortcuts && e.KeyCode == Keys.Delete && !e.Control && !e.Alt && !e.Shift)
            {
                var delete = new BranchDeleteCommand(Ctx);
                if (delete.CanDoImpl()) Ctx.Execute(delete);
            }

            if (UseControlShortcuts && e.KeyCode == Keys.Apps && !e.Control && !e.Alt && !e.Shift)
            {
                if (_tree.SelectedNode != null)
                {
                    var vpos = _tree.SelectedNode.Bounds.Location;
                    _tree_MouseClick(this, new MouseEventArgs(MouseButtons.Right, 1, vpos.X, vpos.Y, 0));
                }
            }

            if (UseControlShortcuts && !UseMenuShortcuts)
            {
                ICommand cmd = null;

                if (e.KeyCode == Keys.C && e.Control && !e.Alt && !e.Shift) cmd = new BranchCopyCommand(Ctx);
                if (e.KeyCode == Keys.X && e.Control && !e.Alt && !e.Shift) cmd = new BranchCutCommand(Ctx);
                if (e.KeyCode == Keys.V && e.Control && !e.Alt && !e.Shift) cmd = new BranchPasteCommand(Ctx);
                if (e.KeyCode == Keys.Up && e.Control && !e.Alt && !e.Shift) cmd = new BranchMoveUpCommand(Ctx);
                if (e.KeyCode == Keys.Down && e.Control && !e.Alt && !e.Shift) cmd = new BranchMoveDownCommand(Ctx);
                if (e.KeyCode == Keys.Y && e.Control && !e.Alt && !e.Shift) cmd = new RedoCommand(Ctx);
                if (e.KeyCode == Keys.Z && e.Control && !e.Alt && !e.Shift) cmd = new UndoCommand(Ctx);

                if (e.KeyCode == Keys.N && e.Control && !e.Alt && !e.Shift) cmd = new VaultNewCommand(Ctx);
                if (e.KeyCode == Keys.O && e.Control && !e.Alt && !e.Shift) cmd = new VaultOpenCommand(Ctx);
                if (e.KeyCode == Keys.S && e.Control && !e.Alt && !e.Shift) cmd = new VaultSaveCommand(Ctx);
                if (e.KeyCode == Keys.I && e.Control && !e.Alt && !e.Shift) cmd = new VaultImportCommand(Ctx);
                if (e.KeyCode == Keys.E && e.Control && !e.Alt && !e.Shift) cmd = new VaultExportCommand(Ctx);

                if (cmd != null)
                {
                    if (cmd.CanDo()) Ctx.Execute(cmd);
                }
            }
        }