Esempio n. 1
0
        private void UserControl_MouseDown(object sender, MouseButtonEventArgs e)
        {
            CaptureMouse();

            draggingAxLine = settings.GetDraggableAxisLineUnderCursor(SDPoint(GetPixelPosition(e)));

            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)
            {
                mouseLeftDownLocation = GetPixelPosition(e);
            }
            else if (e.ChangedButton == MouseButton.Right)
            {
                mouseRightDownLocation = GetPixelPosition(e);
            }
            else if (e.ChangedButton == MouseButton.Middle)
            {
                mouseMiddleDownLocation = GetPixelPosition(e);
            }
            axisLimitsOnMouseDown = plt.Axis();
        }
Esempio n. 2
0
        private void PbPlot_MouseDown(object sender, MouseEventArgs e)
        {
            draggingAxLine = settings.GetDraggableAxisLineUnderCursor(e.Location);

            if (draggingAxLine != null)
            {
                OnMouseDownOnPlottable(EventArgs.Empty);
            }
            else
            {
                // mouse is being used for click and 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();
            }
        }
Esempio n. 3
0
        public PlottableAxLine PlotVLine(
            double x,
            Color? color = null,
            double lineWidth = 1,
            string label = null,
            bool draggable = false,
            double dragLimitLower = double.NegativeInfinity,
            double dragLimitUpper = double.PositiveInfinity,
            LineStyle lineStyle = LineStyle.Solid
            )
        {
            if (color == null)
                color = settings.GetNextColor();

            PlottableAxLine axLine = new PlottableAxLine(
                position: x,
                vertical: true,
                color: (Color)color,
                lineWidth: lineWidth,
                label: label,
                draggable: draggable,
                dragLimitLower: dragLimitLower,
                dragLimitUpper: dragLimitUpper,
                lineStyle: lineStyle
                );

            settings.plottables.Add(axLine);
            return axLine;
        }
Esempio n. 4
0
        private void PbPlot_MouseUp(object sender, MouseEventArgs e)
        {
            if (mouseMiddleDownLocation != null)
            {
                int x1 = Math.Min(mouseLocation.X, ((Point)mouseMiddleDownLocation).X);
                int x2 = Math.Max(mouseLocation.X, ((Point)mouseMiddleDownLocation).X);
                int y1 = Math.Min(mouseLocation.Y, ((Point)mouseMiddleDownLocation).Y);
                int y2 = Math.Max(mouseLocation.Y, ((Point)mouseMiddleDownLocation).Y);

                Point topLeft = new Point(x1, y1);
                Size size = new Size(x2 - x1, y2 - y1);
                Point botRight = new Point(topLeft.X + size.Width, topLeft.Y + size.Height);

                if ((size.Width > 2) && (size.Height > 2))
                {
                    // only change axes if suffeciently large square was drawn
                    plt.Axis(
                            x1: plt.CoordinateFromPixel(topLeft).X,
                            x2: plt.CoordinateFromPixel(botRight).X,
                            y1: plt.CoordinateFromPixel(botRight).Y,
                            y2: plt.CoordinateFromPixel(topLeft).Y
                        );
                }
                else
                {
                    plt.AxisAuto();
                }
            }

            if (mouseRightDownLocation != null)
            {
                int deltaX = Math.Abs(((Point)mouseRightDownLocation).X - mouseLocation.X);
                int deltaY = Math.Abs(((Point)mouseRightDownLocation).Y - mouseLocation.Y);
                if (deltaX < 3 && deltaY < 3)
                {
                    OnMenuDeployed();
                }
            }

            if (isMouseDragging)
                OnMouseDragged(EventArgs.Empty);

            if (isMouseDragging)
                OnAxisChanged();

            if (draggingAxLine != null)
                OnMouseDropPlottable(EventArgs.Empty);

            OnMouseClicked(e);

            mouseLeftDownLocation = null;
            mouseRightDownLocation = null;
            mouseMiddleDownLocation = null;
            axisLimitsOnMouseDown = null;
            settings.mouseMiddleRect = null;
            draggingAxLine = null;
            Render();
        }
Esempio n. 5
0
        /// <summary>
        /// Plot a horizontal line at the given Y position
        /// </summary>
        public void PlotHLine(double x, Color?color = null, double lineWidth = 1, string label = null, bool draggable = false, double dragLimitLower = double.NegativeInfinity, double dragLimitUpper = double.PositiveInfinity)
        {
            if (color == null)
            {
                color = settings.GetNextColor();
            }
            PlottableAxLine axLine = new PlottableAxLine(x, vertical: false, color: (Color)color, lineWidth: lineWidth, label: label, draggable: draggable, dragLimitLower: dragLimitLower, dragLimitUpper: dragLimitUpper);

            settings.plottables.Add(axLine);
        }
Esempio n. 6
0
        /// <summary>
        /// Plot a horizontal line at the given Y position
        /// </summary>
        public void PlotHLine(double x, Color?color = null, double lineWidth = 1, string label = null)
        {
            if (color == null)
            {
                color = settings.GetNextColor();
            }
            PlottableAxLine axLine = new PlottableAxLine(x, vertical: false, color: (Color)color, lineWidth: lineWidth, label: label);

            settings.plottables.Add(axLine);
        }
Esempio n. 7
0
        private void UserControl_MouseUp(object sender, MouseButtonEventArgs e)
        {
            ReleaseMouseCapture();

            draggingAxLine = null;

            if (mouseMiddleDownLocation != null)
            {
                double x1 = Math.Min(mouseLocation.X, ((Point)mouseMiddleDownLocation).X);
                double x2 = Math.Max(mouseLocation.X, ((Point)mouseMiddleDownLocation).X);
                double y1 = Math.Min(mouseLocation.Y, ((Point)mouseMiddleDownLocation).Y);
                double y2 = Math.Max(mouseLocation.Y, ((Point)mouseMiddleDownLocation).Y);

                Point topLeft  = new Point(x1, y1);
                Size  size     = new Size(x2 - x1, y2 - y1);
                Point botRight = new Point(topLeft.X + size.Width, topLeft.Y + size.Height);

                if ((size.Width > 2) && (size.Height > 2))
                {
                    // only change axes if suffeciently large square was drawn
                    plt.Axis(
                        x1: plt.CoordinateFromPixel((int)topLeft.X, (int)topLeft.Y).X,
                        x2: plt.CoordinateFromPixel((int)botRight.X, (int)botRight.Y).X,
                        y1: plt.CoordinateFromPixel((int)botRight.X, (int)botRight.Y).Y,
                        y2: plt.CoordinateFromPixel((int)topLeft.X, (int)topLeft.Y).Y
                        );
                }
                else
                {
                    plt.AxisAuto();
                }
            }

            mouseLeftDownLocation    = null;
            mouseRightDownLocation   = null;
            mouseMiddleDownLocation  = null;
            axisLimitsOnMouseDown    = null;
            settings.mouseMiddleRect = null;
            Render();
        }