Exemplo n.º 1
0
        public override void OnMouseMove(ICoordinate worldPosition, MouseEventArgs e)
        {
            if (IsMultiSelect)
            {
                //WORLDPOSITION = worldPosition;
                UpdateMultiSelection(worldPosition);
                DoDrawing(false);
                return;
            }

            Cursor cursor = null;

            for (int i = 0; i < FeatureEditors.Count; i++)
            {
                ITrackerFeature trackerFeature = FeatureEditors[i].GetTrackerAtCoordinate(worldPosition);
                if (null != trackerFeature)
                {
                    cursor = FeatureEditors[i].GetCursor(trackerFeature);
                }
            }
            if (null == cursor)
            {
                cursor = Cursors.Default;
            }

            MapControl.Cursor = cursor;
        }
Exemplo n.º 2
0
 public override void Select(ITrackerFeature trackerFeature, bool select)
 {
     if (trackerFeature.Selected != select)
     {
         trackerFeature.Selected = select;
         if (null != VectorStyle)
         {
             if (select)
             {
                 trackerFeature.Bitmap = TrackerSymbolHelper.GenerateComposite(new Pen(Color.Blue),
                                                                               new SolidBrush(Color.DarkBlue),
                                                                               VectorStyle.Symbol.Width,
                                                                               VectorStyle.Symbol.Height,
                                                                               6,
                                                                               6);
             }
             else
             {
                 trackerFeature.Bitmap = TrackerSymbolHelper.GenerateComposite(new Pen(Color.Lime),
                                                                               new SolidBrush(Color.Green),
                                                                               VectorStyle.Symbol.Width,
                                                                               VectorStyle.Symbol.Height,
                                                                               6,
                                                                               6);
             }
         }
     }
 }
Exemplo n.º 3
0
 public override void Select(ITrackerFeature trackerFeature, bool select)
 {
     if (trackerFeature.Selected != select)
     {
         trackerFeature.Selected = select;
         if (null != VectorStyle)
         {
             if (select)
             {
                 trackerFeature.Bitmap = TrackerSymbolHelper.GenerateComposite(new Pen(Color.Blue),
                                                                               new SolidBrush(Color.DarkBlue),
                                                                               VectorStyle.Symbol.Width,
                                                                               VectorStyle.Symbol.Height,
                                                                               6,
                                                                               6);
             }
             else
             {
                 trackerFeature.Bitmap = TrackerSymbolHelper.GenerateComposite(new Pen(Color.Lime),
                                                                               new SolidBrush(Color.Green),
                                                                               VectorStyle.Symbol.Width,
                                                                               VectorStyle.Symbol.Height,
                                                                               6,
                                                                               6);
             }
         }
     }
 }
Exemplo n.º 4
0
        public virtual ITrackerFeature GetTrackerAtCoordinate(ICoordinate worldPos)
        {
            for (int i = 0; i < trackers.Count; i++)
            {
                ITrackerFeature trackerFeature = trackers[i];

                ICoordinate size;

                if (null != trackerFeature.Bitmap)
                {
                    size = CoordinateConverter.ImageToWorld(trackerFeature.Bitmap.Width, trackerFeature.Bitmap.Height);
                }
                else
                {
                    // hack for RegularGridCoverageLayer
                    size = CoordinateConverter.ImageToWorld(6, 6);
                }
                IEnvelope boundingBox = MapControlHelper.GetEnvelope(worldPos, size.X, size.Y);

                if (trackerFeature.Geometry.EnvelopeInternal.Intersects(boundingBox))
                {
                    return(trackerFeature);
                }
            }
            return(null);
        }
Exemplo n.º 5
0
        private void FocusTracker(ITrackerFeature trackFeature)
        {
            if (null == trackFeature)
            {
                return;
            }

            if (!((KeyToggleSelection) || (KeyExtendSelection)))
            {
                for (int i = 0; i < FeatureEditors.Count; i++)
                {
                    foreach (ITrackerFeature tf in FeatureEditors[i].GetTrackers())
                    {
                        FeatureEditors[i].Select(tf, false);
                    }
                }
            }
            for (int i = 0; i < FeatureEditors.Count; i++)
            {
                foreach (TrackerFeature tf in FeatureEditors[i].GetTrackers())
                {
                    if (tf == trackFeature)
                    {
                        if (KeyToggleSelection)
                        {
                            FeatureEditors[i].Select(trackFeature, !trackFeature.Selected);
                        }
                        else
                        {
                            FeatureEditors[i].Select(trackFeature, true);
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
        public void PointMutatorCreationWithoutMapControlTest()
        {
            MapControl mapControl = new MapControl();

            mapControl.Map.ZoomToFit(new Envelope(new Coordinate(0, 0), new Coordinate(1000, 1000)));
            ICoordinateConverter coordinateConverter = new CoordinateConverter(mapControl);
            LineStringEditor     lineStringMutator   = new LineStringEditor(coordinateConverter, null, sampleFeature, GetStyle(), null);

            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);
        }
Exemplo n.º 7
0
        protected override void CreateTrackers()
        {
            if (trackerSmallStart == null)
            {
                trackerSmallStart = TrackerSymbolHelper.GenerateSimple(new Pen(Color.Blue), new SolidBrush(Color.DarkBlue), 6, 6);
                trackerSmallEnd = TrackerSymbolHelper.GenerateSimple(new Pen(Color.Tomato), new SolidBrush(Color.Maroon), 6, 6);
                trackerSmall = TrackerSymbolHelper.GenerateSimple(new Pen(Color.Green), new SolidBrush(Color.Lime), 6, 6);
                selectedTrackerSmall = TrackerSymbolHelper.GenerateSimple(new Pen(Color.DarkMagenta), new SolidBrush(Color.Magenta), 6, 6);
            }
            trackers.Clear();
            // optimization: SourceFeature.Geometry.Coordinates is an expensive operation
            if(SourceFeature.Geometry == null)
            {
                return;
            }

            ICoordinate[] coordinates = SourceFeature.Geometry.Coordinates;
            for (int i = 0; i < coordinates.Length; i++)
            {
                ICoordinate coordinate = coordinates[i];
                IPoint selectPoint = GeometryFactory.CreatePoint(coordinate.X, coordinate.Y);
                if (0 == i)
                    trackers.Add(new TrackerFeature(this, selectPoint, i, trackerSmallStart));
                else if ((coordinates.Length - 1) == i)
                    trackers.Add(new TrackerFeature(this, selectPoint, i, trackerSmallEnd));
                else
                    trackers.Add(new TrackerFeature(this, selectPoint, i, trackerSmall));
            }
            AllTracker = new TrackerFeature(this, null, -1, null);
        }
Exemplo n.º 8
0
        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), null);

            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);
        }
