예제 #1
0
파일: PlotScale.cs 프로젝트: wwwK/XwPlot
        public override bool OnButtonPressed(ButtonEventArgs args, PlotCanvas pc)
        {
            // Only start scaling if mouse is inside plot area (excluding axes)
            Rectangle area = pc.PlotAreaBoundingBoxCache;

            if (area.Contains(args.Position))
            {
                scaling   = true;
                lastPoint = new Point(args.X, args.Y);
                if (args.Button == PointerButton.Left)
                {
                    if (Horizontal)
                    {
                        ;                        //pc.plotCursor = CursorType.LeftRight;
                    }
                    if (Vertical)
                    {
                        ;                        //pc.plotCursor = CursorType.UpDown;
                    }
                    if (Horizontal && Vertical)
                    {
                        ;                        //pc.plotCursor = CursorType.Zoom;
                    }
                }
                // evaluate focusPoint about which axis is expanded
                focusX = (double)(args.X - area.Left) / (double)area.Width;
                focusY = (double)(area.Bottom - args.Y) / (double)area.Height;
            }
            return(false);
        }
예제 #2
0
파일: AxisDrag.cs 프로젝트: wwwK/XwPlot
        public override bool OnMouseMoved(MouseMovedEventArgs args, PlotCanvas pc)
        {
            Rectangle area = pc.PlotAreaBoundingBoxCache;

            if (dragging && physicalAxis != null)
            {
                pc.CacheAxes();

                double dX = args.X - lastPoint.X;
                double dY = args.Y - lastPoint.Y;
                lastPoint = new Point(args.X, args.Y);

                double length = physicalAxis.PhysicalLength;

                if (translateX)
                {
                    double xShift = -dX / length;
                    pc.TranslateXAxes(xShift);
                }
                if (translateY)
                {
                    double yShift = +dY / length;
                    pc.TranslateYAxes(yShift);
                }
                return(true);
            }
            return(false);
        }
예제 #3
0
        public override bool OnMouseMoved(MouseMovedEventArgs args, PlotCanvas pc)
        {
            double X = args.X;
            double Y = args.Y;

            if (selectionActive)
            {
                // note last selection rectangle
                Rectangle lastSelection = selection;
                Rectangle bounds        = pc.PlotAreaBoundingBoxCache;
                // clip selection rectangle to PlotArea
                X = Math.Max(X, bounds.Left);
                X = Math.Min(X, bounds.Right);
                Y = Math.Max(Y, bounds.Top);
                Y = Math.Min(Y, bounds.Bottom);

                endPoint.X = X;
                endPoint.Y = Y;
                selection  = FromPoints(startPoint, endPoint);

                pc.Canvas.QueueDraw(lastSelection);
                //Console.WriteLine ("Erase: {0} {1} {2} {3} ", lastSelection.X, lastSelection.Y, lastSelection.Width, lastSelection.Height);
                pc.Canvas.QueueDraw(selection);
            }
            return(false);
        }
예제 #4
0
파일: PlotDrag.cs 프로젝트: wwwK/XwPlot
        public override bool OnMouseMoved(MouseMovedEventArgs args, PlotCanvas pc)
        {
            Rectangle area = pc.PlotAreaBoundingBoxCache;

            if (dragging)
            {
                pc.CacheAxes();

                double dX = args.X - lastPoint.X;                               // distance mouse has moved
                double dY = args.Y - lastPoint.Y;
                lastPoint = new Point(args.X, args.Y);

                // Axis translation required
                double xShift = -dX / area.Width;
                double yShift = +dY / area.Height;

                if (Horizontal)
                {
                    pc.TranslateXAxes(xShift);
                }
                if (Vertical)
                {
                    pc.TranslateYAxes(yShift);
                }
                return(true);
            }
            return(false);
        }
예제 #5
0
파일: PlotScale.cs 프로젝트: wwwK/XwPlot
        public override bool OnMouseMoved(MouseMovedEventArgs args, PlotCanvas pc)
        {
            Rectangle area = pc.PlotAreaBoundingBoxCache;

            if (scaling)
            {
                pc.CacheAxes();

                double dX = args.X - lastPoint.X;                               // distance mouse has moved
                double dY = args.Y - lastPoint.Y;
                lastPoint = new Point(args.X, args.Y);

                // Alt key reduces sensitivity
                double factor = Sensitivity;
                if (key == Key.AltLeft || key == Key.AltRight)
                {
                    factor *= 0.25;                        // arbitrary change
                }

                double xProportion = +dX * factor / area.Width;
                double yProportion = -dY * factor / area.Height;
                if (Horizontal)
                {
                    pc.ZoomXAxes(xProportion, focusX);
                }
                if (Vertical)
                {
                    pc.ZoomYAxes(yProportion, focusY);
                }
                return(true);
            }
            return(false);
        }
