protected override Task<bool> OnSketchCompleteAsync(ArcGIS.Core.Geometry.Geometry geometry)
        {
            //Check we only have one feature to extend to
            if (MapView.Active.Map.SelectionCount != 1)
            {
                MessageBox.Show("Please select one polyline or polygon feature to extend to", "Extend");
                return Task.FromResult(true);
            }

            //Run on MCT
            return QueuedTask.Run(() =>
            {
                //get selected feature geometry
                var selectedFeatures = MapView.Active.Map.GetSelection();
                var insp = new Inspector();
                insp.Load(selectedFeatures.Keys.First(), selectedFeatures.Values.First());
                var selGeom = insp.Shape;
                if (!(selGeom.GeometryType == GeometryType.Polygon
                    || selGeom.GeometryType == GeometryType.Polyline))
                {
                    MessageBox.Show("Please choose as the selected feature either a polyline or polygon feature to extend to");
                    return false;
                }

                //find feature at the click
                var clickFeatures = MapView.Active.GetFeatures(geometry);
                insp.Load(clickFeatures.First().Key, clickFeatures.First().Value);
                var clickGeom = insp.Shape as Polyline;
                if (clickGeom == null)
                {
                    MessageBox.Show("Please select a polyline feature to extend");
                    return false;
                }

                //extend the line to the poly?
                ArcGIS.Core.Geometry.Polyline extPolyline;
                extPolyline = GeometryEngine.Extend(clickGeom, (selGeom.GeometryType == GeometryType.Polygon ? GeometryEngine.Boundary(selGeom) as Polyline : selGeom as Polyline), ExtendFlags.Default);
                if (extPolyline == null)
                {
                    MessageBox.Show(string.Format("Unable to extend the clicked {0} to the selected {1}",
                        clickGeom.GeometryType, selGeom.GeometryType));
                    return false;
                }

                //set the new geometry back on the feature
                insp.Shape = extPolyline;

                //create and execute the edit operation
                var op = new EditOperation();
                op.Name = "Extend";
                op.SelectModifiedFeatures = false;
                op.SelectNewFeatures = false;
                op.Modify(insp);
                return op.Execute();
            });
        }
        protected override Task <bool> OnSketchCompleteAsync(ArcGIS.Core.Geometry.Geometry geometry)
        {
            //Simple check for selected layer
            if (MappingModule.ActiveTOC.SelectedLayers.Count == 0)
            {
                System.Windows.MessageBox.Show("Select a layer in the toc");
                return(Task.FromResult(true));
            }

            //jump to CIM thread
            return(QueuedTask.Run(async() =>
            {
                //Get the selected layer in toc
                var featLayer = MappingModule.ActiveTOC.SelectedLayers[0] as FeatureLayer;

                //find feature oids under the sketch for the selected layer
                var features = await MapView.Active.HitTestAsync(geometry, CancelableProgressor.None);
                var featOids = features.Where(x => x.Item1 == featLayer).Select(x => x.Item2).First();

                //update the attributes of those features
                var fi = new FeatureInspector(true);
                await fi.FillAsync(featLayer, featOids);
                await fi.Attributes.Where(a => a.FieldName == "PARCEL_ID").First().SetValueAsync(42);

                //create and execute the edit operation
                var op = new EditOperation();
                op.Name = "The ultimate answer";
                op.SelectModifiedFeatures = true;
                op.SelectNewFeatures = false;
                op.Modify(fi);
                return await op.ExecuteAsync();
            }));
        }
예제 #3
0
        protected override async Task SetStatusCoreAsync(IWorkItem item, ISourceClass source)
        {
            Table table = OpenFeatureClass(source);

            try
            {
                var databaseSourceClass = (DatabaseSourceClass)source;

                string description = GetOperationDescription(item.Status);

                _msg.Info($"{description}, {item.Proxy}");

                var operation = new EditOperation {
                    Name = description
                };

                string fieldName = databaseSourceClass.StatusFieldName;
                object value     = databaseSourceClass.GetValue(item.Status);

                operation.Modify(table, item.ObjectID, fieldName, value);

                await operation.ExecuteAsync();
            }
            catch (Exception e)
            {
                _msg.Error($"Error set status of work item {item.OID}, {item.Proxy}", e);
                throw;
            }
            finally
            {
                table?.Dispose();
            }
        }
예제 #4
0
        protected override Task <bool> OnSketchCompleteAsync(ArcGIS.Core.Geometry.Geometry geometry)
        {
            //Simple check for selected layer
            if (MapView.Active.GetSelectedLayers().Count == 0)
            {
                MessageBox.Show("Please select a layer in the toc", "Update attributes with sketch");
                return(Task.FromResult(true));
            }

            //Run on MCT
            return(QueuedTask.Run(() =>
            {
                //Get the selected layer in toc
                var featLayer = MapView.Active.GetSelectedLayers().First() as FeatureLayer;

                //find feature oids under the sketch for the selected layer
                var features = MapView.Active.GetFeatures(geometry);
                var featOids = features[featLayer];

                //update the attributes of those features
                var insp = new Inspector();
                insp.Load(featLayer, featOids);
                insp["PARCEL_ID"] = 42;

                //create and execute the edit operation
                var op = new EditOperation();
                op.Name = "Update parcel";
                op.SelectModifiedFeatures = true;
                op.SelectNewFeatures = false;
                op.Modify(insp);
                return op.Execute();
            }));
        }
예제 #5
0
파일: Main.cs 프로젝트: agrc/TrailsAddin
        internal Task EnsureIDsForSelectedAsync(EditOperation operation)
        {
            return(QueuedTask.Run(() =>
            {
                using (var segmentsCursor = SegmentsLayer.GetSelection().Search(null, false))
                {
                    while (segmentsCursor.MoveNext())
                    {
                        var row = segmentsCursor.Current;
                        EnsureIDForSegment(row, operation);
                    }
                }

                using (RowCursor headsCursor = HeadsLayer.GetSelection().Search(null, false))
                {
                    while (headsCursor.MoveNext())
                    {
                        var row = headsCursor.Current;
                        if (row[USNG_TH] == null || (string)row[USNG_TH] == "" || (string)row[USNG_TH] == "<Null>")
                        {
                            operation.Modify(HeadsLayer, row.GetObjectID(), new Dictionary <string, object> {
                                [USNG_TH] = GetUSNGID_Point((MapPoint)row["Shape"])
                            });
                        }
                    }
                }
            }));
        }
        /// <summary>
        /// Applys the domain code to the currenly selected feature
        /// </summary>
        /// <param name="code"></param>
        internal async void ApplyDomain(DomainCode code)
        {
            if (await CheckRequirements())
            {
                await QueuedTask.Run(() =>
                {
                    try
                    {
                        Selection selection = _selectedLayer.GetSelection();
                        var oidset          = selection.GetObjectIDs();

                        var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector();
                        insp.Load(_selectedLayer, oidset);
                        insp[_selectedField] = (int)code;

                        var op  = new EditOperation();
                        op.Name = "Set Domain to " + ((int)code).ToString();
                        op.Modify(insp);
                        op.Execute();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error: " + ex.Message);
                    }
                });
            }
        }
