Exemplo n.º 1
0
        private async void StartEdit()
        {
            if (CurrentGraphic == null || MapEditor.IsActive)
            {
                return;
            }
            if (CurrentGraphic.Geometry.GeometryType == GeometryType.Point)
            {
                MessageBox.Show("当前图形不支持编辑");
                return;
            }
            var editingGraphic = CurrentGraphic;// Fix Bug, change layer during Editing

            editingGraphic.IsVisible = false;

            try
            {
                var progress = new Progress <GeometryEditStatus>();
                var result   = await MapEditor.EditGeometryAsync(editingGraphic.Geometry, null, progress);

                editingGraphic.Geometry = result ?? editingGraphic.Geometry;
            }
            catch (TaskCanceledException)
            {
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (editingGraphic != null)
                {
                    editingGraphic.IsVisible  = true;
                    editingGraphic.IsSelected = false;
                    editingGraphic            = null;
                    CurrentGraphic            = null;// Fix Bug, Edit->Cancel, still can edit but not selected
                }
            }
        }