private void MouseMovedToMoveDraggable(MouseEventArgs e) { var coordinate = plt.CoordinateFromPixel(GetPixelPosition(e).X, GetPixelPosition(e).Y); plottableBeingDragged.DragTo(coordinate.X, coordinate.Y); Render(true); }
private void PbPlot_MouseWheel(object sender, MouseEventArgs e) { double zoomAmount = 0.15; PointF zoomCenter = plt.CoordinateFromPixel(e.Location); if (e.Delta > 0) { plt.AxisZoom(1 + zoomAmount, 1 + zoomAmount, zoomCenter); } else { plt.AxisZoom(1 - zoomAmount, 1 - zoomAmount, zoomCenter); } if (plt.mouseTracker.lowQualityWhileInteracting && plt.mouseTracker.mouseWheelHQRenderDelay > 0) { Render(false, true); lastInteractionTimer.Interval = plt.mouseTracker.mouseWheelHQRenderDelay; // delay in ms lastInteractionTimer.Start(); } else { Render(skipIfCurrentlyRendering: false); } }
private void MouseMovedToMoveDraggable(MouseEventArgs e) { PointF coordinate = plt.CoordinateFromPixel(e.Location); plottableBeingDragged.DragTo(coordinate.X, coordinate.Y); OnMouseDragPlottable(EventArgs.Empty); Render(true, lowQuality: lowQualityWhileDragging); }
private void UserControl_MouseUp(object sender, MouseButtonEventArgs e) { ReleaseMouseCapture(); 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(); }
private void PbPlot_MouseWheel(object sender, MouseEventArgs e) { double zoomAmount = 0.15; PointF zoomCenter = plt.CoordinateFromPixel(e.Location); if (e.Delta > 0) { plt.AxisZoom(1 + zoomAmount, 1 + zoomAmount, zoomCenter); } else { plt.AxisZoom(1 - zoomAmount, 1 - zoomAmount, zoomCenter); } Render(skipIfCurrentlyRendering: false); }
private void PbPlot_MouseMove(object sender, MouseEventArgs e) { mouseLocation = e.Location; OnMouseMoved(EventArgs.Empty); if (isMouseDragging) { plt.Axis(axisLimitsOnMouseDown); if (mouseLeftDownLocation != null) { int deltaX = ((Point)mouseLeftDownLocation).X - mouseLocation.X; int deltaY = mouseLocation.Y - ((Point)mouseLeftDownLocation).Y; settings.AxesPanPx(deltaX, deltaY); } else if (mouseRightDownLocation != null) { int deltaX = ((Point)mouseRightDownLocation).X - mouseLocation.X; int deltaY = mouseLocation.Y - ((Point)mouseRightDownLocation).Y; settings.AxesZoomPx(-deltaX, -deltaY); } else 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 origin = new Point(x1 - settings.dataOrigin.X, y1 - settings.dataOrigin.Y); Size size = new Size(x2 - x1, y2 - y1); settings.mouseMiddleRect = new Rectangle(origin, size); } Render(true, lowQuality: lowQualityWhileDragging); //OnAxisChanged(); // dont want to throw this too often return; } if (draggingAxLine != null) { var pos = plt.CoordinateFromPixel(e.Location); draggingAxLine.position = (draggingAxLine.vertical) ? pos.X : pos.Y; pbPlot.Cursor = (draggingAxLine.vertical == true) ? Cursors.SizeWE : Cursors.SizeNS; OnMouseDragPlottable(EventArgs.Empty); Render(true); return; } var axLineUnderCursor = settings.GetDraggableAxisLineUnderCursor(e.Location); if (axLineUnderCursor is null) pbPlot.Cursor = Cursors.Arrow; else pbPlot.Cursor = (axLineUnderCursor.vertical == true) ? Cursors.SizeWE : Cursors.SizeNS; }
private void UserControl_MouseMove(object sender, MouseEventArgs e) { mouseLocation = GetPixelPosition(e); if (isMouseDragging && draggingAxLine is null) { plt.Axis(axisLimitsOnMouseDown); if (mouseLeftDownLocation != null) { double deltaX = ((Point)mouseLeftDownLocation).X - mouseLocation.X; double deltaY = mouseLocation.Y - ((Point)mouseLeftDownLocation).Y; if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) { deltaY = 0; } if (Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt)) { deltaX = 0; } settings.AxesPanPx((int)deltaX, (int)deltaY); } else if (mouseRightDownLocation != null) { double deltaX = ((Point)mouseRightDownLocation).X - mouseLocation.X; double deltaY = mouseLocation.Y - ((Point)mouseRightDownLocation).Y; if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) { deltaY = 0; } if (Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt)) { deltaX = 0; } settings.AxesZoomPx(-(int)deltaX, -(int)deltaY); } else 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); var origin = new System.Drawing.Point((int)x1 - settings.dataOrigin.X, (int)y1 - settings.dataOrigin.Y); var size = new System.Drawing.Size((int)(x2 - x1), (int)(y2 - y1)); settings.mouseMiddleRect = new System.Drawing.Rectangle(origin, size); } Render(true); return; // we panned or zoomed, so exit } if (draggingAxLine != null) { // we are actively dragging an axis line var pos = plt.CoordinateFromPixel(SDPoint(GetPixelPosition(e))); draggingAxLine.position = (draggingAxLine.vertical) ? pos.X : pos.Y; imagePlot.Cursor = (draggingAxLine.vertical == true) ? Cursors.SizeWE : Cursors.SizeNS; Render(true); return; } var axLineUnderCursor = settings.GetDraggableAxisLineUnderCursor(SDPoint(GetPixelPosition(e))); if (axLineUnderCursor != null) { // an axis line is under the cursor imagePlot.Cursor = (axLineUnderCursor.vertical == true) ? Cursors.SizeWE : Cursors.SizeNS; return; } // the mouse isn't over anything imagePlot.Cursor = Cursors.Arrow; }