예제 #6
0
 public override bool OnMouseExited(EventArgs args, PlotCanvas pc)
 {
     if (selectionActive)
     {
         pc.Canvas.QueueDraw(selection);
         selectionActive = false;
     }
     return(false);
 }
예제 #7
0
파일: PlotScale.cs 프로젝트: wwwK/XwPlot
 public override bool OnButtonReleased(ButtonEventArgs args, PlotCanvas pc)
 {
     if (scaling)
     {
         lastPoint = unset;
         scaling   = false;
         //pc.plotCursor = CursorType.LeftPointer;
     }
     return(false);
 }
예제 #8
0
        /// <summary>
        /// OnButtonPressed method for AxisScale interaction
        /// </summary>
        public override bool OnButtonPressed(ButtonEventArgs args, PlotCanvas pc)
        {
            // if the mouse is inside the plot area (the tick marks may be here,
            // and are counted as part of the axis), then *don't* invoke scaling
            if (pc.PlotAreaBoundingBoxCache.Contains(args.X, args.Y))
            {
                return(false);
            }

            if (args.Button == PointerButton.Left)
            {
                // see if hit with axis. NB Only one axis object will be returned
                ArrayList objects = pc.HitTest(new Point(args.X, args.Y));

                foreach (object o in objects)
                {
                    if (o is Axis)
                    {
                        dragging = true;
                        axis     = (Axis)o;
                        if (pc.PhysicalXAxis1Cache.Axis == axis)
                        {
                            physicalAxis = pc.PhysicalXAxis1Cache;
                            //pc.plotCursor = CursorType.LeftRight;
                        }
                        else if (pc.PhysicalXAxis2Cache.Axis == axis)
                        {
                            physicalAxis = pc.PhysicalXAxis2Cache;
                            //ps.plotCursor = CursorType.LeftRight;
                        }
                        else if (pc.PhysicalYAxis1Cache.Axis == axis)
                        {
                            physicalAxis = pc.PhysicalYAxis1Cache;
                            //pc.plotCursor = CursorType.UpDown;
                        }
                        else if (pc.PhysicalYAxis2Cache.Axis == axis)
                        {
                            physicalAxis = pc.PhysicalYAxis2Cache;
                            //pc.plotCursor = CursorType.UpDown;
                        }

                        startPoint = new Point(args.X, args.Y);
                        lastPoint  = startPoint;

                        // evaluate focusRatio about which axis is expanded
                        double x = startPoint.X - physicalAxis.PhysicalMin.X;
                        double y = startPoint.Y - physicalAxis.PhysicalMin.Y;
                        double r = Math.Sqrt(x * x + y * y);
                        focusRatio = r / physicalAxis.PhysicalLength;
                        return(false);
                    }
                }
            }
            return(false);
        }
예제 #9
0
파일: AxisDrag.cs 프로젝트: wwwK/XwPlot
 /// <summary>
 /// OnButtonReleased method for AxisDrag interaction
 /// </summary>
 public override bool OnButtonReleased(ButtonEventArgs args, PlotCanvas pc)
 {
     if (dragging)
     {
         physicalAxis = null;
         lastPoint    = unset;
         dragging     = false;
         translateX   = false;
         translateY   = false;
     }
     return(false);
 }
예제 #10
0
 /// <summary>
 /// OnButtonReleased method for AxisScale interaction
 /// </summary>
 public override bool OnButtonReleased(ButtonEventArgs args, PlotCanvas pc)
 {
     if (dragging)
     {
         dragging     = false;
         axis         = null;
         physicalAxis = null;
         lastPoint    = new Point();
         //pc.plotCursor = CursorType.LeftPointer;
     }
     return(false);
 }
예제 #11
0
        public override bool OnButtonPressed(ButtonEventArgs args, PlotCanvas pc)
        {
            // Only start selection if mouse is inside plot area (excluding axes)
            Rectangle area = pc.PlotAreaBoundingBoxCache;

            if (args.Button == PointerButton.Left && area.Contains(args.Position))
            {
                selectionActive = true;
                startPoint.X    = args.X;
                startPoint.Y    = args.Y;
                endPoint        = startPoint;
            }
            return(false);
        }