Exemplo n.º 9
0
        public void MoveTrackerWithoutSelection()
        {
            LineStringEditor lineStringMutator = new LineStringEditor(null, null, sampleFeature, GetStyle(), null);
            ITrackerFeature  tracker           = lineStringMutator.GetTrackerByIndex(2); // 20,0

            lineStringMutator.Start();
            lineStringMutator.MoveTracker(tracker, 0, 5, null);
        }
Exemplo n.º 10
0
        public void SelectionTest()
        {
            PointEditor     pointMutator = new PointEditor(null, null, sampleFeature, GetStyle(Pens.Red), null);
            ITrackerFeature tracker      = pointMutator.GetTrackerByIndex(0);

            // The tracker has focus by default; is this ok
            Assert.AreEqual(true, tracker.Selected);
            pointMutator.Select(tracker, false);
            Assert.AreEqual(false, tracker.Selected);
        }
Exemplo n.º 11
0
 public override Cursor GetCursor(ITrackerFeature trackerFeature)
 {
     // ReSharper disable AssignNullToNotNullAttribute
     if (trackerFeature == AllTracker)
     {
         return(Cursors.SizeAll);
     }
     return(new Cursor(Assembly.GetExecutingAssembly().GetManifestResourceStream("SharpMap.UI.Cursors.moveTracker.cur")));
     // ReSharper restore AssignNullToNotNullAttribute
 }
Exemplo n.º 12
0
 public override Cursor GetCursor(ITrackerFeature trackerFeature)
 {
     if (trackers[0] == trackerFeature)
     {
         // ReSharper disable AssignNullToNotNullAttribute
         return new Cursor(Assembly.GetExecutingAssembly().GetManifestResourceStream("SharpMap.UI.Cursors.moveTracker.cur"));
         // ReSharper restore AssignNullToNotNullAttribute
     }
     return null;
 }
Exemplo n.º 13
0
        protected override void CreateTrackers()
        {
            if (trackerSmallStart == null)
            {
                trackerSmallStart = TrackerSymbolHelper.GenerateSimple(new Pen(Color.Blue), new SolidBrush(Color.DarkBlue), 6, 6);
                trackerSmallEnd   = TrackerSymbolHelper.GenerateSimple(new Pen(Color.Tomato), new SolidBrush(Color.Maroon), 6, 6);
                //NS, 2013-10-11, Warna track symbol dari Green ke Red
                trackerSmall         = TrackerSymbolHelper.GenerateSimple(new Pen(Color.Red), new SolidBrush(Color.OrangeRed), 6, 6);//TrackerSymbolHelper.GenerateSimple(new Pen(Color.Green), new SolidBrush(Color.Lime), 6, 6);
                selectedTrackerSmall = TrackerSymbolHelper.GenerateSimple(new Pen(Color.DarkMagenta), new SolidBrush(Color.Magenta), 6, 6);
            }
            trackers.Clear();
            // optimization: SourceFeature.Geometry.Coordinates is an expensive operation
            if (SourceFeature.Geometry == null)
            {
                return;
            }

            ICoordinate[] coordinates = SourceFeature.Geometry.Coordinates;
            //NS, 2014-05-06
            //Untuk point akhir dari polygon tidak dibuatkan tracker
            int coordCount = 0;

            if (SourceFeature.Geometry.GeometryType == "Polygon")
            {
                coordCount = coordinates.Length - 1;
            }
            else
            {
                coordCount = coordinates.Length;
            }

            //for (int i = 0; i < coordinates.Length; i++)
            for (int i = 0; i < coordCount; i++)
            {
                ICoordinate coordinate  = coordinates[i];
                IPoint      selectPoint = GeometryFactory.CreatePoint(coordinate.X, coordinate.Y);
                if (0 == i)
                {
                    trackers.Add(new TrackerFeature(this, selectPoint, i, trackerSmallStart));
                }
                else if ((coordinates.Length - 1) == i)
                {
                    trackers.Add(new TrackerFeature(this, selectPoint, i, trackerSmallEnd));
                }
                else
                {
                    trackers.Add(new TrackerFeature(this, selectPoint, i, trackerSmall));
                }
            }
            AllTracker = new TrackerFeature(this, null, -1, null);
        }
Exemplo n.º 14
0
        public ITrackerFeature GetTrackerAtCoordinate(ICoordinate worldPos)
        {
            ITrackerFeature trackerFeature = null;

            for (int i = 0; i < FeatureEditors.Count; i++)
            {
                trackerFeature = FeatureEditors[i].GetTrackerAtCoordinate(worldPos);
                if (null != trackerFeature)
                {
                    break;
                }
            }
            return(trackerFeature);
        }
Exemplo n.º 15
0
        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(), null);
            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);
        }
