Example #1
0
 /// <summary>
 /// Indicate that a user control has ended a click-drag
 /// </summary>
 public void MouseUp(Point upLocation)
 {
     axes             = AxesAfterMouse();
     mouse.leftDown   = new Point(0, 0);
     mouse.rightDown  = new Point(0, 0);
     mouse.middleDown = new Point(0, 0);
 }
Example #2
0
        public void Render(SKCanvas canvas, SKRect rect)
        {
            if (axes == null)
            {
                AutoAxis();
            }

            layout.Tighten(rect);
            axes.SetRect(layout.data);

            if (layout.display)
            {
                layout.RenderDebuggingGuides(canvas);
            }

            // update the scale, apply mouse adjustments, then update the scale again
            PlotSettings.Axes axesAfterMouse = new PlotSettings.Axes(axes);
            axesAfterMouse.PanPixels(mouse.leftDownDelta);
            axesAfterMouse.ZoomPixels(mouse.rightDownDelta);
            axesAfterMouse.SetRect(layout.data);

            // draw inside a clipping rectangle
            canvas.Save();
            canvas.ClipRect(layout.data);
            for (int i = 0; i < plottables.Count; i++)
            {
                plottables[i].Render(canvas, axesAfterMouse);
            }
            canvas.Restore();

            axisLabels.Render(layout, canvas);
            axisScales.Render(layout, axesAfterMouse, canvas);
        }
Example #3
0
        public void AutoAxis(double marginX = .1, double marginY = .1)
        {
            if (axes == null)
            {
                axes = new PlotSettings.Axes();
            }
            if (plottables.Count > 0)
            {
                axes.Set(plottables[0].GetDataArea());
                for (int i = 1; i < plottables.Count; i++)
                {
                    axes.Expand(plottables[i].GetDataArea());
                }
            }

            axes.Zoom(1 - marginX, 1 - marginY);
        }
Example #4
0
        /// <summary>
        /// Return a new Axes after mouse panning and zooming
        /// </summary>
        private PlotSettings.Axes AxesAfterMouse(RectangleF?renderArea = null)
        {
            if (renderArea is null)
            {
                renderArea = mouse.lastRenderArea;
            }
            else
            {
                mouse.lastRenderArea = (RectangleF)renderArea;
            }

            var axesAfterMouse = new PlotSettings.Axes(axes);

            if (mouse.leftButtonIsDown)
            {
                axesAfterMouse.PanPixels(mouse.leftDelta);
            }
            if (mouse.rightButtonIsDown)
            {
                axesAfterMouse.ZoomPixels(mouse.rightDelta);
            }
            axesAfterMouse.SetDataRect((RectangleF)renderArea);
            return(axesAfterMouse);
        }