ArcGIS Engine 开发中一些常用的语句

166 篇文章 21 订阅
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;
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值