Exemplo n.º 16
0
        public override void OnMouseDown(ICoordinate worldPosition, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            isBusy = true;

            SelectTool selectTool = MapControl.SelectTool;

            if (selectTool.FeatureEditors.Count == 1)
            {
                if ((selectTool.FeatureEditors[0].SourceFeature.Geometry is ILineString) ||
                    (selectTool.FeatureEditors[0].SourceFeature.Geometry is IPolygon))
                {
                    ITrackerFeature trackerFeature = MapControl.SelectTool.GetTrackerAtCoordinate(worldPosition);
                    // hack knowledge of -1 for trackerfeature should not be here
                    // if user click visible tracker it will be handled as move, otherwize a trackers will be added.
                    if ((null != trackerFeature) && (-1 != trackerFeature.Index))
                    {
                        MapControl.MoveTool.OnMouseDown(worldPosition, e);
                        isMoving = true;
                        return;
                    }
                    if (null != SnapResult)
                    {
                        // todo ?move to FeatureEditor and add support for polygon
                        IFeatureEditor featureEditor = selectTool.FeatureEditors[0];

                        if (featureEditor.SourceFeature.Geometry is ILineString)
                        {
                            featureEditor.EditableObject.BeginEdit(string.Format("Insert curvepoint into feature {0}",
                                                                                 featureEditor.SourceFeature is INameable
                                         ? ((INameable)featureEditor.SourceFeature).Name
                                         : ""));
                            //featureEditor.Stop(SnapResult);
                            InsertCurvePoint(featureEditor.SourceFeature);
                            featureEditor.EditableObject.EndEdit();
                        }
                        featureEditor.Layer.RenderRequired = true;
                        MapControl.Refresh();
                        return;
                    }
                }
            }
            // if no curvepoint added handle as normal selection
            selectTool.OnMouseDown(worldPosition, e);
        }
Exemplo n.º 17
0
        public virtual bool MoveTracker(ITrackerFeature trackerFeature, double deltaX, double deltaY, ISnapResult snapResult)
        {
            int               index      = -1;
            IList <int>       handles    = new List <int>();
            IList <IGeometry> geometries = new List <IGeometry>();

            for (int i = 0; i < trackers.Count; i++)
            {
                geometries.Add(trackers[i].Geometry);
                if (trackers[i].Selected)
                {
                    handles.Add(i);
                }
                if (trackers[i] == trackerFeature)
                {
                    index = i;
                }
            }

            if (-1 == index)
            {
                throw new ArgumentException("Can not find tracker; can not move.");
            }
            //return false;
            if (0 == handles.Count)
            {
                throw new ArgumentException("No trackers selected, can not move.");
            }
            //return false;
            if (null != FallOffPolicy)
            {
                FallOffPolicy.Move(TargetFeature.Geometry, geometries, handles, index, deltaX, deltaY);
            }
            else
            {
                GeometryHelper.MoveCoordinate(TargetFeature.Geometry, index, deltaX, deltaY);
                TargetFeature.Geometry.GeometryChangedAction();

                GeometryHelper.MoveCoordinate(trackerFeature.Geometry, 0, deltaX, deltaY);
                trackerFeature.Geometry.GeometryChangedAction();
            }

            foreach (IFeatureRelationEditor topologyRule in TopologyRules)
            {
                topologyRule.UpdateRelatedFeatures(SourceFeature, TargetFeature.Geometry, handles);
            }

            return(true);
        }
Exemplo n.º 18
0
        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);
        }
Exemplo n.º 19
0
        public void MoveTestWithLinearFalOffPolicy()
        {
            LineStringEditor lineStringMutator = new LineStringEditor(null, null, sampleFeature, GetStyle(), null);

            lineStringMutator.FallOffPolicy = new LinearFallOffPolicy();
            ITrackerFeature tracker = lineStringMutator.GetTrackerByIndex(2); // 20,0

            tracker.Selected = true;
            lineStringMutator.Start();
            lineStringMutator.MoveTracker(tracker, 0, 5, null);
            // todo redesign .Stop
            //lineStringMutator.Stop();
            //Assert.AreEqual(20, sampleFeature.Geometry.Coordinates[2].X);
            //Assert.AreEqual(5, sampleFeature.Geometry.Coordinates[2].Y);
        }
Exemplo n.º 20
0
        public virtual bool MoveTracker(ITrackerFeature trackerFeature, double deltaX, double deltaY, ISnapResult snapResult)
        {
            int index = -1;
            IList<int> handles = new List<int>();
            IList<IGeometry> geometries = new List<IGeometry>();

            for (int i = 0; i < trackers.Count; i++)
            {
                geometries.Add(trackers[i].Geometry);
                if (trackers[i].Selected)
                {
                    handles.Add(i);
                }
                if (trackers[i] == trackerFeature)
                {
                    index = i;
                }
            }

            if (-1 == index)
                throw new ArgumentException("Can not find tracker; can not move.");
            //return false;
            if (0 == handles.Count)
                throw new ArgumentException("No trackers selected, can not move.");
            //return false;
            if (null != FallOffPolicy)
            {
                FallOffPolicy.Move(TargetFeature.Geometry, geometries, handles, index, deltaX, deltaY);
            }
            else
            {
                GeometryHelper.MoveCoordinate(TargetFeature.Geometry, index, deltaX, deltaY);
                TargetFeature.Geometry.GeometryChangedAction();

                GeometryHelper.MoveCoordinate(trackerFeature.Geometry, 0, deltaX, deltaY);
                trackerFeature.Geometry.GeometryChangedAction();
            }

            foreach (IFeatureRelationEditor topologyRule in TopologyRules)
            {
                topologyRule.UpdateRelatedFeatures(SourceFeature, TargetFeature.Geometry, handles);
            }

            return true;
        }
Exemplo n.º 21
0
        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(), null);
            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();
        }