예제 #7
0
        protected void inspectorclass()
        {
            var   featLayer = MapView.Active.GetSelectedLayers().First() as FeatureLayer;
            Int64 oid       = 42;

            #region inspectorclass
            QueuedTask.Run(() =>
            {
                var insp = new Inspector();
                insp.Load(featLayer, oid);

                //get the shape of the feature
                var myGeometry = insp.Shape;

                //get an attribue value by name
                var propValue = insp["Prop_value"];

                //set an attribute value by name
                insp["Parcel_no"] = 42;

                //perform the edit
                var op  = new EditOperation();
                op.Name = "Update parcel";
                op.Modify(insp);
                op.Execute();
            });
            #endregion
        }
    protected override Task<bool> OnSketchCompleteAsync(ArcGIS.Core.Geometry.Geometry geometry)
    {
      //Simple check for selected layer
      if (MappingModule.ActiveTOC.SelectedLayers.Count == 0)
      {
        System.Windows.MessageBox.Show("Select a layer in the toc");
        return Task.FromResult(true);
      }

      //jump to CIM thread
      return QueuedTask.Run(async () =>
      {
        //Get the selected layer in toc
        var featLayer = MappingModule.ActiveTOC.SelectedLayers[0] as FeatureLayer;

        //find feature oids under the sketch for the selected layer
        var features = await MapView.Active.HitTestAsync(geometry, CancelableProgressor.None);
        var featOids = features.Where(x => x.Item1 == featLayer).Select(x => x.Item2).First();

        //update the attributes of those features
        var fi = new FeatureInspector(true);
        await fi.FillAsync(featLayer, featOids);
        await fi.Attributes.Where(a => a.FieldName == "PARCEL_ID").First().SetValueAsync(42);

        //create and execute the edit operation
        var op = new EditOperation();
        op.Name = "The ultimate answer";
        op.SelectModifiedFeatures = true;
        op.SelectNewFeatures = false;
        op.Modify(fi);
        return await op.ExecuteAsync();
      });
    }
예제 #9
0
        public static void ReadWriteBlobInspector()
        {
            #region Read and Write blob fields with the attribute inspector
            QueuedTask.Run(() =>
            {
                //get selected feature into inspector
                var selectedFeatures = MapView.Active.Map.GetSelection();
                var insp             = new Inspector();
                insp.Load(selectedFeatures.Keys.First(), selectedFeatures.Values.First());

                //read file into memory stream
                var msr = new MemoryStream();
                using (FileStream file = new FileStream(@"d:\images\Hydrant.jpg", FileMode.Open, FileAccess.Read))
                {
                    file.CopyTo(msr);
                }

                //put the memory stream in the blob field
                var op            = new EditOperation();
                op.Name           = "Blob Inspector";
                insp["Blobfield"] = msr;
                op.Modify(insp);
                op.Execute();

                //read a blob field and save to a file
                //assume inspector has been loaded with a feature
                var msw = new MemoryStream();
                msw     = insp["Blobfield"] as MemoryStream;
                using (FileStream file = new FileStream(@"d:\temp\blob.jpg", FileMode.Create, FileAccess.Write))
                {
                    msw.WriteTo(file);
                }
            });
            #endregion
        }
    protected override Task<bool> OnSketchCompleteAsync(ArcGIS.Core.Geometry.Geometry geometry)
    {
      //Simple check for selected layer
      if (MapView.Active.GetSelectedLayers().Count == 0)
      {
        MessageBox.Show("Please select a layer in the toc","Update attributes with sketch");
        return Task.FromResult(true);
      }

      //Run on MCT
      return QueuedTask.Run(() =>
      {
        //Get the selected layer in toc
        var featLayer = MapView.Active.GetSelectedLayers().First() as FeatureLayer;

        //find feature oids under the sketch for the selected layer
        var features = MapView.Active.GetFeatures(geometry);
        var featOids = features[featLayer];

        //update the attributes of those features
        var insp = new Inspector();
        insp.Load(featLayer, featOids);
        insp["PARCEL_ID"] = 42;

        //create and execute the edit operation
        var op = new EditOperation();
        op.Name = "Update parcel";
        op.SelectModifiedFeatures = true;
        op.SelectNewFeatures = false;
        op.Modify(insp);
        return op.Execute();
      });
    }
        /// <summary>
        /// Update the field with a given value (int)
        /// </summary>
        /// <param name="status"></param>
        /// <param name="editName"></param>
        public void Update(int status, string editName)
        {
            QueuedTask.Run(() => {
                try
                {
                    var basicfeaturelayer = _selectedLayer as BasicFeatureLayer;
                    var selection         = basicfeaturelayer.GetSelection();
                    var oidset            = selection.GetObjectIDs();

                    var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector();
                    insp.Load(basicfeaturelayer, oidset);
                    insp[InpsectorFieldName] = 1;

                    var op  = new EditOperation();
                    op.Name = editName;
                    op.Modify(insp);
                    op.Execute();

                    basicfeaturelayer.ClearSelection();
                } catch (Exception ex)
                {
                    MessageBox.Show("Error: " + ex.Message);
                }
            });
        }
