1
ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);
ESRI.ArcGIS.RuntimeManager.BindLicense(ESRI.ArcGIS.ProductCode.Engine);
2
axMapControl1.MousePointer = esriControlsMousePointer.esriPointerHourglass;
axMapControl1.LoadMxFile(filePath, 0, Type.Missing);
axMapControl1.MousePointer = esriControlsMousePointer.esriPointerDefault;
layer = axMapControl1.Map.get_Layer(i);
3
IFeatureLayer featureLayer = layer as IFeatureLayer;
IFeatureClass featureClass = featureLayer.FeatureClass;
IDataset dataset = (IDataset)featureClass;
IWorkspace workspace = dataset.Workspace;
IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;
workspaceEdit.StartEditing(true);
workspaceEdit.StartEditOperation();
IFeatureBuffer featureBuffer = featureClass.CreateFeatureBuffer();
IFeatureCursor featureCursor;
featureCursor = featureClass.Search(null, true);
IFeature feature;
feature = featureCursor.NextFeature();
while (feature!=null)
{
feature.Delete();
feature = featureCursor.NextFeature();
}
featureCursor = featureClass.Insert(true);
featureBuffer.Shape = geometry;
object featureOID = featureCursor.InsertFeature(featureBuffer);
featureCursor.Flush();
workspaceEdit.StopEditOperation();
workspaceEdit.StopEditing(true);
System.Runtime.InteropServices.Marshal.ReleaseComObject (featureCursor);
4
IGeometryCollection geometryCollection = new MultipointClass();
IMultipoint multipoint;
object missing = Type.Missing;
IPoint point;
for (int i = 0; i < 10; i++)
{
point = new PointClass();
point.PutCoords(i * 2, i * 2);
geometryCollection.AddGeometry(point as IGeometry, ref missing, ref missing);
}
multipoint = geometryCollection as IMultipoint;
addFeature("multipoint", multipoint as IGeometry);
this.axMapControl1.Extent = multipoint.Envelope;
this.axMapControl1.Refresh();
5
IRgbColor rgbColor;
rgbColor = new RgbColorClass();
rgbColor.Red = 255;
rgbColor.Green = 255;
rgbColor.Blue = 0;
object symbol = null;
if (geometry.GeometryType == esriGeometryType.esriGeometryPolyline ||
geometry.GeometryType == esriGeometryType.esriGeometryLine)
{
ISimpleLineSymbol simpleLineSymbol;
simpleLineSymbol = new SimpleLineSymbolClass();
simpleLineSymbol.Color = rgbColor;
simpleLineSymbol.Width = 5;
symbol = simpleLineSymbol;
}
else
{
ISimpleFillSymbol simpleFillSymbol;
simpleFillSymbol = new SimpleFillSymbolClass();
simpleFillSymbol.Color = rgbColor;
symbol = simpleFillSymbol;
}
axMapControl1.DrawShape(geometry, ref symbol);
6
ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
switch (style)
{
case "Solid":
simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
break;
case "Dashed":
simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDash;
break;
case "Dotted":
simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDot;
break;
case "Dash-Dot":
simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDot;
break;
case "Dash-Dot-Dot":
simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDotDot;
break;
case "null":
simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSNull;
break;
}
simpleLineSymbol.Width = width;
IRgbColor rgbColor = getRGB(color.R, color.G, color.B);
simpleLineSymbol.Color = rgbColor;
return simpleLineSymbol;
ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);
ESRI.ArcGIS.RuntimeManager.BindLicense(ESRI.ArcGIS.ProductCode.Engine);
2
axMapControl1.MousePointer = esriControlsMousePointer.esriPointerHourglass;
axMapControl1.LoadMxFile(filePath, 0, Type.Missing);
axMapControl1.MousePointer = esriControlsMousePointer.esriPointerDefault;
layer = axMapControl1.Map.get_Layer(i);
3
IFeatureLayer featureLayer = layer as IFeatureLayer;
IFeatureClass featureClass = featureLayer.FeatureClass;
IDataset dataset = (IDataset)featureClass;
IWorkspace workspace = dataset.Workspace;
IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;
workspaceEdit.StartEditing(true);
workspaceEdit.StartEditOperation();
IFeatureBuffer featureBuffer = featureClass.CreateFeatureBuffer();
IFeatureCursor featureCursor;
featureCursor = featureClass.Search(null, true);
IFeature feature;
feature = featureCursor.NextFeature();
while (feature!=null)
{
feature.Delete();
feature = featureCursor.NextFeature();
}
featureCursor = featureClass.Insert(true);
featureBuffer.Shape = geometry;
object featureOID = featureCursor.InsertFeature(featureBuffer);
featureCursor.Flush();
workspaceEdit.StopEditOperation();
workspaceEdit.StopEditing(true);
System.Runtime.InteropServices.Marshal.ReleaseComObject (featureCursor);
4
IGeometryCollection geometryCollection = new MultipointClass();
IMultipoint multipoint;
object missing = Type.Missing;
IPoint point;
for (int i = 0; i < 10; i++)
{
point = new PointClass();
point.PutCoords(i * 2, i * 2);
geometryCollection.AddGeometry(point as IGeometry, ref missing, ref missing);
}
multipoint = geometryCollection as IMultipoint;
addFeature("multipoint", multipoint as IGeometry);
this.axMapControl1.Extent = multipoint.Envelope;
this.axMapControl1.Refresh();
5
IRgbColor rgbColor;
rgbColor = new RgbColorClass();
rgbColor.Red = 255;
rgbColor.Green = 255;
rgbColor.Blue = 0;
object symbol = null;
if (geometry.GeometryType == esriGeometryType.esriGeometryPolyline ||
geometry.GeometryType == esriGeometryType.esriGeometryLine)
{
ISimpleLineSymbol simpleLineSymbol;
simpleLineSymbol = new SimpleLineSymbolClass();
simpleLineSymbol.Color = rgbColor;
simpleLineSymbol.Width = 5;
symbol = simpleLineSymbol;
}
else
{
ISimpleFillSymbol simpleFillSymbol;
simpleFillSymbol = new SimpleFillSymbolClass();
simpleFillSymbol.Color = rgbColor;
symbol = simpleFillSymbol;
}
axMapControl1.DrawShape(geometry, ref symbol);
6
ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
switch (style)
{
case "Solid":
simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
break;
case "Dashed":
simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDash;
break;
case "Dotted":
simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDot;
break;
case "Dash-Dot":
simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDot;
break;
case "Dash-Dot-Dot":
simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDotDot;
break;
case "null":
simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSNull;
break;
}
simpleLineSymbol.Width = width;
IRgbColor rgbColor = getRGB(color.R, color.G, color.B);
simpleLineSymbol.Color = rgbColor;
return simpleLineSymbol;