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 ());
}
}
}
}