예제 #12
0
        protected void UpdateAttrib()
        {
            QueuedTask.Run(() =>
            {
                //get the geometry of the selected feature.
                var selectedFeatures = MapView.Active.Map.GetSelection();
                var insp             = new Inspector();
                insp.Load(selectedFeatures.Keys.First(), selectedFeatures.Values.First());
                var selGeom = insp.Shape;

                //var extPolyline = some geometry operation.
                var extPolyline = new MapPointBuilder(1.0, 1.0).ToGeometry();

                //set the new geometry back on the feature
                insp.Shape = extPolyline;

                //update an attribute value
                insp["RouteNumber"] = 42;

                //create and execute the edit operation
                var op = new EditOperation()
                {
                    Name = "Extend"
                };
                op.Modify(insp);
                op.Execute();
            });
        }
        protected override void OnClick()
        {
            if (Module1.Current.SelectedItems == null)
            {
                return;
            }

            int    aantalVerdiepingen;
            double verdiepingsHoogte;

            QueuedTask.Run(() =>
            {
                var editOperation = new EditOperation();
                foreach (KeyValuePair <MapMember, List <long> > item in Module1.Current.SelectedItems)
                {
                    var layer = item.Key as BasicFeatureLayer;

                    foreach (long oid in item.Value)
                    {
                        var feature        = layer.Inspect(oid);
                        aantalVerdiepingen = new Random().Next(3, 10);
                        verdiepingsHoogte  = double.Parse(feature["PandHoogte"].ToString()) / aantalVerdiepingen;

                        feature["PandHoogte"] = verdiepingsHoogte;
                        editOperation.Modify(feature);
                        for (int i = 1; i < aantalVerdiepingen; i++)
                        {
                            editOperation.Create(layer, GeometryEngine.Move(feature.Shape, 0, 0, (i * (verdiepingsHoogte * 2))), new Action <long>(x => newFloorCreated(x, layer, verdiepingsHoogte, feature.Shape.Extent.ZMin)));
                        }
                    }
                }
                bool succeded = editOperation.Execute();
            });
        }
        private void CutBuilding(MapViewMouseButtonEventArgs e)
        {
            QueuedTask.Run(() =>
            {
                Dictionary <MapMember, List <long> > selectedItems = GetSelectedItems(e);
                EditOperation editOperation = new EditOperation();
                foreach (KeyValuePair <MapMember, List <long> > item in selectedItems)
                {
                    BasicFeatureLayer layer = item.Key as BasicFeatureLayer;
                    if (layer.ShapeType != ArcGIS.Core.CIM.esriGeometryType.esriGeometryPolygon)
                    {
                        continue;
                    }

                    foreach (long oid in item.Value)
                    {
                        var feature = layer.Inspect(oid);

                        Geometry geometry = feature.Shape.Clone();
                        Polyline polyLine = GetCutPolyLine(geometry);

                        var splitItems = GeometryEngine.Cut(geometry, polyLine);
                        feature.Shape  = splitItems.First();
                        editOperation.Modify(feature);

                        Layer pointLayer = MapView.Active.Map.Layers[0];
                        editOperation.Create(pointLayer, geometry.Extent.Center);
                    }
                    editOperation.Execute();
                }
                MapView.Active.Map.SetSelection(null);
            });
        }
예제 #15
0
        public async void Examples3()
        {
            var oid = 1;

            #region Edit the attributes of a FeatureSceneLayer
            //must support editing!
            var featSceneLayer = MapView.Active.Map.GetLayersAsFlattenedList()
                                 .OfType <FeatureSceneLayer>().FirstOrDefault();
            if (!featSceneLayer.HasAssociatedFeatureService ||
                !featSceneLayer.IsEditable)
            {
                return;
            }

            var ok = await QueuedTask.Run(() =>
            {
                var editOp = new EditOperation()
                {
                    Name = "Edit FeatureSceneLayer Attributes",
                    SelectModifiedFeatures = true
                };
                //make an inspector
                var inspector = new Inspector();
                //get the attributes for the specified oid
                inspector.Load(featSceneLayer, oid);
                inspector["PermitNotes"] = "test"; //modify
                editOp.Modify(inspector);
                return(editOp.Execute());          //synchronous flavor
            });

            #endregion
        }
예제 #16
0
        protected override Task <bool> OnSketchCompleteAsync(ArcGIS.Core.Geometry.Geometry geometry)
        {
            //Check we only have one feature to extend to
            if (MapView.Active.Map.SelectionCount != 1)
            {
                MessageBox.Show("Please select one polyline or polygon feature to extend to", "Extend");
                return(Task.FromResult(true));
            }

            //Run on MCT
            return(QueuedTask.Run(() =>
            {
                //get selected feature geometry
                var selectedFeatures = MapView.Active.Map.GetSelection();
                var insp = new Inspector();
                insp.Load(selectedFeatures.ToDictionary().Keys.First(), selectedFeatures.ToDictionary().Values.First());
                var selGeom = GeometryEngine.Instance.Project(insp.Shape, MapView.Active.Map.SpatialReference);
                if (!(selGeom.GeometryType == GeometryType.Polygon ||
                      selGeom.GeometryType == GeometryType.Polyline))
                {
                    MessageBox.Show("Please choose as the selected feature either a polyline or polygon feature to extend to");
                    return false;
                }

                //find feature at the click
                var clickFeatures = MapView.Active.GetFeatures(geometry);
                var featuresOids = clickFeatures[clickFeatures.ToDictionary().Keys.First()];
                insp.Load(clickFeatures.ToDictionary().First().Key, featuresOids.First());
                var clickGeom = insp.Shape as Polyline;
                if (clickGeom == null)
                {
                    MessageBox.Show("Please select a polyline feature to extend");
                    return false;
                }

                //extend the line to the poly?
                ArcGIS.Core.Geometry.Polyline extPolyline;
                extPolyline = GeometryEngine.Instance.Extend(clickGeom, (selGeom.GeometryType == GeometryType.Polygon ? GeometryEngine.Instance.Boundary(selGeom) as Polyline : selGeom as Polyline), ExtendFlags.Default);
                if (extPolyline == null)
                {
                    MessageBox.Show(string.Format("Unable to extend the clicked {0} to the selected {1}",
                                                  clickGeom.GeometryType, selGeom.GeometryType));
                    return false;
                }

                //set the new geometry back on the feature
                insp.Shape = extPolyline;

                //create and execute the edit operation
                var op = new EditOperation()
                {
                    Name = "Extend",
                    SelectModifiedFeatures = false,
                    SelectNewFeatures = false
                };
                op.Modify(insp);
                return op.Execute();
            }));
        }
        private void ExecuteRotateAnnotation()
        {
            var mapView = MapView.Active;

            if (mapView == null)
            {
                return;
            }


            try
            {
                QueuedTask.Run(() =>
                {
                    var selection = mapView.Map.GetSelection();

                    // 選択しているフィーチャクラスがある場合
                    if (selection.Count > 0)
                    {
                        var editOperation = new EditOperation();

                        // フィーチャクラスごとにループ
                        foreach (var mapMember in selection)
                        {
                            var layer = mapMember.Key as BasicFeatureLayer;

                            // アノテーションの場合
                            if (layer.GetType().Name == "AnnotationLayer")
                            {
                                using (var rowCursor = layer.GetSelection().Search(null))
                                {
                                    var inspector = new Inspector();

                                    while (rowCursor.MoveNext())
                                    {
                                        using (var row = rowCursor.Current)
                                        {
                                            // 角度更新
                                            inspector.Load(layer, row.GetObjectID());
                                            var annoProperties   = inspector.GetAnnotationProperties();
                                            annoProperties.Angle = _angle;
                                            inspector.SetAnnotationProperties(annoProperties);

                                            editOperation.Modify(inspector);
                                        }
                                    }
                                }
                            }
                        }

                        editOperation.Execute();
                    }
                });
            }
            catch
            {
                MessageBox.Show("アノテーションの角度変更に失敗しました。");
            }
        }
