void child_TouchDown(object sender, TouchEventArgs e) { ZoomCanvasItem selectedChild = GetZoomCanvasItem(sender); if (selectedChild == null) { return; } ShowView view = selectedChild.View; if (view == null) { return; } if (firstTapItem == null) { firstTapItem = selectedChild; doubleTapTimer.Start(); doubleTapSequence = DoubleTapSequence.FirstTouchDown; } else if (firstTapItem == selectedChild && doubleTapSequence == DoubleTapSequence.FirstTouchUp) { OnObjectDoubleTap(selectedChild.View); doubleTapSequence = DoubleTapSequence.SecondTouchDown; } OnObjectSelected(view); //TODO: double tap gesture, boundstomatrix, zoom in currentview }
protected override void PrepareContainerForItemOverride(DependencyObject element, object item) { base.PrepareContainerForItemOverride(element, item); this.InvalidateArrange(); ZoomCanvasItem container = element as ZoomCanvasItem; container.RenderTransformOrigin = new Point(0.5, 0.5); container.IsManipulationEnabled = true; container.TouchDown += child_TouchDown; container.TouchUp += container_TouchUp; container.ManipulationDelta += child_ManipulationDelta; container.ManipulationStarting += child_ManipulationStarting; container.ManipulationInertiaStarting += child_ManipulationInertiaStarting; container.ManipulationCompleted += container_ManipulationCompleted; container.ViewChanged += DisplayData_ViewChanged; ShowView view = item as ShowView; if (view != null) { view.Model.DisplayMatrix.ViewChanged += container.DisplayMatrix_ViewChanged; } isPositionUpdateNecessary = true; dirtyItems.Add(container); }
void doubleTapTimer_Tick(object sender, EventArgs e) { firstTapItem = null; doubleTapTimer.Stop(); doubleTapSequence = DoubleTapSequence.None; }
void container_TouchUp(object sender, TouchEventArgs e) { ZoomCanvasItem selectedChild = GetZoomCanvasItem(sender); if (selectedChild == null) { return; } ShowView view = selectedChild.View; if (view == null) { return; } if (firstTapItem == selectedChild && doubleTapSequence == DoubleTapSequence.FirstTouchDown) { doubleTapSequence = DoubleTapSequence.FirstTouchUp; } else { doubleTapSequence = DoubleTapSequence.None; } }
public ZoomCanvasItem GetZoomCanvasItem(object o) { ZoomCanvasItem child = o as ZoomCanvasItem; if (child == null) { child = ItemContainerGenerator.ContainerFromItem(o) as ZoomCanvasItem; } return(child); }
private void SetItemDirty(object sender) { ZoomCanvasItem item = sender as ZoomCanvasItem; if (item == null) { GetZoomCanvasItem(sender); } if (item != null && !this.dirtyItems.Contains(item)) { this.dirtyItems.Add(item); } }
public static bool GetItemIsDirty(object item) { if (item == null) { return(false); } DependencyObject depObj = item as DependencyObject; if (depObj == null) { return(false); } return(ZoomCanvasItem.GetIsDirty(depObj)); }
public static double GetItemOrientation(object item) { if (item == null) { return(0.0); } DependencyObject depObj = item as DependencyObject; if (depObj == null) { return(0.0); } return(ZoomCanvasItem.GetOrientation(depObj)); }
public static Point GetItemCenter(object item) { if (item == null) { return(new Point(double.NaN, double.NaN)); } DependencyObject depObj = item as DependencyObject; if (depObj == null) { return(new Point(double.NaN, double.NaN)); } return(ZoomCanvasItem.GetCenter(depObj)); }
public static Vector GetItemScale(object item) { if (item == null) { return(new Vector(1.0, 1.0)); } DependencyObject depObj = item as DependencyObject; if (depObj == null) { return(new Vector(1.0, 1.0)); } return(ZoomCanvasItem.GetScale(depObj)); }
private bool GetIsLocked(ZoomCanvasItem item) { if (item == null) { return(false); } ShowView view = item.View; if (view == null) { return(false); } return(view.IsLocked); }
void container_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e) { ZoomCanvasItem child = GetZoomCanvasItem(sender); if (child == null) { return; } ShowView zoneView = child.View; if (zoneView == null) { return; } zoneView.ManipulationGroup.Clear(); }
private void PositionChild(ZoomCanvasItem item) { if (item == null) { return; } if (!item.IsDirty) { return; } item.IsDirty = false; Canvas.SetZIndex(item, item.ZIndex); double orientation = item.Orientation; Vector scale = item.Scale; Point center = item.Center; double width = item.ActualWidth; double height = item.ActualHeight; if (double.IsNaN(center.X)) { center.X = item.Center.X; if (double.IsNaN(center.X)) { center.X = this.ActualWidth / 2; } } if (double.IsNaN(center.Y)) { center.Y = item.Center.Y; if (double.IsNaN(center.Y)) { center.Y = this.ActualHeight * 0.75; } } UpdateScatterMatrix(item, item.RenderSize, center, orientation, scale); }
public static bool GetItemCanRotate(object item) { bool canRotate = true; if (item == null) { return(canRotate); } DependencyObject depObj = item as DependencyObject; if (depObj == null) { return(canRotate); } canRotate = ZoomCanvasItem.GetCanRotate(depObj); return(canRotate); }
void child_ManipulationDelta(object sender, ManipulationDeltaEventArgs e) { ZoomCanvasItem child = GetZoomCanvasItem(sender); if (child == null) { return; } ShowView view = child.View; if (view == null || GetIsLocked(child)) { //Since the element is locked, forward the touches to the layoutroot for moving whole background child.TouchesCaptured.ToList().ForEach(t => layoutRoot.CaptureTouch(t)); e.Complete(); return; } UpdatePosition(view, e.DeltaManipulation, e.ManipulationOrigin, child.TouchesCaptured.Count()); PositionChild(child); if (dirtyItems.Contains(child)) { dirtyItems.Remove(child); } foreach (ZoomCanvasItem item in view.ManipulationGroup) { PositionChild(item); if (dirtyItems.Contains(item)) { dirtyItems.Remove(item); } } //We took care of the event e.Handled = true; }
void SelectMoveGroup(object sender) { ZoomCanvasItem child = GetZoomCanvasItem(sender); if (child == null) { return; } ShowZoneView zoneView = child.View as ShowZoneView; if (zoneView == null) { return; } zoneView.ManipulationGroup.Clear(); Rect bounds = zoneView.Bounds; //Special behavior: three fingers will move just the zone if (child.TouchesCaptured.Count() >= 3) { return; } foreach (ShowView view in this.Items) { if (view.Equals(zoneView)) { continue; } Rect itemBounds = view.Bounds; if (bounds.Contains(itemBounds)) { zoneView.ManipulationGroup.Add(GetZoomCanvasItem(view)); } } }
void LayoutRootCanvas_ManipulationDelta(object sender, ManipulationDeltaEventArgs e) { if (zoomElement == null || layoutRoot == null) { return; } if (this.doubleTapSequence == DoubleTapSequence.SecondTouchDown) { return; } if (this.CurrentView.HasAnimatedProperties) { AnimateUtility.StopAnimation(this.CurrentView, DisplayMatrix.CenterProperty); AnimateUtility.StopAnimation(this.CurrentView, DisplayMatrix.OrientationProperty); AnimateUtility.StopAnimation(this.CurrentView, DisplayMatrix.ScaleProperty); } //Get the deltas into World frame-of-reference Vector deltaTranslation = e.DeltaManipulation.Translation; double deltaRotation = e.DeltaManipulation.Rotation; Vector deltaScale = e.DeltaManipulation.Scale; Point manipulationOrigin = e.ManipulationOrigin; UpdateZoomView(deltaTranslation, deltaRotation, deltaScale, manipulationOrigin); //We took care of the event e.Handled = true; foreach (object item in this.Items) { ZoomCanvasItem child = GetZoomCanvasItem(item); if (child != null && !GetIsLocked(child) && child.AreAnyTouchesCaptured) { ShowView view = child.View; Vector scale = deltaScale; if (scale.X != 0) { scale.X = 1 / scale.X; } if (scale.Y != 0) { scale.Y = 1 / scale.Y; } ManipulationDelta deltaManipulation = new ManipulationDelta(-1 * deltaTranslation, -1 * deltaRotation, scale, new Vector()); UpdatePosition(view, deltaManipulation, manipulationOrigin, 1); PositionChild(child); if (dirtyItems.Contains(child)) { dirtyItems.Remove(child); } } } OnViewChanged(); }