예제 #12
0
파일: KeyActions.cs 프로젝트: wwwK/XwPlot
        /// <summary>
        /// Handler for KeyPressed events
        /// </summary>
        /// <param name="args">the Xwt.KeyEventArgs</param>
        /// <param name="pc">the PlotCanvas</param>
        /// <returns>
        /// true if the underlying (cached) plot requires redrawing, otherwise false
        /// </returns>
        public override bool OnKeyPressed(KeyEventArgs args, PlotCanvas pc)
        {
            double factor = Sensitivity;
            Key key = args.Key;
            ModifierKeys modifiers = args.Modifiers;

            if ((modifiers & ModifierKeys.Alt) != 0) {
                factor = Sensitivity * altFactor;
            }

            if (key == Key.Home || key == Key.NumPadHome) {
                pc.SetOriginalDimensions ();
                return true;
            }
            if (key == Key.Left || key == Key.NumPadLeft) {
                pc.CacheAxes();
                pc.TranslateXAxes (factor * left);
                return true;
            }
            if (key == Key.Right || key == Key.NumPadRight) {
                pc.CacheAxes();
                pc.TranslateXAxes (factor*right);
                return true;
            }
            if (key == Key.Up || key == Key.NumPadUp) {
                pc.CacheAxes ();
                pc.TranslateYAxes (factor*up);
                return true;
            }
            if (key == Key.Down || key == Key.NumPadDown) {
                pc.CacheAxes ();
                pc.TranslateYAxes (factor*down);
                return true;
            }
            if (key == Key.Plus || key == Key.NumPadAdd) {
                pc.CacheAxes ();
                pc.ZoomXAxes (zoomIn*factor, symmetrical);
                pc.ZoomYAxes (zoomIn*factor, symmetrical);
                return true;
            }
            if (key == Key.Minus || key == Key.NumPadSubtract) {
                pc.CacheAxes ();
                pc.ZoomXAxes (zoomOut*factor, symmetrical);
                pc.ZoomYAxes (zoomOut*factor, symmetrical);
                return true;
            }
            return false;
        }
예제 #13
0
파일: AxisDrag.cs 프로젝트: wwwK/XwPlot
        /// <summary>
        /// OnButtonPressed method for AxisDrag interaction
        /// </summary>
        public override bool OnButtonPressed(ButtonEventArgs args, PlotCanvas pc)
        {
            // if the mouse is inside the plot area (the tick marks may be here,
            // and are counted as part of the axis), then *don't* invoke scaling
            if (pc.PlotAreaBoundingBoxCache.Contains(args.X, args.Y))
            {
                return(false);
            }

            if (args.Button == PointerButton.Left)
            {
                // see if hit with axis. NB Only one axis object will be returned
                ArrayList objects = pc.HitTest(new Point(args.X, args.Y));
                foreach (object o in objects)
                {
                    if (o is Axis)
                    {
                        dragging = true;
                        Axis axis = (Axis)o;
                        if (pc.PhysicalXAxis1Cache.Axis == axis)
                        {
                            physicalAxis = pc.PhysicalXAxis1Cache;
                            translateX   = true;
                        }
                        else if (pc.PhysicalXAxis2Cache.Axis == axis)
                        {
                            physicalAxis = pc.PhysicalXAxis2Cache;
                            translateX   = true;
                        }
                        else if (pc.PhysicalYAxis1Cache.Axis == axis)
                        {
                            physicalAxis = pc.PhysicalYAxis1Cache;
                            translateY   = true;
                        }
                        else if (pc.PhysicalYAxis2Cache.Axis == axis)
                        {
                            physicalAxis = pc.PhysicalYAxis2Cache;
                            translateY   = true;
                        }
                        lastPoint = new Point(args.X, args.Y);
                        return(false);
                    }
                }
            }
            return(false);
        }
예제 #14
0
파일: PlotDrag.cs 프로젝트: wwwK/XwPlot
        public override bool OnButtonPressed(ButtonEventArgs args, PlotCanvas pc)
        {
            // Only start drag if mouse is inside plot area (excluding axes)
            Rectangle area = pc.PlotAreaBoundingBoxCache;

            if (area.Contains(args.Position))
            {
                dragging  = true;
                lastPoint = new Point(args.X, args.Y);
                if (args.Button == PointerButton.Left)
                {
                    if (Horizontal || Vertical)
                    {
                        //pc.plotCursor = CursorType.Hand;
                    }
                }
            }
            return(false);
        }