예제 #18
0
        /// <summary>
        /// Asynchronous task that splits the current sketch geometry into 100 segments of equal length.
        /// </summary>
        /// <returns>Task{bool}</returns>
        private async Task <bool> ExecuteDensify()
        {
            // get the current sketch geometry from the editing module
            var sketchGeometry = await EditingModule.GetSketchGeometryAsync();

            // check if geometry is valid
            bool isGeometryValid = await QueuingTaskFactory.StartNew <bool>(() =>
            {
                bool validGeometry = true;

                if (sketchGeometry == null || sketchGeometry.IsEmpty)
                {
                    validGeometry = false;
                }

                return(validGeometry);
            });

            if (!isGeometryValid)
            {
                return(false);
            }

            // get the currently selected features from the map
            // the selected feature uses the above selected geometry
            var currentlySelectedFeature = await MappingModule.ActiveMapView.Map.GetSelectionSetAsync();

            // set up an edit operation
            EditOperation editOperation = new EditOperation();

            editOperation.Name = "Densify selected geometry";

            Geometry densifiedGeometry = null;

            // modify the geometry in the sketch geometry
            // the geometry operation needs to run as it own task
            await QueuingTaskFactory.StartNew(() =>
            {
                // compute a length fur the current geometry when divided into 100 segments
                var segmentLength = GeometryEngine.Length(sketchGeometry) / 100;
                // compute a new densified geometry
                densifiedGeometry = GeometryEngine.Densify(sketchGeometry, segmentLength);
            });

            // for the currently selected feature go through the layers to which the feature belongs
            foreach (var mapMember in currentlySelectedFeature.MapMembers)
            {
                // for each of the selections in the layer (map member)
                foreach (var selectedOID in currentlySelectedFeature[mapMember])
                {
                    // provide the densified geometry for the selected feature as part of the modify operation
                    editOperation.Modify((Layer)mapMember, selectedOID, densifiedGeometry);
                }
            }

            // execute the edit operation and return
            return(await editOperation.ExecuteAsync());
        }
        protected override async void OnClick()
        {
            // make sure there's an OID from a created feature
            if (Module1.CubeMultipatchObjectID == -1)
            {
                return;
            }

            //get the multipatch layer from the map
            var localSceneLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType <FeatureLayer>()
                                  .FirstOrDefault(l => l.Name == "Cube" && l.ShapeType == esriGeometryType.esriGeometryMultiPatch);

            if (localSceneLayer == null)
            {
                return;
            }

            // get the multipatch shape using the Inspector
            var insp = new Inspector();
            await insp.LoadAsync(localSceneLayer, Module1.CubeMultipatchObjectID);

            var multipatchFromScene = insp.Shape as Multipatch;

            // apply textures to the multipatch
            var multipatchWithTextures = ApplyTexturesToMultipatch(multipatchFromScene);


            // modify the multipatch geometry
            string msg = await QueuedTask.Run(() =>
            {
                var op  = new EditOperation();
                op.Name = "Apply textures to multipatch";

                // queue feature modification
                op.Modify(localSceneLayer, Module1.CubeMultipatchObjectID, multipatchWithTextures);
                // execute
                bool result = op.Execute();
                // if successful
                if (result)
                {
                    return("");
                }

                // not successful, return any error message from the EditOperation
                return(op.ErrorMessage);
            });

            // if there's an error, show it
            if (!string.IsNullOrEmpty(msg))
            {
                MessageBox.Show($@"Multipatch update failed: " + msg);
            }
        }
예제 #20
0
        protected override async void OnClick()
        {
            var map = MapView.Active?.Map;

            if (map == null)
            {
                return;
            }
            try
            {
                var lyr = map.GetLayersAsFlattenedList().FirstOrDefault((fl) => fl.Name == LyrNameImport) as FeatureLayer;
                var msg = await QueuedTask.Run(() =>
                {
                    var attribs = new Dictionary <long, Dictionary <string, object> >();
                    using (var cursor = lyr.Search())
                        while (cursor.MoveNext())
                        {
                            using (var feat = cursor.Current as Feature)
                            {
                                var path = feat.GetShape() as Polyline;
                                var ls   = LineBuilder.CreateLineSegment(path.Points[0], path.Points[path.PointCount - 1]);
                                attribs.Add(feat.GetObjectID(), new Dictionary <string, object>()
                                {
                                    { "Direction", ls.Angle }
                                });
                            }
                        }

                    // create an edit operation
                    var editOperation = new EditOperation()
                    {
                        Name = $@"Update {LyrNameImport}"
                    };
                    foreach (var key in attribs.Keys)
                    {
                        editOperation.Modify(lyr, key, attribs[key]);
                    }
                    if (!editOperation.Execute())
                    {
                        return(editOperation.ErrorMessage);
                    }
                    return("update complete");
                });

                MessageBox.Show(msg);
            }
            catch (Exception ex)
            {
                MessageBox.Show($@"Error: {ex}");
            }
        }
        protected void OnNewFloorCreated(long obj, BasicFeatureLayer layer, double verdiepingsHoogte, double buildingZMinValue)
        {
            EditOperation editOperation = new EditOperation();
            var           feature       = layer.Inspect(obj);

            double verdieping = Math.Round(((feature.Shape.Extent.ZMin - buildingZMinValue) / (verdiepingsHoogte * 2)), 0);

            feature["PandHoogte"] = verdiepingsHoogte;
            feature["Verdieping"] = verdieping;
            editOperation.Modify(feature);
            editOperation.Execute();

            MapView.Active.Map.SetSelection(null);
        }
        public static void Difference(this EditOperation editOp, BasicFeatureLayer layer,
                                      long oid, Geometry diffGeom)
        {
            var insp = new Inspector();

            insp.Load(layer, oid);

            //do the difference
            var geom = GeometryEngine.Instance.Difference((Geometry)insp["SHAPE"], diffGeom);

            insp["SHAPE"] = geom;
            //call modify
            editOp.Modify(insp);
        }
        protected void OnExtractWalls(long oid, BasicFeatureLayer layer, Geometry geometry, double verdiepingsHoogte, int verdieping)
        {
            var feature = layer.Inspect(oid);

            feature["PandHoogte"] = verdiepingsHoogte;
            feature["Verdieping"] = verdieping;
            EditOperation editOperation = new EditOperation();

            QueuedTask.Run(() =>
            {
                editOperation.Clip(layer, oid, geometry, ClipMode.DiscardArea);
                editOperation.Modify(feature);
            });
            editOperation.Execute();
        }
예제 #24
0
파일: Main.cs 프로젝트: agrc/TrailsAddin
 private string EnsureIDForSegment(Row row, EditOperation operation)
 {
     if (row[USNG_SEG] == null || (string)row[USNG_SEG] == "" || (string)row[USNG_SEG] == "<Null>")
     {
         var id = GetUSNGID_Line(row);
         operation.Modify(SegmentsLayer, row.GetObjectID(), new Dictionary <string, object> {
             [USNG_SEG] = id
         });
         return(id);
     }
     else
     {
         return((string)row[USNG_SEG]);
     }
 }
예제 #25
0
        /// <summary>
        /// Called when the sketch finishes. This is where we will create the sketch operation and then execute it.
        /// </summary>
        /// <param name="geometry">The geometry created by the sketch.</param>
        /// <returns>A Task returning a Boolean indicating if the sketch complete event was successfully handled.</returns>
        protected override Task <bool> OnSketchCompleteAsync(Geometry geometry)
        {
            if (geometry == null)
            {
                return(Task.FromResult(false));
            }

            var featureLayer = MapView.Active.GetSelectedLayers()[0] as FeatureLayer;

            if (featureLayer == null)
            {
                MessageBox.Show("Please ensure that the selected layer is a feature layer.");
                return(Task.FromResult(false));
            }

            return(QueuedTask.Run(() =>
            {
                var desiredField = featureLayer.GetFieldDescriptions().Where(fldDesc => fldDesc.Name == "Comments").FirstOrDefault();

                if (desiredField == null)
                {
                    MessageBox.Show("No field with Name 'Comments' found.");
                    return Task.FromResult(false);
                }

                var features = MapView.Active.GetFeatures(geometry);
                if (features.Count == 0)
                {
                    return Task.FromResult(false);
                }

                var featureOIDs = features.Where(results => results.Key == featureLayer).Select(results => results.Value).First();

                var featureInspector = new Inspector(true);
                featureInspector.Load(featureLayer, featureOIDs);
                featureInspector["Comments"] = "ArcGIS Pro SDK Sample";

                var modifyOperation = new EditOperation();
                modifyOperation.Name = "Update attribute";
                modifyOperation.SelectModifiedFeatures = true;
                modifyOperation.SelectNewFeatures = false;

                modifyOperation.Modify(featureInspector);

                // apply the edits
                return modifyOperation.ExecuteAsync();
            }));
        }
예제 #26
0
        protected override async Task <bool> OnSketchCompleteAsync(Geometry geometry)
        {
            if (_pointLayer == null)
            {
                return(true);
            }

            // execute the select on the MCT
            var result = await QueuedTask.Run(() =>
            {
                // define the spatial query filter
                var spatialQuery = new SpatialQueryFilter()
                {
                    FilterGeometry = geometry, SpatialRelationship = SpatialRelationship.Contains
                };

                // gather the selection
                var pointSelection = _pointLayer.Select(spatialQuery);

                // get the list of oids
                List <long> oids = pointSelection.GetObjectIDs().ToList();
                if (oids.Count == 0)
                {
                    return(false);
                }

                // if some attributes aren't valid
                if (_attributesValid.ContainsValue(false))
                {
                    return(false);
                }

                // everything is valid - apply to the identified features
                var editOp  = new EditOperation();
                editOp.Name = "Apply edits";
                foreach (var oid in oids)
                {
                    editOp.Modify(_pointLayer, oid, _attributes);
                }
                editOp.Execute();

                return(true);
            });

            return(result);
        }
        protected override void OnToolMouseDown(MapViewMouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                int    aantalVerdiepingen = 10;
                double verdiepingsHoogte;

                QueuedTask.Run(() =>
                {
                    var point = MapPointBuilder.CreateMapPoint(e.ClientPoint.X, e.ClientPoint.Y);
                    var selectedLayerFeatures = MapView.Active.GetFeatures(point, true);
                    var selectedItems         = selectedLayerFeatures.ToDictionary(x => x.Key as MapMember, x => x.Value);

                    var op = new EditOperation();
                    foreach (KeyValuePair <MapMember, List <long> > item in selectedItems)
                    {
                        var layer = item.Key as BasicFeatureLayer;

                        foreach (long oid in item.Value)
                        {
                            var feature           = layer.Inspect(oid);
                            verdiepingsHoogte     = double.Parse(feature["PandHoogte"].ToString()) / aantalVerdiepingen;
                            feature["PandHoogte"] = verdiepingsHoogte;
                            feature["Verdieping"] = aantalVerdiepingen;

                            op.Modify(feature);
                            bool succes = op.Execute();

                            op = new EditOperation();
                            if (succes)
                            {
                                for (int i = 1; i < aantalVerdiepingen; i++)
                                {
                                    op.Duplicate(layer, feature.ObjectID, 0, 0, (i * (verdiepingsHoogte * 2)));
                                }
                            }
                        }
                    }
                    bool succeded = op.Execute();

                    MapView.Active.Map.SetSelection(null);
                });
            }
            base.OnToolMouseDown(e);
        }
        protected override void OnClick()
        {
            if (Module1.Current.SelectedItems == null)
            {
                return;
            }

            int    aantalVerdiepingen;
            double verdiepingsHoogte;

            QueuedTask.Run(() =>
            {
                var op = new EditOperation();
                foreach (KeyValuePair <MapMember, List <long> > item in Module1.Current.SelectedItems)
                {
                    var layer = item.Key as BasicFeatureLayer;

                    foreach (long oid in item.Value)
                    {
                        var feature           = layer.Inspect(oid);
                        aantalVerdiepingen    = new Random().Next(3, 10);
                        verdiepingsHoogte     = double.Parse(feature["PandHoogte"].ToString()) / aantalVerdiepingen;
                        feature["PandHoogte"] = verdiepingsHoogte;

                        op.Modify(feature);
                        bool succes = op.Execute();

                        op = new EditOperation();
                        if (succes)
                        {
                            for (int i = 1; i < aantalVerdiepingen; i++)
                            {
                                op.Duplicate(layer, feature.ObjectID, 0, 0, (i * (verdiepingsHoogte * 2)));
                            }
                        }
                    }
                }
                bool succeded = op.Execute();

                Module1.Current.SelectedItems.Clear();
                MapView.Active.Map.SetSelection(null);
            });
        }
        private async void DoChange()
        {
            var crimes = Module1.Current.Crimes;

            if (NoCrimes(crimes))
            {
                return;
            }

            bool noSelect = true;
            var  editOp   = new EditOperation();

            editOp.Name = $"Change {Module1.Current.CrimesLayerName}";
            editOp.SelectModifiedFeatures = true;

            await QueuedTask.Run(() =>
            {
                using (var select = crimes.GetSelection())
                {
                    if (select.GetCount() > 0)
                    {
                        noSelect = false;
                        foreach (var oid in select.GetObjectIDs())
                        {
                            //change an attribute
                            Dictionary <string, object> attributes = new Dictionary <string, object>();
                            attributes["POLICE_DISTRICT"]          = "999";
                            editOp.Modify(crimes, oid, attributes);
                        }
                        editOp.Execute();
                    }
                }
            });

            if (noSelect)
            {
                NothingSelected();
            }
        }
예제 #30
0
        protected override Task HandleMouseDownAsync(MapViewMouseButtonEventArgs e)
        {
            return(QueuedTask.Run(() =>
            {
                var mapClickPnt = MapView.Active.ClientToMap(e.ClientPoint);
                double elevation = mapClickPnt.Z;

                var featLayer = MapView.Active.Map.FindLayers("Clip_Polygon_Asphalt").FirstOrDefault() as FeatureLayer;

                // Get the selected records, and check/exit if there are none.
                var featSelectionOIDs = featLayer.GetSelection().GetObjectIDs();
                if (featSelectionOIDs.Count == 0)
                {
                    MessageBox.Show("No features selected for layer, " + featLayer.Name + ". Elevation not applied. Exiting...", "Info");
                    return;
                }

                // Edit elevation for any/all selected polygons, and reset any existing calculated Volume and SArea values to null.
                var inspector = new ArcGIS.Desktop.Editing.Attributes.Inspector(true);
                inspector.Load(featLayer, featSelectionOIDs);
                inspector["PlaneHeight"] = elevation;
                inspector["Volume"] = null;
                inspector["SArea"] = null;
                inspector["EstWeightInTons"] = null;
                var editOp = new EditOperation
                {
                    Name = $@"Edit {featLayer.Name}, {featSelectionOIDs.Count} records."
                };
                editOp.Modify(inspector);
                editOp.ExecuteAsync();
                Project.Current.SaveEditsAsync();

                Module1.SceneCalcVM.ReferencePlaneElevation = elevation;
                // Refresh the selection
                Module1.Current.FeatureSelectionChanged();
            }));
        }
        private void BlowUpBuilding(MapViewMouseButtonEventArgs e)
        {
            int    aantalVerdiepingen;
            double verdiepingsHoogte;

            QueuedTask.Run(() =>
            {
                Dictionary <MapMember, List <long> > selectedItems = GetSelectedItems(e);
                EditOperation editOperation = new EditOperation();
                foreach (KeyValuePair <MapMember, List <long> > item in selectedItems)
                {
                    BasicFeatureLayer layer = item.Key as BasicFeatureLayer;
                    if (layer.ShapeType != ArcGIS.Core.CIM.esriGeometryType.esriGeometryPolygon)
                    {
                        continue;
                    }

                    foreach (long oid in item.Value)
                    {
                        var feature        = layer.Inspect(oid);
                        aantalVerdiepingen = new Random().Next(3, 10);
                        verdiepingsHoogte  = double.Parse(feature["PandHoogte"].ToString()) / aantalVerdiepingen;

                        double buildingZMinValue = feature.Shape.Extent.ZMin;
                        feature["PandHoogte"]    = verdiepingsHoogte;
                        editOperation.Modify(feature);
                        for (int i = 1; i < aantalVerdiepingen; i++)
                        {
                            var newFloorGeometry = GeometryEngine.Move(feature.Shape, 0, 0, (i * (verdiepingsHoogte * 2)));
                            editOperation.Create(layer, newFloorGeometry, new Action <long>(x => OnNewFloorCreated(x, layer, verdiepingsHoogte, buildingZMinValue)));
                        }
                    }
                }
                bool succeded = editOperation.Execute();
            });
        }
