public void UserInput(KeyboardInput keyboardInput) { bool updateRequired = true; for (;;) { if (_selection.SelectedPoints.Length == 0) { break; } if (DeletePoints(keyboardInput, _selection.SelectedPoints)) { break; } if (MovePoints(keyboardInput, _selection.SelectedPoints)) { break; } updateRequired = false; break; } _lastKeyboardInput = keyboardInput; // Update the GUI if needed. if (updateRequired) { Update(); } }
protected virtual bool MovePoints(KeyboardInput userInput, IPoint[] points) { CheckPoints(points); bool result = false; if (userInput.KeyState == KeyState.Down) { Vector3D moveDelta = new Vector3D(0, 0, 0); switch (userInput.Key) { case Key.Up: case Key.U: moveDelta = new Vector3D(0, 0, 1); break; case Key.Down: case Key.J: moveDelta = new Vector3D(0, 0, -1); break; } // Call the move method with a vector. if (moveDelta.LengthSquared > 0) { result = MovePoints(moveDelta, points); } } return(result); }
public APlotVM(IPlot plot) { _plot = plot; _lastKeyboardInput = new KeyboardInput(); _lastMouseInput = new MouseInput(); _selection = new SelectionManager(plot); _plotPoints = new PlotPoints(); Update(); Step = new Vector3D(0, 0, 1); }
protected virtual bool DeletePoints(KeyboardInput userInput, IPoint[] points) { CheckPoints(points); bool result = false; if (LastKeyboardInput.Key == Key.Delete && LastKeyboardInput.KeyState == KeyState.Down && userInput.Key == Key.Delete && userInput.KeyState == KeyState.Up && userInput.ModifierKeys == ModifierKeys.None) { result = (_plot.DeletePoints(points) != EditResult.Invalid); } return(result); }
public void OnKeyEvent(KeyEventArgs e) { KeyState keyState = KeyState.None; if (e.IsUp) { keyState = KeyState.Up; } else if (e.IsDown) { keyState = KeyState.Down; } KeyboardInput keyboardInput = new KeyboardInput(e.Key, keyState, Keyboard.Modifiers); UserInput(keyboardInput); }