Beispiel #1
0
        public override void OnMouseUp(Coordinate worldPosition, MouseEventArgs e)
        {
            if (isMoving)
            {
                MoveTool.OnMouseUp(worldPosition, e);
            }
            else
            {
                SelectTool.OnMouseUp(worldPosition, e);
            }

            isBusy   = false;
            isMoving = false;
        }
Beispiel #2
0
        public override void OnMouseMove(Coordinate worldPosition, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.None && !isMoving)
            {
                return;
            }

            if (isMoving)
            {
                MoveTool.OnMouseMove(worldPosition, e);
            }
            else if ((SelectTool.SelectedFeatureInteractors.Count == 1) &&
                     SupportedGeometry(SelectTool.SelectedFeatureInteractors[0].SourceFeature.Geometry))
            {
                SelectTool.OnMouseMove(worldPosition, e);
                Snap(SelectTool.SelectedFeatureInteractors[0].SourceFeature.Geometry, worldPosition);
                SetMouseCursor(worldPosition);
                StartDrawing();
                DoDrawing(true);
                StopDrawing();
            }
        }
Beispiel #3
0
        public override void OnMouseDown(Coordinate worldPosition, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            isBusy = true;

            if (SelectTool.SelectedFeatureInteractors.Count != 1)
            {
                SelectTool.OnMouseDown(worldPosition, e);
                return;
            }
            var featureInteractor = SelectTool.SelectedFeatureInteractors[0];

            if (SupportedGeometry(featureInteractor.SourceFeature.Geometry))
            {
                if (SnapResult == null)
                {
                    SelectTool.OnMouseDown(worldPosition, e);
                    return;
                }

                var trackerFeature = featureInteractor.GetTrackerAtCoordinate(SnapResult.Location);

                // if user click visible tracker it will be handled as move, otherwise a Trackers will be added.
                if (Mode == EditMode.Add && trackerFeature != null && trackerFeature.Index != -1)
                {
                    MoveTool.OnMouseDown(worldPosition, e);
                    isMoving = true;
                    return;
                }

                featureInteractor.Start();

                if (featureInteractor.EditableObject != null)
                {
                    var featureName = featureInteractor.SourceFeature is INameable
                                          ? ((INameable)featureInteractor.SourceFeature).Name
                                          : "";

                    featureInteractor.EditableObject.BeginEdit(string.Format(ActionName + " {0}", featureName));
                }

                var result = Mode == EditMode.Add
                                  ? featureInteractor.InsertTracker(SnapResult.Location, SnapResult.SnapIndexPrevious + 1)
                                  : featureInteractor.RemoveTracker(trackerFeature);

                featureInteractor.Stop();

                if (featureInteractor.EditableObject != null)
                {
                    featureInteractor.EditableObject.EndEdit();
                }

                SelectTool.Select(featureInteractor.Layer, featureInteractor.SourceFeature);

                if (result)
                {
                    featureInteractor.Layer.RenderRequired = true;

                    MapControl.Refresh();

                    return;
                }
            }

            // if no curve point modification, handle as normal selection
            SelectTool.OnMouseDown(worldPosition, e);
        }