示例#1
0
        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();
            }
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }