Exemplo n.º 1
0
 private void RefreshCommands()
 {
     AddDeviceCommand.RaiseCanExecuteChanged();
     MoveUpCommand.RaiseCanExecuteChanged();
     MoveDownCommand.RaiseCanExecuteChanged();
     DeleteDeviceCommand.RaiseCanExecuteChanged();
 }
Exemplo n.º 2
0
 void RefreshCommands()
 {
     //CloneViewCommand.RaiseCanExecuteChanged();
     DeleteCommand.RaiseCanExecuteChanged();
     MoveDownCommand.RaiseCanExecuteChanged();
     MoveUpCommand.RaiseCanExecuteChanged();
 }
        /// <summary>
        /// Add a input file.
        /// </summary>
        /// <param name="file">The path of the file</param>
        public async Task AddInputFile(string file)
        {
            switch (OutOfProcessHelper.TestSourceFile(file))
            {
            //File is corrupt pdf.
            case OutOfProcessHelper.SourceTestResult.Unreadable:
                //Tell the user the pdf is corrupt.
                Application.Current.Dispatcher.BeginInvoke(new Action(() => ((MetroWindow)Application.Current.MainWindow).ShowMessageAsync("The file " + Path.GetFileName(file) + " could not be opened as a PDF or image", "Some thing went wrong when opening " + Path.GetFileName(file))));
                break;

            //File is a valid pdf.
            case OutOfProcessHelper.SourceTestResult.Ok:
                //Add the pdf to the ListBox.
                Application.Current.Dispatcher.Invoke(new Action(() => Files.Add(new PDFItem(file, null))));
                break;

            //File is a image (maybe not valid!).
            case OutOfProcessHelper.SourceTestResult.Image:
                break;
            }
            //Update Commands
            Application.Current.Dispatcher.Invoke(() => MergeCommand.RaiseCanExecuteChanged());
            MoveUpCommand.RaiseCanExecuteChanged();
            MoveDownCommand.RaiseCanExecuteChanged();
            Application.Current.Dispatcher.Invoke(() => RemoveCommand.RaiseCanExecuteChanged());
        }
 private void MoveDown(ColumnViewModel item)
 {
     var index = Columns.IndexOf(item);
     Columns.Move(index, index + 1);
     MoveUpCommand.RaiseCanExecuteChanged();
     MoveDownCommand.RaiseCanExecuteChanged();
 }
Exemplo n.º 5
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            player = new PlayerContext(Content, new Vector2(0, 0));

            // Initialize commands
            ICommand quitCommand      = new QuitCommand(this);
            ICommand moveLeftCommand  = new MoveLeftCommand(player);
            ICommand moveRightCommand = new MoveRightCommand(player);
            ICommand moveUpCommand    = new MoveUpCommand(player);
            ICommand moveDownCommand  = new MoveDownCommand(player);

            // Link keys to commands
            Dictionary <Keys, ICommand> keysMap = new Dictionary <Keys, ICommand>();

            keysMap.Add(Keys.Q, quitCommand);
            keysMap.Add(Keys.Left, moveLeftCommand);
            keysMap.Add(Keys.Right, moveRightCommand);
            keysMap.Add(Keys.Up, moveUpCommand);
            keysMap.Add(Keys.Down, moveDownCommand);
            //secondary commands for WASD
            keysMap.Add(Keys.W, moveUpCommand);
            keysMap.Add(Keys.A, moveLeftCommand);
            keysMap.Add(Keys.S, moveDownCommand);
            keysMap.Add(Keys.D, moveRightCommand);

            // Add controls to controller
            keyboardController = new KeyboardController(keysMap);

            base.Initialize();
        }
Exemplo n.º 6
0
        private void SelectTile(TileViewModel tile)
        {
            if (tile == SelectedTile)
            {
                tile = null;
            }

            SelectedTile?.Deselect();
            SelectedTile = tile;
            SelectedTile?.Select();
            MoveDownCommand.OnCanExecuteChanged();
            MoveLeftCommand.OnCanExecuteChanged();
            MoveUpCommand.OnCanExecuteChanged();
            MoveRightCommand.OnCanExecuteChanged();
            DeleteTileCommand.OnCanExecuteChanged();
            OnPropertyChanged("HintVisibility");
            if (SelectedTile != null)
            {
                ShowEditInfo();
            }
            else
            {
                HideEditInfo();
            }
        }