Exemplo n.º 22
0
        public void MoveTrackerWithSelection()
        {
            LineStringEditor lineStringMutator = new LineStringEditor(null, null, sampleFeature, GetStyle(), null);
            ITrackerFeature  tracker           = lineStringMutator.GetTrackerByIndex(2); // 20,0

            tracker.Selected = true;
            lineStringMutator.Start();
            lineStringMutator.MoveTracker(tracker, 0, 5, null);
            Assert.AreEqual(20, tracker.Geometry.Coordinates[0].X);
            Assert.AreEqual(5, tracker.Geometry.Coordinates[0].Y);
            // check if changed coordinate is NOT set to sampleFeature
            Assert.AreEqual(20, sampleFeature.Geometry.Coordinates[2].X);
            Assert.AreEqual(0, sampleFeature.Geometry.Coordinates[2].Y);
            // todo redesign .Stop
            //lineStringMutator.Stop();
            //// check if changed coordinate IS set to sampleFeature
            //Assert.AreEqual(20, sampleFeature.Geometry.Coordinates[2].X);
            //Assert.AreEqual(5, sampleFeature.Geometry.Coordinates[2].Y);
        }
Exemplo n.º 23
0
        public void PointMutatorCreationWithoutMapControlTest()
        {
            PointEditor pointMutator = new PointEditor(null, null, sampleFeature, GetStyle(Pens.Red), null);

            Assert.AreEqual(null, pointMutator.TargetFeature);
            Assert.AreNotEqual(null, pointMutator.SourceFeature);
            // The tracker has focus by default; is this ok
            IList <ITrackerFeature> trackers = pointMutator.GetFocusedTrackers();

            Assert.AreEqual(1, trackers.Count);

            ITrackerFeature tracker = pointMutator.GetTrackerByIndex(0);

            Assert.AreNotEqual(null, tracker);

            pointMutator.Start();
            Assert.AreNotEqual(null, pointMutator.TargetFeature);
            Assert.AreNotEqual(pointMutator.SourceFeature, pointMutator.TargetFeature);
        }
Exemplo n.º 24
0
        public override bool MoveTracker(ITrackerFeature trackerFeature, double deltaX, double deltaY, ISnapResult snapResult)
        {
            if (trackerFeature == AllTracker)
            {
                int               index      = -1;
                IList <int>       handles    = new List <int>();
                IList <IGeometry> geometries = new List <IGeometry>();

                for (int i = 0; i < trackers.Count; i++)
                {
                    geometries.Add(trackers[i].Geometry);
                    //if (trackers[i].Selected)
                    {
                        handles.Add(i);
                    }
                    if (trackers[i] == trackerFeature)
                    {
                        index = i;
                    }
                }
                if (0 == handles.Count)
                {
                    return(false);
                }
                if (null == FallOffPolicy)
                {
                    FallOffPolicy = new NoFallOffPolicy();
                }
                FallOffPolicy.Move(TargetFeature.Geometry, geometries, handles, index, deltaX, deltaY);
                foreach (IFeatureRelationEditor topologyRule in TopologyRules)
                {
                    topologyRule.UpdateRelatedFeatures(SourceFeature, TargetFeature.Geometry, new List <int> {
                        0
                    });
                }

                return(true);
            }
            return(base.MoveTracker(trackerFeature, deltaX, deltaY, snapResult));
        }
Exemplo n.º 25
0
        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(), null);
            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();
        }
Exemplo n.º 26
0
        protected override void CreateTrackers()
        {
            if (trackerSmallStart == null)
            {
                trackerSmallStart    = TrackerSymbolHelper.GenerateSimple(new Pen(Color.Blue), new SolidBrush(Color.DarkBlue), 6, 6);
                trackerSmallEnd      = TrackerSymbolHelper.GenerateSimple(new Pen(Color.Tomato), new SolidBrush(Color.Maroon), 6, 6);
                trackerSmall         = TrackerSymbolHelper.GenerateSimple(new Pen(Color.Green), new SolidBrush(Color.Lime), 6, 6);
                selectedTrackerSmall = TrackerSymbolHelper.GenerateSimple(new Pen(Color.DarkMagenta), new SolidBrush(Color.Magenta), 6, 6);
            }
            trackers.Clear();
            // optimization: SourceFeature.Geometry.Coordinates is an expensive operation
            if (SourceFeature.Geometry == null)
            {
                return;
            }

            ICoordinate[] coordinates = SourceFeature.Geometry.Coordinates;
            for (int i = 0; i < coordinates.Length; i++)
            {
                ICoordinate coordinate  = coordinates[i];
                IPoint      selectPoint = GeometryFactory.CreatePoint(coordinate.X, coordinate.Y);
                if (0 == i)
                {
                    trackers.Add(new TrackerFeature(this, selectPoint, i, trackerSmallStart));
                }
                else if ((coordinates.Length - 1) == i)
                {
                    trackers.Add(new TrackerFeature(this, selectPoint, i, trackerSmallEnd));
                }
                else
                {
                    trackers.Add(new TrackerFeature(this, selectPoint, i, trackerSmall));
                }
            }
            AllTracker = new TrackerFeature(this, null, -1, null);
        }
