private void RefreshCommands() { AddDeviceCommand.RaiseCanExecuteChanged(); MoveUpCommand.RaiseCanExecuteChanged(); MoveDownCommand.RaiseCanExecuteChanged(); DeleteDeviceCommand.RaiseCanExecuteChanged(); }
void RefreshCommands() { //CloneViewCommand.RaiseCanExecuteChanged(); DeleteCommand.RaiseCanExecuteChanged(); MoveDownCommand.RaiseCanExecuteChanged(); MoveUpCommand.RaiseCanExecuteChanged(); }
// Update is called once per frame void Update() { if (Input.GetKey(KeyCode.Z)) { // Move up command moveUp = new MoveUpCommand(this.transform, this._speed); moveUp.Execute(); MoveCommandManager.Instance.AddCommand(moveUp); } else if (Input.GetKey(KeyCode.S)) { // Move down command moveDown = new MoveDownCommand(this.transform, this._speed); moveDown.Execute(); MoveCommandManager.Instance.AddCommand(moveDown); } else if (Input.GetKey(KeyCode.Q)) { // Move left command moveLeft = new MoveLeftCommand(this.transform, this._speed); moveLeft.Execute(); MoveCommandManager.Instance.AddCommand(moveLeft); } else if (Input.GetKey(KeyCode.D)) { // Move right command moveRight = new MoveRightCommand(this.transform, this._speed); moveRight.Execute(); MoveCommandManager.Instance.AddCommand(moveRight); } }
void Update() { if (Input.GetKey(KeyCode.W)) { moveUp = new MoveUpCommand(this.transform, _speed); moveUp.Execute(); CommandManger_2.Instance.AddCommand(moveUp); } else if (Input.GetKey(KeyCode.S)) { moveDown = new MoveDownCommand(this.transform, _speed); moveDown.Execute(); CommandManger_2.Instance.AddCommand(moveDown); } else if (Input.GetKey(KeyCode.A)) { moveLeft = new MoveLeftCommand(this.transform, _speed); moveLeft.Execute(); CommandManger_2.Instance.AddCommand(moveLeft); } else if (Input.GetKey(KeyCode.D)) { moveRight = new MoveRightCommand(this.transform, _speed); moveRight.Execute(); CommandManger_2.Instance.AddCommand(moveRight); } }
/// <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()); }
void Update() { if (Input.GetKey(upKey)) { moveUp = new MoveUpCommand(this.transform, _speed); moveUp.Execute(); CommandManager.Instance.AddBuffer(moveUp); } else if (Input.GetKey(downKey)) { moveDown = new MoveDownCommand(this.transform, _speed); moveDown.Execute(); CommandManager.Instance.AddBuffer(moveDown); } else if (Input.GetKey(rightKey)) { moveRight = new MoveRightCommand(this.transform, _speed); moveRight.Execute(); CommandManager.Instance.AddBuffer(moveRight); } if (Input.GetKey(leftKey)) { moveLeft = new MoveLeftCommand(this.transform, _speed); moveLeft.Execute(); CommandManager.Instance.AddBuffer(moveLeft); } }
private void Start() { _moveUp = new MoveUpCommand(this.transform, speed); _moveDown = new MoveDownCommand(this.transform, speed); _moveLeft = new MoveLeftCommand(this.transform, speed); _moveRight = new MoveRightCommand(this.transform, speed); }
/// <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(); }
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(); } }
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; } }
public void MoveCommRight_When_NewDesk_Then_RightMoving() { var desk = _helper.GenerateDesk(4); var moveCommand = new MoveDownCommand(desk); bool res = moveCommand.Execute(); Assert.True(res); }
public void Rebind() { OnPropertyChanged(() => MoveDownAvailable); OnPropertyChanged(() => MoveUpAvailable); Component.Rebind(); MoveDownCommand.Rebind(); MoveUpCommand.Rebind(); RemoveCommand.Rebind(); }
internal void MenuMoveDownClicked(object sender, EventArgs e) { if (scenarioTreeView.SelectedNode != null) { ICommand command = new MoveDownCommand((QAliberTreeNode)scenarioTreeView.SelectedNode); commandsHistory.Do(command); OnScenarioChanged(); } }
protected override void OnSelectedIndexChanged(int oldValue, int newValue) { base.OnSelectedIndexChanged(oldValue, newValue); RemoveCommand.InvalidateCanExecute(); CloneCommand.InvalidateCanExecute(); MoveUpCommand.InvalidateCanExecute(); MoveDownCommand.InvalidateCanExecute(); }
public void MoveCommRight_When_NewDesk_Then_DeskChanged() { var newDesk = _helper.GenerateDesk(4); var desk = _helper.GenerateDesk(4); var moveCommand = new MoveDownCommand(desk); moveCommand.Execute(); Assert.NotEqual(newDesk.GetDesk(), desk.GetDesk()); }
public void LoadMenuCommand() { ICommand moveUpCommand = new MoveUpCommand(this); ICommand moveDownCommand = new MoveDownCommand(this); ICommand selectCommand = new SelectCommand(this); keyboardController.BindKey(Keys.Up, moveUpCommand); keyboardController.BindKey(Keys.Down, moveDownCommand); keyboardController.BindKey(Keys.Enter, selectCommand); }
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(); }
public void SimpleWinChecker_When_UncorrectDesk_Then_FalseResult() { var desk = _helper.GenerateDesk(4); var moveCommand = new MoveDownCommand(desk); moveCommand.Execute(); desk.SetWinner(new SimpleWinChecker()); bool res = desk.IsInWinPosition(); Assert.False(res); }
public void HoverCommand_ShouldExecuteClientMoveDown() { // arrange moveDownCommand = new MoveDownCommand(DroneClientMock.Object); // act moveDownCommand.Execute(); // assert DroneClientMock.Verify(x => x.MoveDown(), Times.Once); }
public void MoveCommRightandAndUndo_When_NewDesk_Then_CorrectUndo() { var newDesk = _helper.GenerateDesk(4); var desk = _helper.GenerateDesk(4); var moveCommand = new MoveDownCommand(desk); moveCommand.Execute(); moveCommand.Undo(); Assert.Equal(newDesk.GetDesk(), desk.GetDesk()); }
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(); }
public void Should_MoveDown_And_Save() { var settingsStore = Substitute.For <ISettingsStore>(); var item = Substitute.For <Item>(); var command = new MoveDownCommand(item); var handler = new MoveDownCommandHandler(settingsStore); handler.Handle(command); item.Received().MoveDown(); settingsStore.Received().TrySave(); }
public InputManager() { moveUp = new MoveUpCommand(); moveDown = new MoveDownCommand(); moveRight = new MoveRightCommand(); moveLeft = new MoveLeftCommand(); stopMoveUp = new StopMoveUpCommand(); stopMoveLeft = new StopMoveLeftCommand(); stopMoveRight = new StopMoveRightCommand(); stopMoveDown = new StopMoveDownCommand(); attack = new AttackCommand(); rangedAttack = new RangedAttackCommand(); }
public void ShouldInvokeMoveDownAndSetStateToHandled() { var slnControl = new Mock <ISolutionExplorerControl>(); slnControl.Setup(x => x.MoveDown()); var command = new MoveDownCommand(slnControl.Object); var context = new Context(); var result = command.Execute(context, Keys.J); Assert.Equal(CommandState.Handled, result.State); slnControl.VerifyAll(); }
private void RaiseRefreshView(bool refreshCollectionView) { DeleteJobCommand.RaiseCanExecuteChanged(); MergeJobsCommand.RaiseCanExecuteChanged(); MergeAllJobsCommand.RaiseCanExecuteChanged(); MoveUpCommand.RaiseCanExecuteChanged(); MoveDownCommand.RaiseCanExecuteChanged(); if (refreshCollectionView) { JobInfos.Refresh(); } }
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); }
public InputManager(GameObject player) { this.player = player; moveUp = new MoveUpCommand(); moveDown = new MoveDownCommand(); moveRight = new MoveRightCommand(); moveLeft = new MoveLeftCommand(); stopMoveUp = new StopMoveUpCommand(); stopMoveLeft = new StopMoveLeftCommand(); stopMoveRight = new StopMoveRightCommand(); stopMoveDown = new StopMoveDownCommand(); attack = new AttackCommand(); rangedAttack = new RangedAttackCommand(); }
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); }
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 TestCommandMoveDown() { // Arrange int originalLocationY = fakeGameComponent.Y; Command moveDown = new MoveDownCommand(); int finalLocationY; // The amount the game object should move in one command int expectedMoveAmount = 1; // Act moveDown.Execute(fakeGameComponent); finalLocationY = fakeGameComponent.Y; // Assert Assert.AreEqual(finalLocationY, originalLocationY - expectedMoveAmount); }