private void EditGeometry_GeometryEdit(object sender, EditGeometry.GeometryEditEventArgs e)
 {
     if (ActionTextBox.Text != string.Empty)
     {
         ActionTextBox.Select(0, 0);
         ActionTextBox.SelectedText = string.Format("{0}:{1}{2}", actionCount, e.Action, Environment.NewLine);
     }
     else
     {
         ActionTextBox.Text = string.Format("{0}:{1}", actionCount, e.Action);
     }
     actionCount++;
 }
Пример #2
0
        /// <summary>
        /// Event handler for EditGeometry action notifications
        /// </summary>
        static void editGeometry_GeometryEdit(object sender, EditGeometry.GeometryEditEventArgs e)
        {
            // Handle when the user clicks to complete the edit operation
            if (e.Action == Client.EditGeometry.Action.EditCompleted)
            {
                _editGeometry.GeometryEdit -= editGeometry_GeometryEdit;
                if (_editedGraphic != null)
                {
                    if (_editedGraphic.Geometry.SpatialReference == null && View.Instance.Map != null && View.Instance.Map.SpatialReference != null)
                    {
                        // add the spatial reference so the Simplify opertion does not fail
                        _editedGraphic.Geometry.SpatialReference = View.Instance.Map.SpatialReference;
                    }

                    ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.GeometryService.SimplifyGraphicAsync(_editedGraphic, OnSimplifyCompleted);
                }
            }
        }
Пример #3
0
        void EditGeometry_GeometryEdit(object sender, EditGeometry.GeometryEditEventArgs e)
        {
            if (e.Graphic != null && (e.Action == EditGeometry.Action.EditCompleted))
            {
                if (e.Graphic.Selected)
                {
                    e.Graphic.Selected = false;

                    if (ShapeSelected != null)
                    {
                        ShapeSelected.Geometry = e.Geometry;
                    }

                    ItemsSource.Remove(EditShape);
                    EditShape = null;
                    EditGeometry.IsEnabled = false;
                    EditGeometry.StopEdit();

                    //var geo = e.Geometry as Polyline;
                    //if (geo != null)
                    //{
                    //    var points = geo.Paths.ToList()[0];
                    //    var pointList = new List<Point>();

                    //    foreach (var point in points)
                    //    {
                    //        pointList.Add(new Point(point.X, point.Y));
                    //    }

                    //    Messenger.Default.Send(new MapWaypointMessenger
                    //    {
                    //        Points = pointList,
                    //        TaskId = 0,
                    //    });
                    //}
                    var mapControl = ServiceLocator.Current.GetInstance <IMap>();
                    if (mapControl != null)
                    {
                        var    pointList = new List <Point>();
                        ushort taskId    = 0;
                        foreach (var guiTask in mapControl.ShapesItemsSource)
                        {
                            var guiTaskNav = guiTask as Shape;
                            var polyline   = e.Geometry as Polyline;
                            if (guiTaskNav != null)
                            {
                                if (guiTaskNav.Geometry == e.Geometry)
                                {
                                    foreach (var path in polyline.Paths.ToList())
                                    {
                                        foreach (var p in path)
                                        {
                                            pointList.Add(new Point(p.X, p.Y));
                                        }
                                    }
                                    taskId = (ushort)guiTaskNav.ID;
                                }
                            }
                        }
                        if (taskId > 0 && pointList.Count > 1)
                        {
                            Messenger.Default.Send(new MapWaypointMessenger
                            {
                                Points = pointList,
                                TaskId = taskId
                            });
                        }
                    }
                }
            }
            else if (e.Action == EditGeometry.Action.EditCanceled)
            {
                ItemsSource.Remove(EditShape);
                EditShape              = null;
                ShapeSelected          = null;
                EditGeometry.IsEnabled = false;
                EditGeometry.StopEdit();
            }
            else if (e.Action == EditGeometry.Action.EditStarted)
            {
                _vertexGraphicList.ForEach(f => ItemsSource.Remove(f));
                _vertexGraphicList.Clear();
                AddVertexLabel(e.Geometry);
            }
            else if (e.Action == EditGeometry.Action.GeometryMoved ||
                     e.Action == EditGeometry.Action.GeometryScaled ||
                     e.Action == EditGeometry.Action.GeometryRotated ||
                     e.Action == EditGeometry.Action.VertexAdded ||
                     e.Action == EditGeometry.Action.VertexMoved ||
                     e.Action == EditGeometry.Action.VertexRemoved)
            {
                _vertexGraphicList.ForEach(f => ItemsSource.Remove(f));
                _vertexGraphicList.Clear();
                AddVertexLabel(e.Geometry);
            }
        }