Exemplo n.º 7
0
        protected override void OnPreviewKeyDown(KeyEventArgs e)
        {
            base.OnPreviewKeyDown(e);

            DataGridCell senderCell = e.OriginalSource as DataGridCell;
            bool         ctrlDown   = Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl);

            if (e.Key == Key.Return)
            {
                if (senderCell != null && !senderCell.IsEditing)
                {
                    // Enter edit mode if current cell is not in edit mode
                    senderCell.Focus();
                    this.BeginEdit();
                    e.Handled = true;
                }
            }
            else if (e.Key == Key.Space)
            {
                if (senderCell != null && !senderCell.IsEditing)
                {
                    object item = senderCell.DataContext;

                    // In some cases senderCell is not selected. This can happen after multi selection over all items.
                    if (!senderCell.IsSelected)
                    {
                        item = SelectedItem; // simply use first selected item
                    }

                    ToggleEnabledForItem(item);
                    e.Handled = true;
                }
            }
            else if (ctrlDown && e.Key == Key.Up)
            {
                if (MoveUpCommand != null && MoveUpCommand.CanExecute(null))
                {
                    var focusedCellItem = (Keyboard.FocusedElement as DataGridCell)?.DataContext;

                    MoveUpCommand.Execute(null);

                    // DataGrid loses keyboard focus after moving items
                    FocusCellAfterDelay(focusedCellItem);
                }
                e.Handled = true;
            }
            else if (ctrlDown && e.Key == Key.Down)
            {
                if (MoveDownCommand != null && MoveDownCommand.CanExecute(null))
                {
                    var focusedCellItem = (Keyboard.FocusedElement as DataGridCell)?.DataContext;

                    MoveDownCommand.Execute(null);

                    // DataGrid loses keyboard focus after moving items
                    FocusCellAfterDelay(focusedCellItem);
                }
                e.Handled = true;
            }
        }
Exemplo n.º 8
0
        public void MoveUpCommandAndUndo_When_NewDesk_Then_NoMoving()
        {
            var  desk        = _helper.GenerateDesk(4);
            var  moveCommand = new MoveUpCommand(desk);
            bool res         = moveCommand.Execute();

            Assert.False(res);
        }
Exemplo n.º 9
0
 public void Rebind()
 {
     OnPropertyChanged(() => MoveDownAvailable);
     OnPropertyChanged(() => MoveUpAvailable);
     Component.Rebind();
     MoveDownCommand.Rebind();
     MoveUpCommand.Rebind();
     RemoveCommand.Rebind();
 }
Exemplo n.º 10
0
 internal void MenuMoveUpClicked(object sender, EventArgs e)
 {
     if (scenarioTreeView.SelectedNode != null)
     {
         ICommand command = new MoveUpCommand((QAliberTreeNode)scenarioTreeView.SelectedNode);
         commandsHistory.Do(command);
         OnScenarioChanged();
     }
 }
Exemplo n.º 11
0
        protected override void OnSelectedIndexChanged(int oldValue, int newValue)
        {
            base.OnSelectedIndexChanged(oldValue, newValue);

            RemoveCommand.InvalidateCanExecute();
            CloneCommand.InvalidateCanExecute();
            MoveUpCommand.InvalidateCanExecute();
            MoveDownCommand.InvalidateCanExecute();
        }
Exemplo n.º 12
0
        public void MoveUpCommandAndUndo_When_NewDesk_Then_DeskDoesntChange()
        {
            var newDesk     = _helper.GenerateDesk(4);
            var desk        = _helper.GenerateDesk(4);
            var moveCommand = new MoveUpCommand(desk);

            moveCommand.Execute();

            Assert.Equal(newDesk.GetDesk(), desk.GetDesk());
        }
    void Start()
    {
        List <ActorController> actors = GameObject.FindObjectsOfType <ActorController>().ToList();

        leftPlayerActor  = actors.Single(x => x.name == "PlayerPaddle");
        rightPlayerActor = actors.Single(x => x.name == "AI_Paddle");

        moveUpCommand = new MoveUpCommand();
        moveDownCmd   = new MoveDownCommand();
    }
Exemplo n.º 14
0
        public void HoverCommand_ShouldExecuteClientMoveUp()
        {
            // arrange
            moveUpCommand = new MoveUpCommand(DroneClientMock.Object);

            // act
            moveUpCommand.Execute();

            // assert
            DroneClientMock.Verify(x => x.MoveUp(), Times.Once);
        }