Exemplo n.º 27
0
        public override void OnMouseDown(ICoordinate worldPosition, MouseEventArgs e)
        {
            isBusy = true;

            SelectTool selectTool = MapControl.SelectTool;

            if (selectTool.FeatureEditors.Count == 1)
            {
                if ((selectTool.FeatureEditors[0].SourceFeature.Geometry is ILineString) ||
                    (selectTool.FeatureEditors[0].SourceFeature.Geometry is IPolygon))
                {
                    ITrackerFeature trackerFeature = MapControl.SelectTool.GetTrackerAtCoordinate(worldPosition);
                    // hack knowledge of -1 for trackerfeature should not be here
                    // if user click visible tracker it will be handled as move, otherwize a trackers will be added.
                    if ((null != trackerFeature) && (-1 != trackerFeature.Index))
                    {
                        MapControl.MoveTool.OnMouseDown(worldPosition, e);
                        isMoving = true;
                        return;
                    }
                    if (null != SnapResult)
                    {
                        // todo ?move to FeatureMutator and add support for polygon
                        if (selectTool.FeatureEditors[0].SourceFeature.Geometry is ILineString)
                        {
                            InsertCurvePoint(selectTool.FeatureEditors[0].SourceFeature);
                        }
                        selectTool.FeatureEditors[0].Layer.RenderRequired = true;
                        MapControl.Refresh();
                        return;
                    }
                }
            }
            // if no curvepoint added handle as normal selection
            selectTool.OnMouseDown(worldPosition, e);
        }
Exemplo n.º 28
0
        public override bool MoveTracker(ITrackerFeature trackerFeature, double deltaX, double deltaY, ISnapResult snapResult)
        {
            if (trackerFeature == AllTracker)
            {
                int index = -1;
                IList<int> handles = new List<int>();
                IList<IGeometry> geometries = new List<IGeometry>();

                for (int i = 0; i < trackers.Count; i++)
                {
                    geometries.Add(trackers[i].Geometry);
                    //if (trackers[i].Selected)
                    {
                        handles.Add(i);
                    }
                    if (trackers[i] == trackerFeature)
                    {
                        index = i;
                    }
                }
                if (0 == handles.Count)
                    return false;
                if (null == FallOffPolicy)
                {
                    FallOffPolicy = new NoFallOffPolicy();
                }
                FallOffPolicy.Move(TargetFeature.Geometry, geometries, handles, index, deltaX, deltaY);
                foreach (IFeatureRelationEditor topologyRule in TopologyRules)
                {
                    topologyRule.UpdateRelatedFeatures(SourceFeature, TargetFeature.Geometry, new List<int> { 0 });
                }

                return true;
            }
            return base.MoveTracker(trackerFeature, deltaX, deltaY, snapResult);
        }
Exemplo n.º 29
0
        private void FocusTracker(ITrackerFeature trackFeature)
        {
            if (null == trackFeature)
                return;

            if (!((KeyToggleSelection) || (KeyExtendSelection)))
            {
                for (int i=0; i<FeatureEditors.Count; i++)
                {
                    foreach (ITrackerFeature tf in FeatureEditors[i].GetTrackers())
                    {
                        FeatureEditors[i].Select(tf, false);
                    }
                }
            }
            for (int i = 0; i < FeatureEditors.Count; i++)
            {
                foreach (TrackerFeature tf in FeatureEditors[i].GetTrackers())
                {
                    if (tf == trackFeature)
                    {
                        if (KeyToggleSelection)
                        {
                            FeatureEditors[i].Select(trackFeature, !trackFeature.Selected);
                        }
                        else
                        {
                            FeatureEditors[i].Select(trackFeature, true);
                        }
                    }
                }
            }
        }
Exemplo n.º 30
0
        public override void OnMouseDown(ICoordinate worldPosition, MouseEventArgs e)
        {
            MapControl.SnapTool.Reset();
            SelectTool selectTool = MapControl.SelectTool;
            IFeature oldSelectedFeature = null;
            IList<ITrackerFeature> focusedTrackers = new List<ITrackerFeature>();
            ITrackerFeature trackerFeature = selectTool.GetTrackerAtCoordinate(worldPosition);
            
            if (null != trackerFeature)
            {
                oldSelectedFeature = trackerFeature.FeatureEditor.SourceFeature;
                focusedTrackers = trackerFeature.FeatureEditor.GetFocusedTrackers();
            }

            // Let the selecttool handle the mouse event unless multiple trackers have focus and
            // there is no key pressed. In this case the user expects to move the focused trackers
            // and SelectTool will reset them
            if (!((focusedTrackers.Count > 1) && (!selectTool.KeyToggleSelection) &&
                (!selectTool.KeyExtendSelection)/* && (trackerFeature.Selected)*/))
            {
                selectTool.OnMouseDown(worldPosition, e);
                // did we just deselect out only selected tracker?
                if (null != trackerFeature)
                {
                    int focusedTrackersCount = trackerFeature.FeatureEditor.GetFocusedTrackers().Count;
                    if ((focusedTrackers.Count != focusedTrackersCount) && (0 == focusedTrackersCount))
                        return;
                }
            }

            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            if (1 != selectTool.FeatureEditors.Count)
            {
                return;
            }
            dragSource = null;
            if (selectTool.FeatureEditors.Count == 1)
            {
                isBusy = true;
                IFeature feature = selectTool.FeatureEditors[0].SourceFeature;
                if (oldSelectedFeature != feature)
                {
                    if (!selectTool.FeatureEditors[0].AllowSingleClickAndMove())
                    {
                        isBusy = false;
                        return;
                    }
                }

                if (!selectTool.FeatureEditors[0].AllowMove())
                {
                    isBusy = false;
                    return;
                }

                // TODO: this code looks too complicated
                //IFeatureProvider featureProvider = selectTool.MultiSelection[0].Layer.DataSource;
                IFeatureProvider featureProvider = selectTool.FeatureEditors[0].Layer.DataSource;
                // IndexOf doesn;'t work on shapefiles; featurerows are recreated during each read
                int dragIndex = featureProvider.Features.IndexOf(feature);
                if (-1 == dragIndex)
                {
                    isBusy = false;
                    return;
                }
                dragSource = StartDragging(worldPosition, featureProvider.GetFeature(dragIndex));
                if (null == dragSource)
                {
                    isBusy = false;
                    return;
                }
            }
            else
            {
                return;
            }
            MouseDownLocation = worldPosition; 
            snappingSource = null;
            IList<ITrackerFeature> list = selectTool.FeatureEditors[0].GetFocusedTrackers();
            if (null == list)
                return;
            if (list.Count <= 0)
                return;
            if (list.Count == 1 )
                snappingSource = list[0];
            return;
        }
