Exemple #1
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);
            if (e.Handled)
            {
                return;
            }

            bool alt   = Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt);
            bool ctrl  = Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl);
            bool shift = Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift);

            // DO - UNDO
            CommandController controller = viewModel.Controller;

            if (!alt && ctrl && !shift && e.Key == Key.Z)
            {
                controller.UndoCommand();
            }
            if (!alt && ctrl && !shift && e.Key == Key.Y)
            {
                controller.ExecuteCommand();
            }

            lblUndoStack.Content = controller.UndoCount;
            lblRedoStack.Content = controller.RedoCount;

            //if (!alt && !ctrl && !shift)
            //{
            //    leftTree.SelectNextName(e.Key);
            //}

            return;
        }
Exemple #2
0
    public void CommandControllerUnknownCommand()
    {
        var cc      = new CommandController();
        var ccOuter = new CommandController(cc);

        Assert.Throws <CommandUnknownException> (() => {
            ccOuter.ExecuteCommand(new CommandData(_TestCommandName + "abc"));
        });
    }
Exemple #3
0
    public void CommandControllerFallback()
    {
        var cc = new CommandController();

        cc.RegisterCommand <TestCommand> ();

        var ccOuter = new CommandController(cc);

        Assert.Throws <TestException> (() => {
            ccOuter.ExecuteCommand(new CommandData(_TestCommandName));
        });
    }
Exemple #4
0
        internal void Initialize(MainWindow mainWindow)
        {
            this.model = new MainModel();

            InitializeMenus(mainWindow);
            InitializePanels(mainWindow);


            model.ModulesMgr.Initialize(this);

            CommandController controller = (CommandController)this.Controller;

            UndoCommand = new RelayCommand(par => controller.UndoCommand(), canEx => controller.UndoCount > 0);
            RedoCommand = new RelayCommand(par => controller.ExecuteCommand(), canEx => controller.RedoCount > 0);

            return;
        }