예제 #15
0
파일: PlotZoom.cs 프로젝트: wwwK/XwPlot
        /// <summary>
        /// Mouse Scroll (wheel) method for PlotZoom interaction
        /// </summary>
        public override bool OnMouseScrolled(MouseScrolledEventArgs args, PlotCanvas pc)
        {
            double proportion = 0.1 * Sensitivity;              // use initial zoom of 10%
            double focusX = 0.5, focusY = 0.5;                  // default focus point

            double direction = 1;

            if (args.Direction == ScrollDirection.Down)
            {
                direction = -1;
            }

            // Zoom direction is +1 for Up/ZoomIn, or -1 for Down/ZoomOut
            proportion *= -direction;

            // delete previous focusPoint drawing
            pc.Canvas.QueueDraw(focusRect);

            Rectangle area = pc.PlotAreaBoundingBoxCache;

            if (area.Contains(args.X, args.Y))
            {
                focus.X = args.X;
                focus.Y = args.Y;
                focusX  = (double)(args.X - area.Left) / (double)area.Width;
                focusY  = (double)(area.Bottom - args.Y) / (double)area.Height;
            }

            // Zoom in/out for all defined axes
            pc.CacheAxes();
            pc.ZoomXAxes(proportion, focusX);
            pc.ZoomYAxes(proportion, focusY);

            double x = focus.X - 32;
            double y = focus.Y - 32;

            focusRect = new Rectangle(x, y, 64, 64);
            // draw new focusRect
            pc.Canvas.QueueDraw(focusRect);

            return(true);
        }
예제 #16
0
        /// <summary>
        /// OnMouseMoved method for AxisScale interaction
        /// </summary>
        public override bool OnMouseMoved(MouseMovedEventArgs args, PlotCanvas pc)
        {
            if (dragging && physicalAxis != null)
            {
                pc.CacheAxes();

                double dX = (args.X - lastPoint.X);
                double dY = (args.Y - lastPoint.Y);
                lastPoint = new Point(args.X, args.Y);

                // In case the physical axis is not horizontal/vertical, combine dX and dY
                // in a way which preserves their sign and intuitive axis zoom sense, ie
                // because the physical origin is top-left, expand with +ve dX, but -ve dY
                double distance   = dX - dY;
                double proportion = distance * Sensitivity / physicalAxis.PhysicalLength;
                axis.IncreaseRange(proportion, focusRatio);
                return(true);
            }
            return(false);
        }
예제 #17
0
        public override bool OnButtonReleased(ButtonEventArgs args, PlotCanvas pc)
        {
            bool modified = false;

            // delete previous overlay rectangle
            pc.Canvas.QueueDraw(selection);

            if (selectionActive)
            {
                selectionActive = false;
                Rectangle bounds = pc.PlotAreaBoundingBoxCache;
                if (!bounds.Contains(endPoint))
                {
                    // MouseUp outside plotArea - cancel selection
                    modified = false;
                }
                else
                {
                    pc.CacheAxes();
                    // Redefine range based on selection. The proportions for
                    // Min and Max do not require Min < Max, since they will
                    // be re-ordered by Axis.DefineRange if necessary
                    double xMin = startPoint.X - bounds.Left;
                    double yMin = bounds.Bottom - startPoint.Y;

                    double xMax = endPoint.X - bounds.Left;
                    double yMax = bounds.Bottom - endPoint.Y;

                    double xMinProp = xMin / bounds.Width;
                    double xMaxProp = xMax / bounds.Width;
                    double yMinProp = yMin / bounds.Height;
                    double yMaxProp = yMax / bounds.Height;

                    pc.DefineXAxes(xMinProp, xMaxProp);
                    pc.DefineYAxes(yMinProp, yMaxProp);
                    modified = true;
                }
            }
            return(modified);
        }
예제 #18
0
파일: AxisDrag.cs 프로젝트: hwthomas/XwPlot
        /// <summary>
        /// OnButtonPressed method for AxisDrag interaction
        /// </summary>
        public override bool OnButtonPressed(ButtonEventArgs args, PlotCanvas pc)
        {
            // if the mouse is inside the plot area (the tick marks may be here,
            // and are counted as part of the axis), then *don't* invoke scaling
            if (pc.PlotAreaBoundingBoxCache.Contains(args.X, args.Y)) {
                return false;
            }

            if (args.Button == PointerButton.Left) {
                // see if hit with axis. NB Only one axis object will be returned
                ArrayList objects = pc.HitTest (new Point(args.X, args.Y));
                foreach (object o in objects) {
                    if (o is Axis) {
                        dragging = true;
                        Axis axis = (Axis)o;
                        if (pc.PhysicalXAxis1Cache.Axis == axis) {
                            physicalAxis = pc.PhysicalXAxis1Cache;
                            translateX = true;
                        }
                        else if (pc.PhysicalXAxis2Cache.Axis == axis) {
                            physicalAxis = pc.PhysicalXAxis2Cache;
                            translateX = true;
                        }
                        else if (pc.PhysicalYAxis1Cache.Axis == axis) {
                            physicalAxis = pc.PhysicalYAxis1Cache;
                            translateY = true;
                        }
                        else if (pc.PhysicalYAxis2Cache.Axis == axis) {
                            physicalAxis = pc.PhysicalYAxis2Cache;
                            translateY = true;
                        }
                        lastPoint = new Point (args.X, args.Y);
                        return false;
                    }
                }
            }
            return false;
        }