Exemplo n.º 31
0
 public override void Select(ITrackerFeature trackerFeature, bool select)
 {
     trackerFeature.Selected = select;
     trackerFeature.Bitmap = select ? selectedTrackerSmall : trackerSmall;
 }
Exemplo n.º 32
0
        public virtual Cursor GetCursor(ITrackerFeature trackerFeature)
        {
// ReSharper disable AssignNullToNotNullAttribute
            return(new Cursor(Assembly.GetExecutingAssembly().GetManifestResourceStream("SharpMap.UI.Cursors.moveTracker.cur")));
// ReSharper restore AssignNullToNotNullAttribute
        }
Exemplo n.º 33
0
 public virtual void Select(ITrackerFeature trackerFeature, bool select)
 {
 }
Exemplo n.º 34
0
 public virtual void Select(ITrackerFeature trackerFeature, bool select)
 {
 }
Exemplo n.º 35
0
        public override void OnMouseDown(ICoordinate worldPosition, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            var oldSelectedTrackerIndicesCount = SelectedTrackerIndices.Count;
            var oldTrackerFeatureCount         = trackers.Count;

            IsBusy = true;
            ILayer selectedLayer;

            mouseDownLocation = worldPosition;

            // Check first if an object is already selected and if the mousedown has occured at this object.
            ITrackerFeature trackerFeature = GetTrackerAtCoordinate(worldPosition);

            if (FeatureEditors.Count > 1)
            {
                // hack: if multiple selection toggle/select complete feature
                trackerFeature = null;
            }

            SetClickOnExistingSelection(false, null);

            if (null != trackerFeature)
            {
                if (1 == FeatureEditors.Count)
                {
                    SetClickOnExistingSelection(true, worldPosition);
                    FocusTracker(trackerFeature);
                    MapControl.Refresh();
                }
                return;
            }
            // single selection. Find the nearest geometry and give
            float    limit   = (float)MapControlHelper.ImageToWorld(Map, 4);
            IFeature nearest = FindNearestFeature(worldPosition, limit, out selectedLayer, ol => ol.IsVisible);

            if (null != nearest)
            {
                // Create or add a new FeatureEditor
                if (FeatureEditors.Count > 0)
                {
                    IFeatureEditor currentMutator = GetActiveMutator(nearest);
                    if (KeyExtendSelection)
                    {
                        if (null == currentMutator)
                        {
                            // not in selection; add
                            AddSelection(selectedLayer, nearest, -1, true);
                        } // else possibly set default focus tracker
                    }
                    else if (KeyToggleSelection)
                    {
                        if (null == currentMutator)
                        {
                            // not in selection; add
                            AddSelection(selectedLayer, nearest, -1, true);
                        }
                        else
                        {
                            // in selection; remove
                            RemoveSelection(nearest);
                        }
                    }
                    else
                    {
                        // no special key processing; handle as a single select.
                        Clear();
                        if (!StartSelection(selectedLayer, nearest, -1))
                        {
                            StartMultiSelect();
                        }
                        //AddSelection(selectedLayer, nearest, -1);
                    }
                }
                else
                {
                    if (!StartSelection(selectedLayer, nearest, -1))
                    {
                        StartMultiSelect();
                    }
                    //AddSelection(selectedLayer, nearest, -1);
                }
            }
            else
            {
                // We didn't find an object at the position of the mouse button -> start a multiple select
                if (!KeyExtendSelection)
                {
                    // we are not extending the current selection
                    Clear();
                }
                if (e.Button == MouseButtons.Left)
                //if (IsActive)
                {
                    StartMultiSelect();
                }
            }

            if ((oldSelectedTrackerIndicesCount != SelectedTrackerIndices.Count ||
                 oldTrackerFeatureCount != trackers.Count) && trackingLayer.DataSource.Features.Count != 0)
            {
                MapControl.Refresh();
            }
        }
Exemplo n.º 36
0
 public override void Select(ITrackerFeature trackerFeature, bool select)
 {
     trackerFeature.Selected = select;
     trackerFeature.Bitmap   = select ? selectedTrackerSmall : trackerSmall;
 }
