private void OnTouch(object sender, TouchEventArgs args) { if (Map.Lock) { return; } var mapAction = _touchHandler.Handle(args.Event); if (mapAction == MapAction.RefreshGraphics) { Map.Viewport.Transform( _touchHandler.Touch.X, _touchHandler.Touch.Y, _touchHandler.PreviousTouch.X, _touchHandler.PreviousTouch.Y, _touchHandler.Scale); Map.Viewport.Resolution = Restrict.RestrictZoom(Map.Viewport, Map.Resolutions, Map.Envelope); Restrict.RestrictPan(Map.Viewport, Map.Envelope); Invalidate(); } else if (mapAction == MapAction.RefreshData) { Map.ViewChanged(true); } }
public void TestRestrictZoom() { // arrange var restrictPanZoom = new RestrictPanZoom { PanMode = RestrictPanMode.KeepCenterWithinExtents }; var viewport = new Viewport { Center = new Point(0, 0), Width = 100, Height = 100, Resolution = 1 }; // viewport.Center is (0, 0) at this point var restrictTo = new BoundingBox(20, 40, 120, 140); // Minimal X value is 20, Minimal Y value is 40 // act restrictPanZoom.RestrictPan(viewport, restrictTo); // assert Assert.AreEqual(viewport.Center.X, 20); Assert.AreEqual(viewport.Center.Y, 40); }