예제 #19
0
파일: PlotZoom.cs 프로젝트: wwwK/XwPlot
 /// <summary>
 /// MouseMove method for PlotScroll
 /// </summary>
 public override bool OnMouseMoved(MouseMovedEventArgs args, PlotCanvas pc)
 {
     // delete previous focusPoint drawing
     pc.Canvas.QueueDraw(focusRect);
     return(false);
 }
예제 #20
0
        public override bool OnMouseMoved(MouseMovedEventArgs args, PlotCanvas pc)
        {
            Rectangle area = pc.PlotAreaBoundingBoxCache;

            if (scaling) {
                pc.CacheAxes();

                double dX = args.X - lastPoint.X;		// distance mouse has moved
                double dY = args.Y - lastPoint.Y;
                lastPoint = new Point (args.X, args.Y);

                // Alt key reduces sensitivity
                double factor = Sensitivity;
                if (key == Key.AltLeft || key == Key.AltRight) {
                    factor *= 0.25;	   // arbitrary change
                }

                double xProportion = +dX*factor/area.Width;
                double yProportion = -dY*factor/area.Height;
                if (Horizontal) {
                    pc.ZoomXAxes (xProportion, focusX);
                }
                if (Vertical) {
                    pc.ZoomYAxes (yProportion, focusY);
                }
                return true;
            }
            return false;
        }
예제 #21
0
 public override bool OnKeyReleased(KeyEventArgs args, PlotCanvas pc)
 {
     key = args.Key;
     return false;
 }
예제 #22
0
 public override bool OnButtonPressed(ButtonEventArgs args, PlotCanvas pc)
 {
     // Only start scaling if mouse is inside plot area (excluding axes)
     Rectangle area = pc.PlotAreaBoundingBoxCache;
     if (area.Contains (args.Position)) {
         scaling = true;
         lastPoint = new Point (args.X, args.Y);
         if (args.Button == PointerButton.Left) {
             if (Horizontal) {
                 ;//pc.plotCursor = CursorType.LeftRight;
             }
             if (Vertical) {
                 ;//pc.plotCursor = CursorType.UpDown;
             }
             if (Horizontal && Vertical) {
                 ;//pc.plotCursor = CursorType.Zoom;
             }
         }
         // evaluate focusPoint about which axis is expanded
         focusX = (double)(args.X - area.Left)/(double)area.Width;
         focusY = (double)(area.Bottom - args.Y)/(double)area.Height;
     }
     return false;
 }
예제 #23
0
 public override bool OnMouseExited(EventArgs args, PlotCanvas pc)
 {
     if (selectionActive) {
         pc.Canvas.QueueDraw (selection);
         selectionActive = false;
     }
     return false;
 }
예제 #24
0
파일: AxisDrag.cs 프로젝트: hwthomas/XwPlot
        public override bool OnMouseMoved(MouseMovedEventArgs args, PlotCanvas pc)
        {
            Rectangle area = pc.PlotAreaBoundingBoxCache;

            if (dragging && physicalAxis != null) {
                pc.CacheAxes();

                double dX = args.X - lastPoint.X;
                double dY = args.Y - lastPoint.Y;
                lastPoint = new Point (args.X, args.Y);

                double length = physicalAxis.PhysicalLength;

                if (translateX) {
                    double xShift = -dX / length;
                    pc.TranslateXAxes (xShift);
                }
                if (translateY) {
                    double yShift = +dY / length;
                    pc.TranslateYAxes (yShift);
                }
                return true;
            }
            return false;
        }
예제 #25
0
파일: PlotZoom.cs 프로젝트: hwthomas/XwPlot
 /// <summary>
 /// MouseMove method for PlotScroll
 /// </summary>
 public override bool OnMouseMoved(MouseMovedEventArgs args, PlotCanvas pc)
 {
     // delete previous focusPoint drawing
     pc.Canvas.QueueDraw (focusRect);
     return false;
 }
예제 #26
0
 public override bool OnButtonPressed(ButtonEventArgs args, PlotCanvas pc)
 {
     // Only start selection if mouse is inside plot area (excluding axes)
     Rectangle area = pc.PlotAreaBoundingBoxCache;
     if (args.Button == PointerButton.Left && area.Contains (args.Position)) {
         selectionActive = true;
         startPoint.X = args.X;
         startPoint.Y = args.Y;
         endPoint = startPoint;
     }
     return false;
 }
