Exemple #1
0
        private void EditorForm_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyData)
            {
            case Keys.Delete:
                Command newCommand = removeCommand.Clone();
                if (newCommand.Execute(this))
                {
                    history.Push(newCommand);
                    Subscribe();
                }
                break;

            case Keys.Oemplus:
                Command newIncrCommand = increaseCommand.Clone();
                if (newIncrCommand.Execute(this))
                {
                    history.Push(newIncrCommand);
                    Subscribe();
                }
                break;

            case Keys.OemMinus:
                Command newDecrCommand = decreaseCommand.Clone();
                if (newDecrCommand.Execute(this))
                {
                    history.Push(newDecrCommand);
                    Subscribe();
                }
                break;

            case Keys.Left:
                Command newLeftCommand = leftCommand.Clone();
                if (newLeftCommand.Execute(this))
                {
                    history.Push(newLeftCommand);
                    Subscribe();
                }
                break;

            case Keys.Right:
                Command newRightCommand = rightCommand.Clone();
                if (newRightCommand.Execute(this))
                {
                    history.Push(newRightCommand);
                    Subscribe();
                }
                break;

            case Keys.Up:
                Command newUpCommand = upCommand.Clone();
                if (newUpCommand.Execute(this))
                {
                    history.Push(newUpCommand);
                    Subscribe();
                }
                break;

            case Keys.Down:
                Command newDownCommand = downCommand.Clone();
                if (newDownCommand.Execute(this))
                {
                    history.Push(newDownCommand);
                    Subscribe();
                }
                break;

            case Keys.Z:
                if (history.Count == 0)
                {
                    break;
                }
                if (history.Peek() is SubscribeCommand)
                {
                    history.Pop().Unexecute();
                }
                history.Pop().Unexecute();
                break;
            }
            vector.UpdatePath();
            panel1.Refresh();
        }