Exemplo n.º 15
0
        void OnMoveDown()
        {
            var clause = SelectedClause;

            if (clause == null)
            {
                return;
            }
            clause.Container.MoveDown(clause);
            MoveUpCommand.RaiseCanExecuteChanged();
            MoveDownCommand.RaiseCanExecuteChanged();
        }
Exemplo n.º 16
0
        protected override void OnItemsChanged(IList <T> oldValue, IList <T> newValue)
        {
            base.OnItemsChanged(oldValue, newValue);

            AddCommand.InvalidateCanExecute();
            RemoveCommand.InvalidateCanExecute();
            CloneCommand.InvalidateCanExecute();
            MoveUpCommand.InvalidateCanExecute();
            MoveDownCommand.InvalidateCanExecute();
            ClearCommand.InvalidateCanExecute();
            ExportCommand.InvalidateCanExecute();
        }
Exemplo n.º 17
0
        /// <summary>
        /// Updates operation collection.
        /// </summary>
        private void UpdateOperations()
        {
            this.contextMenuOperations = new Collection <MenuItemViewModel>();

            if (this.SelectedItems.Count == 1)
            {
                SerializedDomainClassViewModel classViewModel = this.SelectedItems[0] as SerializedDomainClassViewModel;
                if (classViewModel != null)
                {
                    if (classViewModel.Parent != null)
                    {
                        MenuItemViewModel mv = new MenuItemViewModel(this.ViewModelStore, "Select Relationship");
                        mv.Command = SelectRelationshipCommand;
                        this.contextMenuOperations.Add(mv);
                    }
                }

                SerializedReferenceRelationshipViewModel refRelViewModel = this.SelectedItems[0] as SerializedReferenceRelationshipViewModel;
                if (refRelViewModel != null)
                {
                    if (!refRelViewModel.IsInFullSerialization)
                    {
                        MenuItemViewModel mv = new MenuItemViewModel(this.ViewModelStore, "Select Relationship");
                        mv.Command = SelectRelationshipCommand;
                        this.contextMenuOperations.Add(mv);
                    }
                }
            }

            if (this.SelectedItems.Count > 0)
            {
                AddSeparator();

                MenuItemViewModel mvMoveUp = new MenuItemViewModel(this.ViewModelStore, "Move up", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Up-16.png");
                mvMoveUp.Command = MoveUpCommand;
                if (!MoveUpCommand.CanExecute())
                {
                    mvMoveUp.IsEnabled = false;
                }
                this.contextMenuOperations.Add(mvMoveUp);

                MenuItemViewModel mvMoveDown = new MenuItemViewModel(this.ViewModelStore, "Move down", "pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Down-16.png");
                mvMoveDown.Command = MoveDownCommand;
                if (!MoveDownCommand.CanExecute())
                {
                    mvMoveDown.IsEnabled = false;
                }
                this.contextMenuOperations.Add(mvMoveDown);
            }

            OnPropertyChanged("Operations");
        }
Exemplo n.º 18
0
        public void Should_MoveUp_And_Save()
        {
            var settingsStore = Substitute.For <ISettingsStore>();
            var item          = Substitute.For <Item>();
            var command       = new MoveUpCommand(item);
            var handler       = new MoveUpCommandHandler(settingsStore);

            handler.Handle(command);

            item.Received().MoveUp();

            settingsStore.Received().TrySave();
        }
Exemplo n.º 19
0
        private void RaiseRefreshView(bool refreshCollectionView)
        {
            DeleteJobCommand.RaiseCanExecuteChanged();
            MergeJobsCommand.RaiseCanExecuteChanged();
            MergeAllJobsCommand.RaiseCanExecuteChanged();
            MoveUpCommand.RaiseCanExecuteChanged();
            MoveDownCommand.RaiseCanExecuteChanged();

            if (refreshCollectionView)
            {
                JobInfos.Refresh();
            }
        }
Exemplo n.º 20
0
        public void ShouldInvokeMoveUpAndSetStateToHandled()
        {
            var slnControl = new Mock <ISolutionExplorerControl>();

            slnControl.Setup(x => x.MoveUp());

            var command = new MoveUpCommand(slnControl.Object);
            var context = new Context();
            var result  = command.Execute(context, Keys.K);

            Assert.Equal(CommandState.Handled, result.State);
            slnControl.VerifyAll();
        }
Exemplo n.º 21
0
        public Command CreateCommand(CommandType commandType)
        {
            Command command = null;

            switch (commandType)
            {
            case CommandType.Start:
                command = new StartCommand(drone);
                break;

            case CommandType.Stop:
                command = new StopCommand(drone);
                break;

            case CommandType.Configure:
                command = new ConfigureCommand(drone);
                break;

            case CommandType.MoveBackward:
                command = new MoveBackwardCommand(drone);
                break;

            case CommandType.MoveDown:
                command = new MoveDownCommand(drone);
                break;

            case CommandType.MoveForward:
                command = new MoveForwardCommand(drone);
                break;

            case CommandType.MoveLeft:
                command = new MoveLeftCommand(drone);
                break;

            case CommandType.MoveRight:
                command = new MoveRightCommand(drone);
                break;

            case CommandType.MoveUp:
                command = new MoveUpCommand(drone);
                break;

            case CommandType.Hover:
                command = new HoverCommand(drone);
                break;

            default:
                throw new ArgumentException("Invalid command type");
            }
            return(command);
        }
Exemplo n.º 22
0
 void InitInputManager()
 {
     ioMgr    = GetComponent <InputManager>();
     jump     = new JumpCommand(pc);
     stopJump = new StopJumpCommand(pc);
     dash     = new DashCommand(pc);
     left     = new MoveLeftCommand(pc);
     right    = new MoveRightCommand(pc);
     stopHor  = new StopMoveHorCommand(pc);
     up       = new MoveUpCommand(pc);
     down     = new MoveDownCommand(pc);
     stopVer  = new StopMoveVerCommand(pc);
     attack   = new AttackCommand(pc);
     interact = new InteractCommand(pc);
 }
Exemplo n.º 23
0
        public void TestCommandMoveUp()
        {
            //arrange
            int     originalYLocation = fakeGameComponent.Y;
            Command moveUp            = new MoveUpCommand();
            int     finalLocationY;
            int     expectedMoveAmount = 1;

            //act
            moveUp.Execute(fakeGameComponent);
            finalLocationY = fakeGameComponent.Y;

            //assert
            Assert.AreEqual(originalYLocation, finalLocationY + expectedMoveAmount);
        }
Exemplo n.º 24
0
 public void SetActivePlayer()
 {
     up                = new MoveUpCommand();
     left              = new MoveLeftCommand();
     down              = new MoveDownCommand();
     right             = new MoveRightCommand();
     escape            = new EscapeButtonCommand();
     actionButtonOne   = new ActionButtonOne();
     actionButtonTwo   = new ActionButtonTwo();
     actionButtonThree = new ActionButtonThree();
     actionButtonFour  = new ActionButtonFour();
     actionButtonFive  = new ActionButtonFive();
     openCloseBook     = new EButtonCommand();
     openCloseQuests   = new TabButtonCommand();
 }
        public void TestCommandMoveUp()
        {
            // Arrange
            int     originalLocationY = fakeGameComponent.Y;
            Command moveUp            = new MoveUpCommand();
            int     finalLocationY;
            // The amount the game object should move in one command
            int expectedMoveAmount = 1;

            // Act
            moveUp.Execute(fakeGameComponent);
            finalLocationY = fakeGameComponent.Y;

            // Assert
            Assert.AreEqual(finalLocationY, originalLocationY + expectedMoveAmount);
        }
        private void Move(bool up)
        {
            //The selected item
            PDFItem dataItem = Files[SelectedIndex];
            int     index    = SelectedIndex;

            if (!up)
            {
                index--;
            }
            if (up)
            {
                index++;
            }
            Files.Remove(dataItem);
            Files.Insert(index, dataItem);
            SelectedIndex = 0;
            SelectedIndex = index;
            MoveDownCommand.RaiseCanExecuteChanged();
            MoveUpCommand.RaiseCanExecuteChanged();
        }
Exemplo n.º 27
0
 public void CLear()
 {
     robot = null;
     cmd   = null;
 }
Exemplo n.º 28
0
 private void MoveDown()
 {
     SelectedTile.Row++;
     MoveDownCommand.OnCanExecuteChanged();
     MoveUpCommand.OnCanExecuteChanged();
 }
Exemplo n.º 29
0
 public void RefreshPosition()
 {
     MoveUpCommand.RaiseCanExecuteChanged();
     MoveDownCommand.RaiseCanExecuteChanged();
 }
Exemplo n.º 30
0
 public void Init()
 {
     robot = new WorkerMoq();
     cmd   = new MoveUpCommand(robot);
 }