public void PointMutatorCreationWithoutMapControlTest() { MapControl mapControl = new MapControl(); mapControl.Map.ZoomToBox(new Envelope(new Coordinate(0, 0), new Coordinate(1000, 1000))); ICoordinateConverter coordinateConverter = new CoordinateConverter(mapControl); LineStringEditor lineStringMutator = new LineStringEditor(coordinateConverter, null, sampleFeature, GetStyle()); Assert.AreEqual(null, lineStringMutator.TargetFeature); Assert.AreNotEqual(null, lineStringMutator.SourceFeature); // There are no default focused trackers IList<ITrackerFeature> trackers = lineStringMutator.GetFocusedTrackers(); Assert.AreEqual(0, trackers.Count); ITrackerFeature tracker = lineStringMutator.GetTrackerByIndex(2); Assert.AreNotEqual(null, tracker); Assert.AreEqual(20.0, tracker.Geometry.Coordinates[0].X); Assert.AreEqual(0.0, tracker.Geometry.Coordinates[0].Y); lineStringMutator.Start(); lineStringMutator.Select(tracker, true); trackers = lineStringMutator.GetFocusedTrackers(); Assert.AreEqual(1, trackers.Count); Assert.AreNotEqual(null, lineStringMutator.TargetFeature); Assert.AreNotEqual(lineStringMutator.SourceFeature, lineStringMutator.TargetFeature); }
public override ITrackerFeature GetTrackerAtCoordinate(ICoordinate worldPos) { ITrackerFeature trackerFeature = base.GetTrackerAtCoordinate(worldPos); if (null == trackerFeature) { ICoordinate org = CoordinateConverter.ImageToWorld(new PointF(0, 0)); ICoordinate range = CoordinateConverter.ImageToWorld(new PointF(6, 6)); // todo make attribute if (SourceFeature.Geometry.Distance(GeometryFactory.CreatePoint(worldPos)) < Math.Abs(range.X - org.X)) { return(AllTracker); } } return(trackerFeature); }
public void PointMutatorCreationWithMapControlTest() { IMapControl mapControl = new MapControl {Map = {Size = new Size(1000, 1000)}}; ICoordinateConverter coordinateConverter = new CoordinateConverter(mapControl); PointEditor pointMutator = new PointEditor(coordinateConverter, null, sampleFeature, GetStyle(Pens.Red)); Assert.AreEqual(null, pointMutator.TargetFeature); Assert.AreNotEqual(null, pointMutator.SourceFeature); ITrackerFeature tracker = pointMutator.GetTrackerAtCoordinate(new Coordinate(0, 0)); Assert.AreNotEqual(null, tracker); pointMutator.Start(); pointMutator.MoveTracker(tracker, 5.0, 5.0, null); pointMutator.Stop(); Assert.AreEqual(5.0, tracker.Geometry.Coordinates[0].X); Assert.AreEqual(5.0, tracker.Geometry.Coordinates[0].Y); Assert.AreEqual(5.0, sampleFeature.Geometry.Coordinates[0].X); Assert.AreEqual(5.0, sampleFeature.Geometry.Coordinates[0].Y); }
public void AllTrackerTest() { MapControl mapControl = new MapControl { Map = { Size = new Size(1000, 1000) } }; ICoordinateConverter coordinateConverter = new CoordinateConverter(mapControl); LineStringEditor lineStringMutator = new LineStringEditor(coordinateConverter, null, sampleFeature, GetStyle()); ITrackerFeature trackerFeature = lineStringMutator.GetTrackerAtCoordinate(new Coordinate(15, 0)); lineStringMutator.Start(); lineStringMutator.MoveTracker(trackerFeature, 0.0, 5.0, null); Assert.AreEqual(5.0, lineStringMutator.TargetFeature.Geometry.Coordinates[0].Y); Assert.AreEqual(5.0, lineStringMutator.TargetFeature.Geometry.Coordinates[1].Y); Assert.AreEqual(5.0, lineStringMutator.TargetFeature.Geometry.Coordinates[2].Y); Assert.AreEqual(5.0, lineStringMutator.TargetFeature.Geometry.Coordinates[3].Y); Assert.AreEqual(5.0, lineStringMutator.TargetFeature.Geometry.Coordinates[4].Y); lineStringMutator.Stop(); }
public void MultipleSelectionTestViaCoordinatesNoFallOffPolicy() { // todo write MapControl mapControl = new MapControl { Map = { Size = new Size(1000, 1000) } }; ICoordinateConverter coordinateConverter = new CoordinateConverter(mapControl); LineStringEditor lineStringMutator = new LineStringEditor(coordinateConverter, null, sampleFeature, GetStyle()); ITrackerFeature trackerFeatureAtCoordinate10 = lineStringMutator.GetTrackerAtCoordinate(new Coordinate(10, 0)); trackerFeatureAtCoordinate10.Selected = true; ITrackerFeature trackerFeatureAtCoordinate30 = lineStringMutator.GetTrackerAtCoordinate(new Coordinate(30, 0)); trackerFeatureAtCoordinate30.Selected = true; lineStringMutator.FallOffPolicy = new NoFallOffPolicy(); lineStringMutator.Start(); lineStringMutator.MoveTracker(trackerFeatureAtCoordinate30, 0, 5, null); // both tracker at 10 and 30 is moved Assert.AreEqual(5.0, trackerFeatureAtCoordinate30.Geometry.Coordinates[0].Y); Assert.AreEqual(5.0, trackerFeatureAtCoordinate10.Geometry.Coordinates[0].Y); lineStringMutator.Stop(); }
public void SelectionTestViaCoordinates() { MapControl mapControl = new MapControl {Map = {Size = new Size(1000, 1000)}}; ICoordinateConverter coordinateConverter = new CoordinateConverter(mapControl); LineStringEditor lineStringMutator = new LineStringEditor(coordinateConverter, null, sampleFeature, GetStyle()); ITrackerFeature trackerFeatureAtCoordinate = lineStringMutator.GetTrackerAtCoordinate(new Coordinate(20, 0)); ITrackerFeature trackerFeatureAtIndex = lineStringMutator.GetTrackerByIndex(2); Assert.AreEqual(trackerFeatureAtIndex, trackerFeatureAtCoordinate); trackerFeatureAtCoordinate.Selected = true; Assert.AreEqual(1, lineStringMutator.GetFocusedTrackers().Count); }