Exemple #1
0
        private void UserControl_MouseDown(object sender, MouseButtonEventArgs e)
        {
            CaptureMouse();

            var mousePixel = GetPixelPosition(e);

            plottableBeingDragged = plt.GetDraggableUnderMouse(mousePixel.X, mousePixel.Y);

            if (plottableBeingDragged is null)
            {
                // MouseDown event is to start a pan or zoom
                bool shiftIsPressed = Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift);
                if (e.ChangedButton == MouseButton.Left && shiftIsPressed)
                {
                    mouseMiddleDownLocation = GetPixelPosition(e);
                }
                else if (e.ChangedButton == MouseButton.Left && enablePanning)
                {
                    mouseLeftDownLocation = GetPixelPosition(e);
                }
                else if (e.ChangedButton == MouseButton.Right && enableZooming)
                {
                    mouseRightDownLocation = GetPixelPosition(e);
                }
                else if (e.ChangedButton == MouseButton.Middle)
                {
                    mouseMiddleDownLocation = GetPixelPosition(e);
                }
                axisLimitsOnMouseDown = plt.Axis();
            }
            else
            {
                // mouse is being used to drag a plottable
            }
        }
Exemple #2
0
        private void PbPlot_MouseDown(object sender, MouseEventArgs e)
        {
            var mousePixel = e.Location;

            plottableBeingDragged = plt.GetDraggableUnderMouse(mousePixel.X, mousePixel.Y);

            if (plottableBeingDragged is null)
            {
                // MouseDown event is to start a pan or zoom
                if (e.Button == MouseButtons.Left && ModifierKeys.HasFlag(Keys.Shift))
                {
                    mouseMiddleDownLocation = e.Location;
                }
                else if (e.Button == MouseButtons.Left && enablePanning)
                {
                    mouseLeftDownLocation = e.Location;
                }
                else if (e.Button == MouseButtons.Right && enableZooming)
                {
                    mouseRightDownLocation = e.Location;
                }
                else if (e.Button == MouseButtons.Middle)
                {
                    mouseMiddleDownLocation = e.Location;
                }
                axisLimitsOnMouseDown = plt.Axis();
            }
            else
            {
                // mouse is being used to drag a plottable
                OnMouseDownOnPlottable(EventArgs.Empty);
            }
        }