Use the moving element to select Features

Source: Internet
Author: User
Using System;
Using System. Collections. Generic;
Using System. ComponentModel;
Using System. Data;
Using System. Drawing;
Using System. Text;
Using System. Windows. Forms;
Using ESRI. ArcGIS. DataSourcesGDB;
Using ESRI. ArcGIS. esriSystem;
Using ESRI. ArcGIS. Geodatabase;
Using ESRI. ArcGIS. Carto;
Using ESRI. ArcGIS. Geometry;
Using ESRI. ArcGIS. Display;

Namespace WindowsApplication1
Public partial class Form1: Form
Public Form1 ()
InitializeComponent ();

Private void button#click (object sender, EventArgs e)
IPropertySet pPS = new PropertySetClass ();
IWorkspaceFactory pWF = new SdeWorkspaceFactoryClass ();
PPS. SetProperty ("Server", "8b63161cdae4488 ");
PPS. SetProperty ("Instance", "5159 ");
PPS. SetProperty ("Database", "TestElementEdit ");
PPS. SetProperty ("User", "sde ");
PPS. SetProperty ("Password", "zhangjun1130 ");
PPS. SetProperty ("Version", "sde. default ");
IWorkspace pWs = pWF. Open (pPS, 0 );
IFeatureWorkspace pFWs = pWs as IFeatureWorkspace;

IFeatureClass pFC = pFWs. OpenFeatureClass ("ElementEdit ");
IFeatureLayer pFL = new FeatureLayerClass ();
PFL. FeatureClass = pFC;

AxMapControl1.AddLayer (pFL );


Private void axmapcontrolpoliconmousedown (object sender, ESRI. ArcGIS. Controls. IMapControlEvents2_OnMouseDownEvent e)

If (radioButton3.Checked = true)
Ipolympus Gon pPolygon = (ipolympus gon) axMapControl1.TrackPolygon ();
IGraphicsContainer pGC = (IGraphicsContainer) axMapControl1.Map;
IActiveView pActiver = (IActiveView) axMapControl1.Map;
Ipolympus element pPolygonElement = new PolygonElementClass ();
IElement pElement = (IElement) pPolygonElement;
IElementEditVertices pElementEditVertices = (IElementEditVertices) pPolygonElement;
PElement. Geometry = pPolygon;
PGC. AddElement (pElement, 0 );
PActiver. Refresh ();
PElementEditVertices. MovingVertices = true;
// ISelectionTracker pST = null;
// PElementEditVertices. GetMoveVerticesSelectionTracker ();


Private void axmapcontrolpoliconmouseup (object sender, ESRI. ArcGIS. Controls. IMapControlEvents2_OnMouseUpEvent e)
If (radioButton1.Checked = true)
IGraphicsContainer pGC = (IGraphicsContainer) axMapControl1.Map;
IGraphicsContainerSelect pGCS = (IGraphicsContainerSelect) pGC;
IEnumElement pEE = pGCS. SelectedElements;
IElement pE = pEE. Next ();
IElementEditVertices pEEV = pE as IElementEditVertices;
PEEV. MovingVertices = true;
ISpatialFilter pSF = new SpatialFilterClass ();
PSF. GeometryField = "Shape ";
PSF. Geometry = pE. Geometry;
PSF. SpatialRel = esriSpatialRelEnum. esriSpatialRelIntersects;

IFeatureSelection pFS = axMapControl1.Map. get_Layer (0) as IFeatureSelection;
PFS. SelectFeatures (pSF, esriSelectionResultEnum. esriSelectionResultNew, false );
(AxMapControl1.Map as IActiveView). Refresh ();

ISelection pS = axMapControl1.Map. FeatureSelection;
IEnumFeature FFE = (IEnumFeature) pS;
Int I = 0;
IFeature pF = Arg. Next ();
While (pF! = Null)
I ++;
PF = Arg. Next ();
MessageBox. Show (I. ToString ());


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.