/// <summary> /// Update the position and size of the rectangle that user is dragging out. /// </summary> private void SetDragZoomRect(Point pt1, Point pt2) { // // Update the coordinates of the rectangle that is being dragged out by the user. // The we offset and rescale to convert from content coordinates. // var rect = ViewportHelpers.Clip(pt1, pt2, new Point(0, 0), new Point(_partDragZoomCanvas.ActualWidth, _partDragZoomCanvas.ActualHeight)); ViewportHelpers.PositionBorderOnCanvas(_partDragZoomBorder, rect); }
/// <summary> /// Event raised on mouse move in the ZoomAndPanControl. /// </summary> protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (_mouseHandlingMode == MouseHandlingModeEnum.Panning) { var curContentPoint = e.GetPosition(_viewportCanvas); var rectangleDragVector = curContentPoint - _origContentMouseDownPoint; // // When in 'dragging rectangles' mode update the position of the rectangle as the user drags it. // _origContentMouseDownPoint = e.GetPosition(_viewportCanvas).Clamp(); Canvas.SetLeft(_dragBorder, Canvas.GetLeft(_dragBorder) + rectangleDragVector.X); Canvas.SetTop(_dragBorder, Canvas.GetTop(_dragBorder) + rectangleDragVector.Y); } else if (_mouseHandlingMode == MouseHandlingModeEnum.DragZooming) { var curContentPoint = e.GetPosition(_viewportCanvas); var rect = ViewportHelpers.Clip(curContentPoint, _origContentMouseDownPoint, new Point(0, 0), new Point(_viewportCanvas.Width, _viewportCanvas.Height)); ViewportHelpers.PositionBorderOnCanvas(_sizingBorder, rect); } e.Handled = true; }