void mapView_ManipulationDelta(object sender, ManipulationDeltaEventArgs e) { ShowZoneView zoneView = sender as ShowZoneView; if (zoneView == null || !canMapBeTriggered) { return; } if (Math.Abs(e.CumulativeManipulation.Translation.Y) < 15) { e.Handled = true; if (e.CumulativeManipulation.Translation.X < -10) { Size size = zoneView.RenderSize; Point center = zoneView.PointToScreen(new Point(zoneView.ActualWidth / 2, zoneView.ActualHeight / 2)); canMapBeTriggered = false; e.Complete(); OnAddMapCommand(center, size); } } else { canMapBeTriggered = false; } }
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)); } } }
private void GenerateZoneControl() { ShowZoneModel zoneModel = new ShowZoneModel(); zoneModel.Text = "Zone"; Viewbox vb = new Viewbox(); vb.Width = 100; vb.Height = 100; vb.Margin = new Thickness(20.0); ShowZoneView zoneView = new ShowZoneView(zoneModel); zoneView.Background = new SolidColorBrush(Colors.Transparent); vb.Child = zoneView; zoneView.IsManipulationEnabled = true; zoneView.ManipulationDelta += zoneView_ManipulationDelta; pnlControls.Children.Add(vb); }