예제 #32
0
        public async void CalculateVolume()
        {
            // Update the viewmodel with values
            await FrameworkApplication.SetCurrentToolAsync("esri_mapping_exploreTool");

            // Check for an active mapview
            if (MapView.Active == null)
            {
                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("No MapView currently active. Exiting...", "Info");
                return;
            }

            // Prompt before proceeding with calculation work
            var response = ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Save edits and calculate volume on selected features?", "Calculate Volume", System.Windows.MessageBoxButton.YesNo, System.Windows.MessageBoxImage.Question);

            if (response == MessageBoxResult.No)
            {
                return;
            }

            // Save edits for reading by GP Tool
            await Project.Current.SaveEditsAsync();

            try
            {
                await QueuedTask.Run((Func <Task>)(async() =>
                {
                    var featLayer = MapView.Active.Map.FindLayers("Clip_Polygon_Asphalt").FirstOrDefault() as FeatureLayer;

                    // Get the selected records, and check/exit if there are none:
                    var featSelectionOIDs = featLayer.GetSelection().GetObjectIDs();
                    if (featSelectionOIDs.Count == 0)
                    {
                        ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("No records selected for layer, " + featLayer.Name + ". Exiting...", "Info");
                        return;
                    }

                    // Ensure value for reference plane direction combobox
                    else if (SceneCalcVM.ReferencePlaneDirection == string.Empty)
                    {
                        ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Choose the reference plane direction for volume calculation. Exiting...", "Value Needed");
                        return;
                    }

                    // Ensure there is a valid reference plane height/elevation value for all selected records
                    RowCursor cursorPolygons = featLayer.GetSelection().Search(null);
                    while (cursorPolygons.MoveNext())
                    {
                        using (Row currentRow = cursorPolygons.Current)
                        {
                            // Get values for dockpane
                            if (currentRow["PlaneHeight"] == null || Convert.ToDouble(currentRow["PlaneHeight"]) == 0)
                            {
                                string currentObjectID = Convert.ToString(currentRow["ObjectID"]);
                                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Empty or invalid Plane Height value for polygon ObjectID: " + currentObjectID + ". Exiting...", "Value Needed");
                                return;
                            }
                        }
                    }

                    // Get the name of the attribute to update, and the value to set:
                    double refPlaneElevation = SceneCalcVM.ReferencePlaneElevation;
                    string refPlaneDirection = SceneCalcVM.ReferencePlaneDirection;

                    // Start progress dialog
                    var progDialog = new ProgressDialog("Calculating Volume");
                    var progSource = new ProgressorSource(progDialog);
                    progDialog.Show();

                    // Prepare for run of GP tool -- Get the path to the LAS point layer
                    string surfaceLASDataset = "Asphalt3D_132_point_cloud.las";
                    var inspector            = new ArcGIS.Desktop.Editing.Attributes.Inspector(true);
                    inspector.Load(featLayer, featSelectionOIDs);
                    inspector["PlaneDirection"]    = refPlaneDirection;
                    inspector["DateOfCapture"]     = DateTime.Today;
                    inspector["ElevationMeshFile"] = "Asphalt3D_132_3d_mesh.slpk";
                    inspector["PointCloudFile"]    = surfaceLASDataset;

                    var editOp  = new EditOperation();
                    editOp.Name = "Edit " + featLayer.Name + ", " + Convert.ToString(featSelectionOIDs.Count) + " records.";
                    editOp.Modify(inspector);
                    await editOp.ExecuteAsync();
                    await Project.Current.SaveEditsAsync();

                    // Get the path to the layer's feature class
                    string infc = featLayer.Name;
                    // Place parameters into an array
                    var parameters = Geoprocessing.MakeValueArray(surfaceLASDataset, infc, "PlaneHeight", refPlaneDirection);
                    // Place environment settings in an array, in this case, OK to over-write
                    var environments = Geoprocessing.MakeEnvironmentArray(overwriteoutput: true);
                    // Execute the GP tool with parameters
                    var gpResult = await Geoprocessing.ExecuteToolAsync("PolygonVolume_3d", parameters, environments);
                    // Save edits again
                    await Project.Current.SaveEditsAsync();

                    // var selFeatures = featLayer.GetSelection().GetCount();
                    RowCursor cursorPolygons2 = featLayer.GetSelection().Search(null);

                    double totalVolumeValue  = 0;
                    double totalAreaValue    = 0;
                    double totalWeightInTons = 0;
                    double currentVolume;
                    double currentSArea;
                    double currentWeightInTons;
                    long currentOID;

                    while (cursorPolygons2.MoveNext())
                    {
                        using (Row currentRow = cursorPolygons2.Current)
                        {
                            // Get values for dockpane
                            currentOID = currentRow.GetObjectID();
                            // Convert volume in cubic meters from source data to cubic feet:
                            currentVolume = Convert.ToDouble(currentRow["Volume"]) * 35.3147;
                            // Convert surface area value from square meters from source data to square feet:
                            currentSArea = Convert.ToDouble(currentRow["SArea"]) * 10.7639;
                            // Calculate estimated weight in tons = (volume in square foot * 103.7 pounds per square foot) / 2000 pounds per ton
                            currentWeightInTons = (currentVolume * 103.7) / 2000;

                            // Update the new cubic feet and square feet values for the feature:
                            inspector.Load(featLayer, currentOID);
                            inspector["Volume"]          = currentVolume;
                            inspector["SArea"]           = currentSArea;
                            inspector["EstWeightInTons"] = currentWeightInTons;
                            await inspector.ApplyAsync();

                            // Combine values for display of total volume and surface area values in the dockpane:
                            totalVolumeValue  = totalVolumeValue + currentVolume;
                            totalAreaValue    = totalAreaValue + currentSArea;
                            totalWeightInTons = totalWeightInTons + currentWeightInTons;
                        }
                    }

                    // Apply the values and refresh selection update
                    await Project.Current.SaveEditsAsync();
                    FeatureSelectionChanged();
                    // Close progress dialog
                    progDialog.Hide();
                    progDialog.Dispose();
                }));
            }
            catch (Exception exc)
            {
                // Catch any exception found and display a message box.
                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Exception caught while trying to perform update: " + exc.Message);
                return;
            }
        }
        private void saveTableEdits()
        {
            if (MapView.Active == null)
            {
                return;
            }

            QueuedTask.Run(() =>
            {
                // Check to see if there is a selected feature layer
                var featLayer = MapView.Active.Map.GetLayersAsFlattenedList().FirstOrDefault(l => l.Name == SelectedFeatureLayer) as FeatureLayer;
                if (featLayer == null)
                {
                    return;
                }
                // Get the selected records, and check/exit if there are none:
                var featSelectionOIDs = featLayer.GetSelection().GetObjectIDs();
                if (featSelectionOIDs.Count == 0 || featSelectionOIDs.Count > 1)
                {
                    return;
                }

                try
                {
                    var inspector = new ArcGIS.Desktop.Editing.Attributes.Inspector(true);
                    inspector.Load(featLayer, featSelectionOIDs);

                    if (inspector.HasAttributes)
                    {
                        if (inspector.Count(a => a.FieldName.ToUpper() == "type_couv1") > 0)
                        {
                            inspector["type_couv1"] = _dataNaipf2019.TxtTbType1;
                        }

                        var editOp  = new EditOperation();
                        editOp.Name = "Edit " + featLayer.Name + ", " + Convert.ToString(featSelectionOIDs.Count) + " records.";
                        editOp.Modify(inspector);
                        editOp.ExecuteAsync();

                        //MessageBox.Show("Update operation completed.", "Editing with Inspector");
                    }
                    else
                    {
                        //MessageBox.Show("The Attribute provided is not valid. " +
                        //    "\r\n Ensure your attribute name is correct.", "Invalid attribute");
                        // return;
                    }
                }
                catch (Exception exc)
                {
                    // Catch any exception found and display a message box.
                    MessageBox.Show("Exception caught: " + exc.Message);
                    return;
                }
                finally
                {
                    if (Project.Current.HasEdits)
                    {
                        Project.Current.SaveEditsAsync();
                    }
                }
            });
        }
        /// <summary>
        /// Method to perform the cut operation on the geometry and change attributes
        /// </summary>
        /// <param name="geometry">Line geometry used to perform the cut against in the polygon features
        /// in the active map view.</param>
        /// <returns>If the cut operation was successful.</returns>
        protected Task<bool> ExecuteCut(Geometry geometry)
        {
            if (geometry == null)
                return Task.FromResult(false);

            // create an edit operation
            EditOperation cutOperation = new EditOperation();
            cutOperation.Name = "Cut Elements";
            cutOperation.ProgressMessage = "Working...";
            cutOperation.CancelMessage = "Operation canceled.";
            cutOperation.ErrorMessage = "Error cutting polygons";
            cutOperation.SelectModifiedFeatures = false;
            cutOperation.SelectNewFeatures = false;

            // create a collection of feature layers that can be edited
            var editableLayers = ActiveMapView.Map.GetLayersAsFlattenedList()
                .OfType<FeatureLayer>()
                .Where(lyr => lyr.CanEditData() == true).Where(lyr =>
                lyr.ShapeType == esriGeometryType.esriGeometryPolygon);

            // ensure that there are target layers
            if (editableLayers.Count() == 0)
                return Task.FromResult(false);

            // initialize a list of ObjectIDs that need to be cut
            var cutOIDs = new List<long>();

            // for each of the layers 
            foreach (FeatureLayer editableFeatureLayer in editableLayers)
            {
                // find the features crossed by the sketch geometry
                var rowCursor = editableFeatureLayer.Search(geometry, SpatialRelationship.Crosses);

                // get the feature class associated with the layer
                Table fc = editableFeatureLayer.GetTable();

                // find the field index for the 'Description' attribute
                int descriptionIndex = -1;
                descriptionIndex = fc.GetDefinition().FindField("Description");

                // add the feature IDs into our prepared list
                while (rowCursor.MoveNext())
                {
                    var feature = rowCursor.Current as Feature;
                    if (feature.GetShape() != null)
                    {
                        // we are looking for polygons are completely intersected by the cut line
                        if (GeometryEngine.Relate(geometry, feature.GetShape(), "TT*F*****"))
                        {
                            // add the current feature to the overall list of features to cut
                            cutOIDs.Add(rowCursor.Current.GetObjectID());

                            // adjust the attribute before the cut
                            if (descriptionIndex != -1)
                                cutOperation.Modify(rowCursor.Current, descriptionIndex, "Pro Sample");
                        }
                    }
                }
                // add the elements to cut into the edit operation
                cutOperation.Cut(editableFeatureLayer, cutOIDs, geometry);
            }

            //execute the operation
            var operationResult = cutOperation.Execute();

            return Task.FromResult(operationResult);
        }
        /// <summary>
        /// This function takes the selected features in the map view, finds the first field of type string in the each feature class
        /// and modifies the attribute value to a random string.
        /// </summary>
        /// <returns>Indicator if the edit operation was successful.</returns>
        private async Task<bool> PerformAttributeChange()
        {
            try
            {
                // retrieve the currently selected features in the map view            
                var currentSelectedFeatures = await QueuedTask.Run(() =>
                {
                    return MapView.Active.Map.GetSelection();
                });

                // for each of the map members in the selected layers
                foreach (var mapMember in currentSelectedFeatures)
                {
                    var featureLayer = mapMember.Key as BasicFeatureLayer;
                    // .. get the underlying table
                    var table = await QueuedTask.Run(() =>
                    {
                        return featureLayer.GetTable();
                    });

                    // retrieve the first field of type string
                    var stringField = table.GetFieldByTypeAsync(FieldType.String).Result;
                    var stringFieldName = stringField != null ? stringField.Name : String.Empty;

                    // check if the returned string of the field name actually contains something
                    // meaning if the current MapMember actually contains a field of type string
                    if (String.IsNullOrEmpty(stringFieldName))
                        continue;

                    #region Use edit operations for attribute changes
                    // create a new edit operation to encapsulate the string field modifications
                    var modifyStringsOperation = new EditOperation
                    {
                        Name = String.Format("Modify string field '{0}' in layer {1}.", stringFieldName, mapMember.Key.Name)
                    };
                    ICollection<long> oidSet = new List<long>();
                    var iCnt = 0;
                    // with each ObjectID of the selected feature
                    foreach (var oid in currentSelectedFeatures[mapMember.Key])
                    {
                        // set up a new dictionary with fields to modify
                        var modifiedAttributes = new Dictionary<string, object>
                        {
                            // add the name of the string field and the new attribute value to the dictionary
                            // in this example a random string is used
                            {stringFieldName, string.Format("Update {0} on: {1:s}", ++iCnt, DateTime.Now)}
                        };

                        // put the modify operation on the editor stack
                        modifyStringsOperation.Modify(mapMember.Key, oid, modifiedAttributes);
                        oidSet.Add(oid);
                    }

                    // execute the modify operation to apply the changes
                    await modifyStringsOperation.ExecuteAsync();
                    #endregion

                    #region Use the feature inspector for attribute changes
#if OrUseThis
                    // as an alternative approach
                    // use the feature inspector class
                    var featureInspector = new Inspector(true);

                    // fill the feature inspector with the oids from the feature layer               
                    await featureInspector.LoadAsync(mapMember.Key, currentSelectedFeatures[mapMember.Key]);

                    // change the attribute value for the string field
                    featureInspector[stringFieldName] = Path.GetRandomFileName().Replace(".", "");

                    // app. the new values
                    await featureInspector.ApplyAsync();
#endif
                    #endregion
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occurred while updating attribute column data {0}", ex.ToString());
            }
            return true;
        }