Exemplo n.º 37
0
        /// <summary>
        /// Processes the mouse movement. Moving an object only works when the left mouse button is pressed (drawgging).
        /// Always call the selecttool to do the default processing such as setting the correct cursor.
        /// </summary>
        /// <param name="worldPosition"></param>
        /// <param name="e"></param>
        public override void OnMouseMove(ICoordinate worldPosition, MouseEventArgs e)
        {
            MapControl.SelectTool.OnMouseMove(worldPosition, e);
            if (null == LastMouseLocation)
            {
                return;
            }
            if ((worldPosition.X == LastMouseLocation.X) && (worldPosition.Y == LastMouseLocation.Y))
            {
                return;
            }
            if ((e.Button != MouseButtons.Left) && (MapControl.SelectTool.IsActive)) // HACK snapping logic should only in curve
            {
                return;
            }
            //NS, 2013-09-13
            //if (MapControl.SelectTool.FeatureEditors[0].SourceFeature.Geometry is GeoAPI.Geometries.ILineString)
            //{
            //    GisSharpBlog.NetTopologySuite.Geometries.LineString line =
            //        MapControl.SelectTool.FeatureEditors[0].TargetFeature.Geometry as GisSharpBlog.NetTopologySuite.Geometries.LineString;

            //    if (((worldPosition.X == line.StartPoint.X) && (worldPosition.Y == line.StartPoint.Y)) &&
            //        ((worldPosition.X == line.EndPoint.X) && (worldPosition.Y == line.EndPoint.Y)))
            //    {
            //        //return;
            //        throw new ArgumentOutOfRangeException("NS Message...", "StartPoint or EndPoint cannot be move!");
            //    }
            //}

            //NS, 2013-10-14, hanya feture yang diedit yang bisa digeser....:)
            if (MapControl.SelectTool.FeatureEditors[0].SourceFeature.Attributes.Keys.Contains("Editing"))
            {
                if (!(bool)MapControl.SelectTool.FeatureEditors[0].SourceFeature.Attributes["Editing"])
                {
                    return;
                }
            }

            SnapResult = null;
            //if (null != dragSource)
            //NS: 2013-08-15, jika dragTarget == NULL error....
            if ((null != dragSource) && (null != dragTarget))
            {
                SnapResult = MapControl.SnapTool.ExecuteLayerSnapRules(MapControl.SelectTool.FeatureEditors[0].Layer,
                                                                       dragSource, dragTarget.Geometry, worldPosition,
                                                                       (null == snappingSource) ? -1 : snappingSource.Index);

                targetLayer.Style = (null == SnapResult) ? errorSelectionStyle : selectionStyle;
            }
            if (null != dragTarget)
            {
                bool adjustGeometry = MapControl.SelectTool.FeatureEditors[0].UpdateDefaultGeometry(
                    (null != SnapResult) ? SnapResult.SnappedFeature : null,
                    dragTarget,
                    (null != SnapResult) ? SnapResult.Location : worldPosition);

                if (adjustGeometry)
                {
                    SynchroniseSelectionTrackers(dragTarget.Geometry);
                }
                else
                {
                    if ((null != SnapResult) && (null != snappingSource))
                    {
                        MoveSelection(SnapResult.Location.X - dragTarget.Geometry.Coordinates[snappingSource.Index].X,
                                      SnapResult.Location.Y - dragTarget.Geometry.Coordinates[snappingSource.Index].Y);

                        //NS, 2014-05-02
                        //Untuk point awal dan akhir, apabila diedit maka akan mengikuti salah satu titik yang di gesernya (awal/akhir)
                        if ((snappingSource.Index == 0) && (dragTarget.Geometry.GeometryType == "Polygon"))
                        {
                            ITrackerFeature aTrackerFeature = MapControl.SelectTool.FeatureEditors[0].GetTrackerAtCoordinate(dragTarget.Geometry.Coordinates[dragTarget.Geometry.NumPoints - 1]);
                            if (null != aTrackerFeature)
                            {
                                //Tracker
                                //MapControl.SelectTool.FeatureEditors[0].MoveTracker(aTrackerFeature,
                                //    TrackerFeature.FeatureEditor.TargetFeature.Geometry.Coordinates[snappingSource.Index].X,
                                //    TrackerFeature.FeatureEditor.TargetFeature.Geometry.Coordinates[snappingSource.Index].Y, SnapResult);
                                //Point
                                aTrackerFeature.FeatureEditor.TargetFeature.Geometry.Coordinates[dragTarget.Geometry.NumPoints - 1].X =
                                    TrackerFeature.FeatureEditor.TargetFeature.Geometry.Coordinates[snappingSource.Index].X;
                                aTrackerFeature.FeatureEditor.TargetFeature.Geometry.Coordinates[dragTarget.Geometry.NumPoints - 1].Y =
                                    TrackerFeature.FeatureEditor.TargetFeature.Geometry.Coordinates[snappingSource.Index].Y;
                            }
                        }
                        else
                        if ((snappingSource.Index == (dragTarget.Geometry.NumPoints - 1)) && (dragTarget.Geometry.GeometryType == "Polygon"))
                        {
                            ITrackerFeature aTrackerFeature = MapControl.SelectTool.FeatureEditors[0].GetTrackerAtCoordinate(dragTarget.Geometry.Coordinates[0]);
                            if (null != aTrackerFeature)
                            {
                                //Tracker
                                //MapControl.SelectTool.FeatureEditors[0].MoveTracker(aTrackerFeature,
                                //    TrackerFeature.FeatureEditor.TargetFeature.Geometry.Coordinates[snappingSource.Index].X,
                                //    TrackerFeature.FeatureEditor.TargetFeature.Geometry.Coordinates[snappingSource.Index].Y, SnapResult);
                                //Point
                                aTrackerFeature.FeatureEditor.TargetFeature.Geometry.Coordinates[0].X =
                                    TrackerFeature.FeatureEditor.TargetFeature.Geometry.Coordinates[snappingSource.Index].X;
                                aTrackerFeature.FeatureEditor.TargetFeature.Geometry.Coordinates[0].Y =
                                    TrackerFeature.FeatureEditor.TargetFeature.Geometry.Coordinates[snappingSource.Index].Y;
                            }
                        }
                    }
                    else
                    {
                        MoveSelection(worldPosition.X - LastMouseLocation.X, worldPosition.Y - LastMouseLocation.Y);
                        //NS, 2014-05-06
                        //Jika polygon di geser, pastikan point terakhir mengikuti point awal
                        if (dragTarget.Geometry.GeometryType == "Polygon")
                        {
                            ITrackerFeature aTrackerFeature = MapControl.SelectTool.FeatureEditors[0].GetTrackerAtCoordinate(dragTarget.Geometry.Coordinates[dragTarget.Geometry.NumPoints - 1]);
                            if (null != aTrackerFeature)
                            {
                                aTrackerFeature.FeatureEditor.TargetFeature.Geometry.Coordinates[dragTarget.Geometry.NumPoints - 1].X =
                                    TrackerFeature.FeatureEditor.TargetFeature.Geometry.Coordinates[0].X;
                                aTrackerFeature.FeatureEditor.TargetFeature.Geometry.Coordinates[dragTarget.Geometry.NumPoints - 1].Y =
                                    TrackerFeature.FeatureEditor.TargetFeature.Geometry.Coordinates[0].Y;
                            }
                        }
                    }
                }
                DoDragging();
            }
            LastMouseLocation = worldPosition;
        }
