private void SetCreateMoveScrollArgsAndTriggerEvent(double newViewWidth, double newViewHeight, double newMiddleOfViewX, double newMiddleOfViewY) { CurrentViewDimensions = new ViewDimensions(newViewWidth, newViewHeight, newMiddleOfViewX, newMiddleOfViewY); MoveScrollArgs args = GetMoveScrollArgs(CurrentViewDimensions); if (!AreViewDimensionsPossible(CurrentViewDimensions)) { return; } MoveScrollView(this, args); canvas.Invalidate(); }
private void Canvas_PointerPressed(object sender, PointerRoutedEventArgs e) { pointerPoints.Add(e.GetCurrentPoint(canvas)); var isBool = canvas.CapturePointer(e.Pointer); var list = canvas.PointerCaptures.ToArray(); startAverageDistanceWidthPossible = startAverageDistanceHeightPossible = true; GetAverageDistanceBetweenPointers(out startAverageDistanceWidth, out startAverageDistanceHeight); GetAverageMiddlePointOfPointers(out startAveragePointX, out startAveragePointY); preMoveTicks = DateTime.Now.Ticks; startViewDimensions = CurrentViewDimensions.Clone(); }
public void SetEvents(CanvasControl canvas, UIElement grid, float viewValueWidth, float viewValueHeight, float middleOfViewX, float middleOfViewY) { this.canvas = canvas; CurrentViewDimensions = new ViewDimensions(viewValueWidth, viewValueHeight, middleOfViewX, middleOfViewY); grid.PointerPressed += Canvas_PointerPressed; grid.PointerMoved += Canvas_PointerMoved; grid.PointerReleased += Canvas_PointerReleased; grid.PointerWheelChanged += Canvas_PointerWheelChanged; canvas.SizeChanged += Canvas_SizeChanged; }
private void Canvas_PointerReleased(object sender, PointerRoutedEventArgs e) { int index = pointerPoints.FindIndex(x => x.PointerId == e.Pointer.PointerId); if (index != -1) { pointerPoints.RemoveAt(index); canvas.ReleasePointerCapture(e.Pointer); startAverageDistanceWidthPossible = startAverageDistanceHeightPossible = true; GetAverageDistanceBetweenPointers(out startAverageDistanceWidth, out startAverageDistanceHeight); GetAverageMiddlePointOfPointers(out startAveragePointX, out startAveragePointY); startViewDimensions = CurrentViewDimensions.Clone(); } }
private bool AreViewDimensionsPossible(ViewDimensions viewDimensions) { if (float.IsInfinity(viewDimensions.BottomRightValuePoint.X)) { return(false); } if (float.IsInfinity(viewDimensions.BottomRightValuePoint.Y)) { return(false); } if (float.IsInfinity(viewDimensions.MiddleOfViewValuePoint.X)) { return(false); } if (float.IsInfinity(viewDimensions.MiddleOfViewValuePoint.Y)) { return(false); } if (float.IsInfinity(viewDimensions.TopLeftValuePoint.X)) { return(false); } if (float.IsInfinity(viewDimensions.TopLeftValuePoint.Y)) { return(false); } if (float.IsInfinity(viewDimensions.ViewValueSize.X)) { return(false); } if (float.IsInfinity(viewDimensions.ViewValueSize.Y)) { return(false); } if (float.IsNaN(viewDimensions.BottomRightValuePoint.X)) { return(false); } if (float.IsNaN(viewDimensions.BottomRightValuePoint.Y)) { return(false); } if (float.IsNaN(viewDimensions.MiddleOfViewValuePoint.X)) { return(false); } if (float.IsNaN(viewDimensions.MiddleOfViewValuePoint.Y)) { return(false); } if (float.IsNaN(viewDimensions.TopLeftValuePoint.X)) { return(false); } if (float.IsNaN(viewDimensions.TopLeftValuePoint.Y)) { return(false); } if (float.IsNaN(viewDimensions.ViewValueSize.X)) { return(false); } if (float.IsNaN(viewDimensions.ViewValueSize.Y)) { return(false); } return(true); }
private MoveScrollArgs GetMoveScrollArgs(ViewDimensions newViewDimensions) { return(new MoveScrollArgs(newViewDimensions.Clone())); }