Turn from original arcengine data edit--Select features
For a long time did not write blog, this period of relatively free, the AE data editing implementation summary.
To edit a feature, first select the feature, press the SHIFT key to make multiple selections, and press ESC to clear the selection.
There are two ways to highlight an individual's choices, both in the public override void OnMouseDown (int Button, int Shift, int X, int Y) events in the implementation:
1, ifeatureselection This requires a clear selection of the layer
IPoint PPoint =PActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint (X, Y); Ienvelope Penvelope;DoubleTol = -;p Envelope=Ppoint.envelope;penvelope.width= Penvelope.width +Tol;penvelope.height= Penvelope.height +Tol;penvelope.centerat (ppoint); Ispatialfilter Pspatialfilter;pspatialfilter=NewSpatialfilterclass ();p spatialfilter.geometry=Penvelope;pspatialfilter.spatialrel=esrispatialrelenum.esrispatialrelintersects;ifeatureselection pfeatureselection;pfeatureselection= Ucdrawpanel.currentfeaturelayer asifeatureselection;ifeature pfeature;ucdrawpanel.unionfeature=NewList<ifeature> ();//instantiating a merged feature setif(Shift = =1){ if(UcDrawPanel.currentFeatureLayer.FeatureClass.ShapeType = =esrigeometrytype.esrigeometrypolyline) {pfeatureselection.selectfeatures (Pspatialfilter, EsriSe Lectionresultenum.esriselectionresultadd,true); ICursor Pcursor; PFeatureSelection.SelectionSet.Search (NULL,false, outpcursor); }}Else{pActiveView.FocusMap.ClearSelection (); Pfeatureselection.selectfeatures (Pspatialfilter, Esriselectionresultenum.esriselectionresultnew,true); ICursor Pcursor; PFeatureSelection.SelectionSet.Search (NULL,false, outpcursor); }pactiveview.partialrefresh (Esriviewdrawphase.esriviewgeoselection, Ucdrawpanel.currentfeaturelayer,NULL);//Highlight Itisimplefillsymbol ifillsymbol;isymbol isymbol;irgbcolor irgbcolor;ifillsymbol=NewSimplefillsymbol (); Ifillsymbol.style=Esrisimplefillstyle.esrisfssolid;irgbcolor=NewRgbColor (); Irgbcolor.green= -; Ifillsymbol.color=Irgbcolor;isymbol=(isymbol) ifillsymbol;isymbol.rop2=Esrirasteropcode.esriropnotxorpen; Ienumfeature penumfeature= PActiveView.FocusMap.FeatureSelection asIenumfeature;penumfeature.reset ();p feature=Penumfeature.next ();//highlight highlighting for selected featuresif(Pfeature! =NULL) {igeometry pgeometry=Pfeature.shape; Itopologicaloperator Ptop= Pgeometry asItopologicaloperator; while(Pfeature! =NULL) {ucDrawPanel.unionFeature.Add (pfeature); Pgeometry=ptop.union (Pfeature.shape); Ptop= Pgeometry asItopologicaloperator; Pfeature=Penumfeature.next (); } ucdrawpanel.currentfeature= Ucdrawpanel.unionfeature[ucdrawpanel.unionfeature.count-1]; _mapctrl.flashshape (Pgeometry,1, -, Isymbol);}//Clear Selection FeaturesElse{pActiveView.FocusMap.ClearSelection (); Pactiveview.partialrefresh (Esriviewdrawphase.esriviewgeoselection,NULL, pactiveview.extent);}
2, Selectbymap based on the entire map, of course, you can also first set the layer's selectable property under Dynamic settings
if(Button = =1){ //clear the Map view_mapctrl.map.clearselection (); Igraphicscontainer Pcontainer= _mapctrl.map asIgraphicscontainer; Pcontainer.deleteallelements (); _mapctrl.activeview.refresh (); Base. OnMouseDown (Button, Shift, X, Y); Iactiveview Pactiveview=_mapctrl.activeview; IPoint PPoint=PActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint (X, Y); IPoint Temppoint= PActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint (X +5, Y +5); Ienvelope Objenvelope; DoubleTol = Math.Abs (Temppoint.x-ppoint.x); Objenvelope=Ppoint.envelope; Objenvelope.width= Objenvelope.width +Tol; Objenvelope.height= Objenvelope.height +Tol; Objenvelope.centerat (PPoint); Setselectable (ucdrawpanel.currentlayername);//only the current edit layer is selectable_mapctrl.map.selectbyshape (igeometry) Objenvelope,NULL,true);//Select only one featurePactiveview.partialrefresh (Esriviewdrawphase.esriviewgeoselection,NULL, _mapctrl.activeview.extent); Ucdrawpanel.currentfeaturelayer=getlayerbyname (_mapctrl, ucdrawpanel.currentlayername); if(Ucdrawpanel.currentfeaturelayer! =NULL) {ucdrawpanel.currentfeature=getfeaturebyselection (Ucdrawpanel.currentfeaturelayer); } Else{Messwin Messwin=NewMesswin (); Messwin.settitleandmess ("Tips",@"error getting selection features! ",false); return; }}
Ps:esc key exit, implemented in onkeydown Event
Public Override void OnKeyDown (intint Shift) { if (keycode = = (int) keys.escape) { = _mapctrl.activeview; PActiveView.FocusMap.ClearSelection (); NULL , pactiveview.extent); NULL ; }}
Arcengine data Editing-selecting features