예제 #27
0
 public virtual bool OnMouseScrolled(MouseScrolledEventArgs args, PlotCanvas pc)
 {
     return(false);
 }
예제 #28
0
 public virtual bool OnMouseExited(EventArgs args, PlotCanvas pc)
 {
     return(false);
 }
예제 #29
0
        public override bool OnMouseMoved(MouseMovedEventArgs args, PlotCanvas pc)
        {
            double X = args.X;
            double Y = args.Y;

            if (selectionActive) {
                // note last selection rectangle
                Rectangle lastSelection = selection;
                Rectangle bounds = pc.PlotAreaBoundingBoxCache;
                // clip selection rectangle to PlotArea
                X = Math.Max(X, bounds.Left);
                X = Math.Min(X, bounds.Right);
                Y = Math.Max(Y, bounds.Top);
                Y = Math.Min(Y, bounds.Bottom);

                endPoint.X = X;
                endPoint.Y = Y;
                selection = FromPoints (startPoint, endPoint);

                pc.Canvas.QueueDraw (lastSelection);
                //Console.WriteLine ("Erase: {0} {1} {2} {3} ", lastSelection.X, lastSelection.Y, lastSelection.Width, lastSelection.Height);
                pc.Canvas.QueueDraw (selection);
            }
            return false;
        }
예제 #30
0
파일: PlotZoom.cs 프로젝트: hwthomas/XwPlot
        /// <summary>
        /// Mouse Scroll (wheel) method for PlotZoom interaction
        /// </summary>
        public override bool OnMouseScrolled(MouseScrolledEventArgs args, PlotCanvas pc)
        {
            double proportion = 0.1*Sensitivity;	// use initial zoom of 10%
            double focusX = 0.5, focusY = 0.5;		// default focus point

            double direction = 1;
            if (args.Direction == ScrollDirection.Down) {
                direction = -1;
            }

            // Zoom direction is +1 for Up/ZoomIn, or -1 for Down/ZoomOut
            proportion *= -direction;

            // delete previous focusPoint drawing
            pc.Canvas.QueueDraw (focusRect);

            Rectangle area = pc.PlotAreaBoundingBoxCache;
            if (area.Contains(args.X, args.Y)) {
                focus.X = args.X;
                focus.Y = args.Y;
                focusX = (double)(args.X - area.Left)/(double)area.Width;
                focusY = (double)(area.Bottom - args.Y)/(double)area.Height;
            }

            // Zoom in/out for all defined axes
            pc.CacheAxes();
            pc.ZoomXAxes (proportion,focusX);
            pc.ZoomYAxes (proportion,focusY);

            double x = focus.X-32;
            double y = focus.Y-32;

            focusRect = new Rectangle (x, y, 64, 64);
            // draw new focusRect
            pc.Canvas.QueueDraw (focusRect);

            return (true);
        }
예제 #31
0
파일: KeyActions.cs 프로젝트: wwwK/XwPlot
 /// <summary>
 /// Handler for KeyRelease events
 /// </summary>
 /// <param name="key">the NPlot key enumeration</param>
 /// <param name="pc">the PlotCanvas</param>
 /// <returns></returns> 
 public override bool OnKeyReleased(KeyEventArgs args, PlotCanvas pc)
 {
     return false;
 }
예제 #32
0
 /// <summary>
 /// OnButtonReleased method for AxisScale interaction
 /// </summary>
 public override bool OnButtonReleased(ButtonEventArgs args, PlotCanvas pc)
 {
     if (dragging) {
         dragging = false;
         axis = null;
         physicalAxis = null;
         lastPoint = new Point();
         //pc.plotCursor = CursorType.LeftPointer;
     }
     return false;
 }
예제 #33
0
파일: AxisDrag.cs 프로젝트: hwthomas/XwPlot
 /// <summary>
 /// OnButtonReleased method for AxisDrag interaction
 /// </summary>
 public override bool OnButtonReleased(ButtonEventArgs args, PlotCanvas pc)
 {
     if (dragging) {
         physicalAxis = null;
         lastPoint = unset;
         dragging = false;
         translateX = false;
         translateY = false;
     }
     return false;
 }