Exemplo n.º 38
0
        public virtual bool MoveTracker(ITrackerFeature trackerFeature, double deltaX, double deltaY, ISnapResult snapResult)
        {
            int               index      = -1;
            IList <int>       handles    = new List <int>();
            IList <IGeometry> geometries = new List <IGeometry>();

            for (int i = 0; i < trackers.Count; i++)
            {
                geometries.Add(trackers[i].Geometry);
                if (trackers[i].Selected)
                {
                    handles.Add(i);
                }
                if (trackers[i] == trackerFeature)
                {
                    index = i;
                }
            }

            //NS, 2013-10-29, Untuk polygon hasil buffer control point seharusnya tidak bisa dipindah-pindah,
            // kecuali titik tengahnya yang di drag....
            if (trackerFeature.FeatureEditor.SourceFeature.Attributes.Keys.Contains("Buffer"))
            {
                if ((bool)trackerFeature.FeatureEditor.SourceFeature.Attributes["Buffer"])
                {
                    return(false); //throw new ArgumentException("Jangan dipindah-pindah :P.");
                }
            }

            //NS, 2013-09-09, Karena bila "throw ne ArgumentException", user awam akan menganggap error fatal,
            //jadi d return false saja deh...
            if (-1 == index)
            {
                //throw new ArgumentException("Can not find tracker; can not move.");
                //NS, 2013-09-09
                return(false);
            }
            if (0 == handles.Count)
            {
                //throw new ArgumentException("No trackers selected, can not move.");
                //NS, 2013-09-09
                return(false);
            }

            if (null != FallOffPolicy)
            {
                FallOffPolicy.Move(TargetFeature.Geometry, geometries, handles, index, deltaX, deltaY);
            }
            else
            {
                GeometryHelper.MoveCoordinate(TargetFeature.Geometry, index, deltaX, deltaY);
                TargetFeature.Geometry.GeometryChangedAction();

                GeometryHelper.MoveCoordinate(trackerFeature.Geometry, 0, deltaX, deltaY);
                trackerFeature.Geometry.GeometryChangedAction();
            }

            foreach (IFeatureRelationEditor topologyRule in TopologyRules)
            {
                topologyRule.UpdateRelatedFeatures(SourceFeature, TargetFeature.Geometry, handles);
            }

            return(true);
        }
Exemplo n.º 39
0
        public override void OnMouseDown(ICoordinate worldPosition, MouseEventArgs e)
        {
            MapControl.SnapTool.Reset();
            SelectTool selectTool                   = MapControl.SelectTool;
            IFeature   oldSelectedFeature           = null;
            IList <ITrackerFeature> focusedTrackers = new List <ITrackerFeature>();
            ITrackerFeature         trackerFeature  = selectTool.GetTrackerAtCoordinate(worldPosition);

            if (null != trackerFeature)
            {
                oldSelectedFeature = trackerFeature.FeatureEditor.SourceFeature;
                focusedTrackers    = trackerFeature.FeatureEditor.GetFocusedTrackers();
            }

            // Let the selecttool handle the mouse event unless multiple trackers have focus and
            // there is no key pressed. In this case the user expects to move the focused trackers
            // and SelectTool will reset them
            if (!((focusedTrackers.Count > 1) && (!selectTool.KeyToggleSelection) &&
                  (!selectTool.KeyExtendSelection) /* && (trackerFeature.Selected)*/))
            {
                selectTool.OnMouseDown(worldPosition, e);
                // did we just deselect out only selected tracker?
                if (null != trackerFeature)
                {
                    int focusedTrackersCount = trackerFeature.FeatureEditor.GetFocusedTrackers().Count;
                    if ((focusedTrackers.Count != focusedTrackersCount) && (0 == focusedTrackersCount))
                    {
                        return;
                    }
                }
            }

            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            if (1 != selectTool.FeatureEditors.Count)
            {
                return;
            }
            dragSource = null;
            if (selectTool.FeatureEditors.Count == 1)
            {
                isBusy = true;
                IFeature feature = selectTool.FeatureEditors[0].SourceFeature;
                if (oldSelectedFeature != feature)
                {
                    if (!selectTool.FeatureEditors[0].AllowSingleClickAndMove())
                    {
                        isBusy = false;
                        return;
                    }
                }

                if (!selectTool.FeatureEditors[0].AllowMove())
                {
                    isBusy = false;
                    return;
                }

                // TODO: this code looks too complicated
                //IFeatureProvider featureProvider = selectTool.MultiSelection[0].Layer.DataSource;
                IFeatureProvider featureProvider = selectTool.FeatureEditors[0].Layer.DataSource;
                // IndexOf doesn;'t work on shapefiles; featurerows are recreated during each read
                int dragIndex = featureProvider.Features.IndexOf(feature);
                if (-1 == dragIndex)
                {
                    isBusy = false;
                    return;
                }
                dragSource = StartDragging(worldPosition, featureProvider.GetFeature(dragIndex));
                if (null == dragSource)
                {
                    isBusy = false;
                    return;
                }
            }
            else
            {
                return;
            }
            MouseDownLocation = worldPosition;
            snappingSource    = null;
            IList <ITrackerFeature> list = selectTool.FeatureEditors[0].GetFocusedTrackers();

            if (null == list)
            {
                return;
            }
            if (list.Count <= 0)
            {
                return;
            }
            if (list.Count == 1)
            {
                snappingSource = list[0];
            }
            return;
        }