Пример #1
0
        internal static void ActiveMap_MapClick(object sender, MapMouseClickInteractiveOverlayEventArgs e)
        {
            if (CurrentMarkerOverlay != null)
            {
                bool needTakeSnapshot = true;

                if (Keyboard.Modifiers != ModifierKeys.Shift)
                {
                    needTakeSnapshot = CommitTextAnnotations();
                    ViewModel.SyncStylePreview();
                }

                if (needTakeSnapshot)
                {
                    ViewModel.TakeSnapshot();
                }
            }

            if (ViewModel.SelectedMode != null && ViewModel.SelectedMode.Mode == TrackMode.Custom && shouldAddTextBoxWhenNextClick)
            {
                AddMarker(new PointShape(e.InteractionArguments.WorldX, e.InteractionArguments.WorldY));
            }
        }
Пример #2
0
        private void TrackOverlay_MapMouseClick(object sender, MapMouseClickInteractiveOverlayEventArgs e)
        {
            PointShape           clickedPoint         = new PointShape(e.InteractionArguments.WorldX, e.InteractionArguments.WorldY);
            RectangleShape       rect                 = MapSuiteSampleHelper.GetBufferedRectangle(clickedPoint, mapModel.MapControl.CurrentResolution);
            Collection <Feature> intersectingFeatures = mapModel.MapControl.TrackOverlay.TrackShapeLayer.QueryTools.GetFeaturesIntersecting(rect, ReturningColumnsType.AllColumns);

            if (intersectingFeatures.Count > 0)
            {
                if (mapModel.MapControl.EditOverlay.EditShapesLayer.InternalFeatures.Count > 0)
                {
                    foreach (var item in mapModel.MapControl.EditOverlay.EditShapesLayer.InternalFeatures)
                    {
                        mapModel.MapControl.TrackOverlay.TrackShapeLayer.InternalFeatures.Add(item.Id, item);
                    }
                    mapModel.MapControl.EditOverlay.EditShapesLayer.InternalFeatures.Clear();
                }
                mapModel.MapControl.TrackOverlay.TrackShapeLayer.InternalFeatures.Remove(intersectingFeatures[0].Id);
                mapModel.MapControl.EditOverlay.EditShapesLayer.InternalFeatures.Add(intersectingFeatures[0]);
                mapModel.MapControl.EditOverlay.CalculateAllControlPoints();
                mapModel.MapControl.Refresh(mapModel.MapControl.TrackOverlay);
                mapModel.MapControl.Refresh(mapModel.MapControl.EditOverlay);
            }
        }
        //internal static void ActiveMap_MapClick(object sender, MapClickWpfMapEventArgs e)
        internal static void ActiveMap_MapClick(object sender, MapMouseClickInteractiveOverlayEventArgs e)
        {
            if (ViewModel.IsInModifyMode)
            {
                ViewModel.CurrentAnnotationOverlay.TrackShapeLayer.Open();
                RectangleShape clickBuffer = GetClickBuffer(e.InteractionArguments.WorldX, e.InteractionArguments.WorldY);

                #region save feature ids to exclude temporary.

                var tmpFeatureIdsToExclude = new Collection <string>();
                foreach (var id in ViewModel.CurrentAnnotationOverlay.TrackShapeLayer.FeatureIdsToExclude)
                {
                    tmpFeatureIdsToExclude.Add(id);
                }
                ViewModel.CurrentAnnotationOverlay.TrackShapeLayer.FeatureIdsToExclude.Clear();

                #endregion save feature ids to exclude temporary.

                var foundFeature = ViewModel.CurrentAnnotationOverlay.TrackShapeLayer.QueryTools
                                   .GetFeaturesIntersecting(clickBuffer, ViewModel.CurrentAnnotationOverlay.TrackShapeLayer.GetDistinctColumnNames()).FirstOrDefault(tmpFeature => !tmpFeatureIdsToExclude.Contains(tmpFeature.Id));

                if (foundFeature == default(Feature))
                {
                    PlatformGeoCanvas geoCanvas = new PlatformGeoCanvas();
                    foundFeature = ViewModel.CurrentAnnotationOverlay.TrackShapeLayer.InternalFeatures
                                   .Where(tmpFeature => tmpFeature.ColumnValues.ContainsKey(AnnotationTrackInteractiveOverlay.AnnotationTextColumnName) &&
                                          !String.IsNullOrEmpty(tmpFeature.ColumnValues[AnnotationTrackInteractiveOverlay.AnnotationTextColumnName]))
                                   .FirstOrDefault(textFeature =>
                    {
                        if (tmpFeatureIdsToExclude.Contains(textFeature.Id))
                        {
                            return(false);
                        }

                        TextStyle textStyle = ViewModel.CurrentAnnotationOverlay
                                              .GetSpecificTextStyle(textFeature.ColumnValues[AnnotationTrackInteractiveOverlay.ValueStyleMatchColumnName]);

                        DrawingRectangleF textArea = geoCanvas.MeasureText(textFeature.ColumnValues[AnnotationTrackInteractiveOverlay.AnnotationTextColumnName]
                                                                           , textStyle.Font);

                        PointShape textScreenPoint = GisEditor.ActiveMap.ToScreenCoordinate((PointShape)textFeature.GetShape());

                        double left   = textScreenPoint.X;
                        double top    = textScreenPoint.Y;
                        double right  = textScreenPoint.X + textArea.Width;
                        double bottom = textScreenPoint.Y + textArea.Height;

                        string placementString = textStyle.PointPlacement.ToString();
                        if (placementString.Contains("Left"))
                        {
                            left = textScreenPoint.X - textArea.Width;
                        }

                        if (placementString.Contains("Upper"))
                        {
                            top = textScreenPoint.Y - textArea.Height;
                        }

                        PointShape upperLeft  = GisEditor.ActiveMap.ToWorldCoordinate(new PointShape(left, top));
                        PointShape lowerRight = GisEditor.ActiveMap.ToWorldCoordinate(new PointShape(right, bottom));

                        RectangleShape textWorldArea = new RectangleShape(upperLeft, lowerRight);
                        return(textWorldArea.Intersects(new PointShape(e.InteractionArguments.WorldX, e.InteractionArguments.WorldY)));
                    });
                }

                #region restore feature ids to exclude

                foreach (var id in tmpFeatureIdsToExclude)
                {
                    ViewModel.CurrentAnnotationOverlay.TrackShapeLayer.FeatureIdsToExclude.Add(id);
                }

                #endregion restore feature ids to exclude

                ViewModel.CurrentAnnotationOverlay.TrackShapeLayer.Close();

                if (foundFeature != default(Feature))
                {
                    var isShiftDown = Keyboard.Modifiers == ModifierKeys.Shift;
                    if (!isShiftDown)
                    {
                        CommitEdit(false);
                    }

                    bool isEditing = true;
                    if (!ViewModel.CurrentAnnotationOverlay.TrackShapeLayer.FeatureIdsToExclude.Contains(foundFeature.Id))
                    {
                        ViewModel.CurrentAnnotationOverlay.TrackShapeLayer.FeatureIdsToExclude.Add(foundFeature.Id);
                    }
                    else
                    {
                        isEditing = false;
                        if (isShiftDown)
                        {
                            ViewModel.CurrentAnnotationOverlay.TrackShapeLayer.FeatureIdsToExclude.Remove(foundFeature.Id);
                            if (ViewModel.CurrentEditOverlay.EditShapesLayer.InternalFeatures.Contains(foundFeature.Id))
                            {
                                ViewModel.CurrentEditOverlay.EditShapesLayer.InternalFeatures.Remove(foundFeature.Id);
                            }
                        }
                    }

                    if (isEditing)
                    {
                        SetAnnotationToEditMode(foundFeature);
                    }

                    ViewModel.CurrentEditOverlay.CalculateAllControlPoints();
                    ViewModel.CurrentAnnotationOverlay.Refresh();
                    ViewModel.CurrentEditOverlay.Refresh();
                    ViewModel.SyncUIState();
                    ViewModel.TakeSnapshot();
                }
                else
                {
                    if (ViewModel.CurrentEditOverlay.EditShapesLayer.InternalFeatures.Count > 0 ||
                        (MarkerHelper.CurrentMarkerOverlay != null && MarkerHelper.CurrentMarkerOverlay.Markers.Count > 0))
                    {
                        System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => CommitEdit()));
                    }
                }
            }
        }
 private void TrackOverlay_MapMouseClick(object sender, MapMouseClickInteractiveOverlayEventArgs e)
 {
     PointShape clickedPoint = new PointShape(e.InteractionArguments.WorldX, e.InteractionArguments.WorldY);
     RectangleShape rect = MapSuiteSampleHelper.GetBufferedRectangle(clickedPoint, mapModel.MapControl.CurrentResolution);
     Collection<Feature> intersectingFeatures = mapModel.MapControl.TrackOverlay.TrackShapeLayer.QueryTools.GetFeaturesIntersecting(rect, ReturningColumnsType.AllColumns);
     if (intersectingFeatures.Count > 0)
     {
         if (mapModel.MapControl.EditOverlay.EditShapesLayer.InternalFeatures.Count > 0)
         {
             foreach (var item in mapModel.MapControl.EditOverlay.EditShapesLayer.InternalFeatures)
             {
                 mapModel.MapControl.TrackOverlay.TrackShapeLayer.InternalFeatures.Add(item.Id, item);
             }
             mapModel.MapControl.EditOverlay.EditShapesLayer.InternalFeatures.Clear();
         }
         mapModel.MapControl.TrackOverlay.TrackShapeLayer.InternalFeatures.Remove(intersectingFeatures[0].Id);
         mapModel.MapControl.EditOverlay.EditShapesLayer.InternalFeatures.Add(intersectingFeatures[0]);
         mapModel.MapControl.EditOverlay.CalculateAllControlPoints();
         mapModel.MapControl.Refresh(mapModel.MapControl.TrackOverlay);
         mapModel.MapControl.Refresh(mapModel.MapControl.EditOverlay);
     }
 }