예제 #34
0
        public override bool OnButtonReleased(ButtonEventArgs args, PlotCanvas pc)
        {
            bool modified = false;

            // delete previous overlay rectangle
            pc.Canvas.QueueDraw (selection);

            if (selectionActive) {
                selectionActive = false;
                Rectangle bounds = pc.PlotAreaBoundingBoxCache;
                if (!bounds.Contains(endPoint)) {
                    // MouseUp outside plotArea - cancel selection
                    modified = false;
                }
                else {
                    pc.CacheAxes();
                    // Redefine range based on selection. The proportions for
                    // Min and Max do not require Min < Max, since they will
                    // be re-ordered by Axis.DefineRange if necessary
                    double xMin = startPoint.X - bounds.Left;
                    double yMin = bounds.Bottom - startPoint.Y;

                    double xMax = endPoint.X - bounds.Left;
                    double yMax = bounds.Bottom - endPoint.Y;

                    double xMinProp = xMin/bounds.Width;
                    double xMaxProp = xMax/bounds.Width;
                    double yMinProp = yMin/bounds.Height;
                    double yMaxProp = yMax/bounds.Height;

                    pc.DefineXAxes (xMinProp, xMaxProp);
                    pc.DefineYAxes (yMinProp, yMaxProp);
                    modified = true;
                }
            }
            return modified;
        }
예제 #35
0
        PlotCanvas plotCanvas;          // To allow access to parent PlotCanvas

        /// <summary>
        /// Creates a new DrawingSurface and saves a reference to the PlotSurface
        /// </summary>
        internal DrawingSurface(PlotCanvas pc) : base()
        {
            plotCanvas = pc;
        }
예제 #36
0
 public virtual bool OnButtonReleased(ButtonEventArgs args, PlotCanvas pc)
 {
     return(false);
 }
예제 #37
0
파일: PlotScale.cs 프로젝트: wwwK/XwPlot
 public override bool OnKeyReleased(KeyEventArgs args, PlotCanvas pc)
 {
     key = args.Key;
     return(false);
 }
예제 #38
0
 public virtual bool OnKeyReleased(KeyEventArgs args, PlotCanvas pc)
 {
     return(false);
 }
예제 #39
0
        /// <summary>
        /// OnButtonPressed method for AxisScale interaction
        /// </summary>
        public override bool OnButtonPressed(ButtonEventArgs args, PlotCanvas pc)
        {
            // if the mouse is inside the plot area (the tick marks may be here,
            // and are counted as part of the axis), then *don't* invoke scaling
            if (pc.PlotAreaBoundingBoxCache.Contains(args.X, args.Y)) {
                return false;
            }

            if (args.Button == PointerButton.Left) {
                // see if hit with axis. NB Only one axis object will be returned
                ArrayList objects = pc.HitTest (new Point(args.X, args.Y));

                foreach (object o in objects) {
                    if (o is Axis) {
                        dragging = true;
                        axis = (Axis)o;
                        if (pc.PhysicalXAxis1Cache.Axis == axis) {
                            physicalAxis = pc.PhysicalXAxis1Cache;
                            //pc.plotCursor = CursorType.LeftRight;
                        }
                        else if (pc.PhysicalXAxis2Cache.Axis == axis) {
                            physicalAxis = pc.PhysicalXAxis2Cache;
                            //ps.plotCursor = CursorType.LeftRight;
                        }
                        else if (pc.PhysicalYAxis1Cache.Axis == axis) {
                            physicalAxis = pc.PhysicalYAxis1Cache;
                            //pc.plotCursor = CursorType.UpDown;
                        }
                        else if (pc.PhysicalYAxis2Cache.Axis == axis) {
                            physicalAxis = pc.PhysicalYAxis2Cache;
                            //pc.plotCursor = CursorType.UpDown;
                        }

                        startPoint = new Point (args.X, args.Y);
                        lastPoint = startPoint;

                        // evaluate focusRatio about which axis is expanded
                        double  x = startPoint.X - physicalAxis.PhysicalMin.X;
                        double  y = startPoint.Y - physicalAxis.PhysicalMin.Y;
                        double r = Math.Sqrt(x*x + y*y);
                        focusRatio = r/physicalAxis.PhysicalLength;
                        return false;
                    }
                }
            }
            return false;
        }
예제 #40
0
        /// <summary>
        /// OnMouseMoved method for AxisScale interaction
        /// </summary>
        public override bool OnMouseMoved(MouseMovedEventArgs args, PlotCanvas pc)
        {
            if (dragging && physicalAxis != null) {
                pc.CacheAxes();

                double dX = (args.X - lastPoint.X);
                double dY = (args.Y - lastPoint.Y);
                lastPoint = new Point (args.X, args.Y);

                // In case the physical axis is not horizontal/vertical, combine dX and dY
                // in a way which preserves their sign and intuitive axis zoom sense, ie
                // because the physical origin is top-left, expand with +ve dX, but -ve dY
                double distance = dX - dY;
                double proportion = distance*Sensitivity /physicalAxis.PhysicalLength;
                axis.IncreaseRange (proportion, focusRatio);
                return true;
            }
            return false;
        }
