private void RefreshCommands() { AddDeviceCommand.RaiseCanExecuteChanged(); MoveUpCommand.RaiseCanExecuteChanged(); MoveDownCommand.RaiseCanExecuteChanged(); DeleteDeviceCommand.RaiseCanExecuteChanged(); }
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(); }
/// <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 MoveUpCommandAndUndo_When_NewDesk_Then_NoMoving() { var desk = _helper.GenerateDesk(4); var moveCommand = new MoveUpCommand(desk); bool res = moveCommand.Execute(); Assert.False(res); }
public void Rebind() { OnPropertyChanged(() => MoveDownAvailable); OnPropertyChanged(() => MoveUpAvailable); Component.Rebind(); MoveDownCommand.Rebind(); MoveUpCommand.Rebind(); RemoveCommand.Rebind(); }
internal void MenuMoveUpClicked(object sender, EventArgs e) { if (scenarioTreeView.SelectedNode != null) { ICommand command = new MoveUpCommand((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 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(); }
public void HoverCommand_ShouldExecuteClientMoveUp() { // arrange moveUpCommand = new MoveUpCommand(DroneClientMock.Object); // act moveUpCommand.Execute(); // assert DroneClientMock.Verify(x => x.MoveUp(), Times.Once); }
void OnMoveDown() { var clause = SelectedClause; if (clause == null) { return; } clause.Container.MoveDown(clause); MoveUpCommand.RaiseCanExecuteChanged(); MoveDownCommand.RaiseCanExecuteChanged(); }
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(); }
/// <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"); }
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(); }
private void RaiseRefreshView(bool refreshCollectionView) { DeleteJobCommand.RaiseCanExecuteChanged(); MergeJobsCommand.RaiseCanExecuteChanged(); MergeAllJobsCommand.RaiseCanExecuteChanged(); MoveUpCommand.RaiseCanExecuteChanged(); MoveDownCommand.RaiseCanExecuteChanged(); if (refreshCollectionView) { JobInfos.Refresh(); } }
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(); }
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); }
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 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); }
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(); }
public void CLear() { robot = null; cmd = null; }
private void MoveDown() { SelectedTile.Row++; MoveDownCommand.OnCanExecuteChanged(); MoveUpCommand.OnCanExecuteChanged(); }
public void RefreshPosition() { MoveUpCommand.RaiseCanExecuteChanged(); MoveDownCommand.RaiseCanExecuteChanged(); }
public void Init() { robot = new WorkerMoq(); cmd = new MoveUpCommand(robot); }