예제 #41
0
파일: PlotDrag.cs 프로젝트: hwthomas/XwPlot
        public override bool OnMouseMoved(MouseMovedEventArgs args, PlotCanvas pc)
        {
            Rectangle area = pc.PlotAreaBoundingBoxCache;

            if (dragging) {
                pc.CacheAxes();

                double dX = args.X - lastPoint.X;		// distance mouse has moved
                double dY = args.Y - lastPoint.Y;
                lastPoint = new Point (args.X, args.Y);

                // Axis translation required
                double xShift = -dX / area.Width;
                double yShift = +dY / area.Height;

                if (Horizontal) {
                    pc.TranslateXAxes (xShift);
                }
                if (Vertical) {
                    pc.TranslateYAxes (yShift);
                }
                return true;
            }
            return false;
        }
예제 #42
0
파일: PlotDrag.cs 프로젝트: hwthomas/XwPlot
 public override bool OnButtonReleased(ButtonEventArgs args, PlotCanvas pc)
 {
     if (dragging) {
         lastPoint = unset;
         dragging = false;
         //pc.plotCursor = CursorType.LeftPointer;
     }
     return false;
 }
예제 #43
0
 public virtual bool OnMouseScrolled(MouseScrolledEventArgs args, PlotCanvas pc)
 {
     return false;
 }
예제 #44
0
파일: PlotDrag.cs 프로젝트: hwthomas/XwPlot
 public override bool OnButtonPressed(ButtonEventArgs args, PlotCanvas pc)
 {
     // Only start drag if mouse is inside plot area (excluding axes)
     Rectangle area = pc.PlotAreaBoundingBoxCache;
     if (area.Contains (args.Position)) {
         dragging = true;
         lastPoint = new Point (args.X, args.Y);
         if (args.Button == PointerButton.Left) {
             if (Horizontal || Vertical) {
                 //pc.plotCursor = CursorType.Hand;
             }
         }
     }
     return false;
 }
예제 #45
0
 public virtual bool OnButtonReleased(ButtonEventArgs args, PlotCanvas pc)
 {
     return false;
 }
예제 #46
0
 public virtual bool OnKeyReleased(KeyEventArgs args, PlotCanvas pc)
 {
     return false;
 }
예제 #47
0
 public virtual bool OnMouseEntered(EventArgs args, PlotCanvas pc)
 {
     return false;
 }
예제 #48
0
        PlotCanvas plotCanvas; // To allow access to parent PlotCanvas

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Creates a new DrawingSurface and saves a reference to the PlotSurface
        /// </summary>
        internal DrawingSurface(PlotCanvas pc)
            : base()
        {
            plotCanvas = pc;
        }
예제 #49
0
        /// <summary>
        /// Handler for KeyPressed events
        /// </summary>
        /// <param name="args">the Xwt.KeyEventArgs</param>
        /// <param name="pc">the PlotCanvas</param>
        /// <returns>
        /// true if the underlying (cached) plot requires redrawing, otherwise false
        /// </returns>
        public override bool OnKeyPressed(KeyEventArgs args, PlotCanvas pc)
        {
            double factor = Sensitivity;
            Key key = args.Key;
            ModifierKeys modifiers = args.Modifiers;

            if ((modifiers & ModifierKeys.Alt) != 0) {
                factor = Sensitivity * altFactor;
            }

            if (key == Key.Home || key == Key.NumPadHome) {
                pc.SetOriginalDimensions ();
                return true;
            }
            if (key == Key.Left || key == Key.NumPadLeft) {
                pc.CacheAxes();
                pc.TranslateXAxes (factor * left);
                return true;
            }
            if (key == Key.Right || key == Key.NumPadRight) {
                pc.CacheAxes();
                pc.TranslateXAxes (factor*right);
                return true;
            }
            if (key == Key.Up || key == Key.NumPadUp) {
                pc.CacheAxes ();
                pc.TranslateYAxes (factor*up);
                return true;
            }
            if (key == Key.Down || key == Key.NumPadDown) {
                pc.CacheAxes ();
                pc.TranslateYAxes (factor*down);
                return true;
            }
            if (key == Key.Plus || key == Key.NumPadAdd) {
                pc.CacheAxes ();
                pc.ZoomXAxes (zoomIn*factor, symmetrical);
                pc.ZoomYAxes (zoomIn*factor, symmetrical);
                return true;
            }
            if (key == Key.Minus || key == Key.NumPadSubtract) {
                pc.CacheAxes ();
                pc.ZoomXAxes (zoomOut*factor, symmetrical);
                pc.ZoomYAxes (zoomOut*factor, symmetrical);
                return true;
            }
            return false;
        }