C#+ArcEngine开发笔记

//跳到指定的经纬度

private void gotoXY(double X,double Y)
        {
            IPoint pCenter = new PointClass();
            pCenter.X = X;
            pCenter.Y = Y;
            IEnvelope envelope = axMapControl1.Extent;
            //envelope.Width = 0.16;        //指定显示范围
            //envelope.Height = 0.12;
            //envelope.PutCoords(117.47, 33.85, 117.63, 33.73);
            envelope.CenterAt(pCenter);
            axMapControl1.Extent = envelope;
        }



//添加标注

public static void AddAnnotate(ILayer layer, string fieldName)
        {
            IGeoFeatureLayer pGeoLayer = layer as IGeoFeatureLayer;
            IAnnotateLayerPropertiesCollection IPALPColl = pGeoLayer.AnnotationProperties;
            IPALPColl.Clear();


            IRgbColor pColor = new RgbColorClass()
            {
                Red = 255,
                Blue = 0,
                Green = 0
            };
            IFontDisp pFont = new StdFont()     //using stdole
            {
                Name = "宋体",
                Bold = true
            } as IFontDisp;


            ITextSymbol pTextSymbol = new TextSymbolClass()
            {
                Color = pColor,
                Font = pFont,
                Size = 12
            };


            //用来控制标注和要素的相对位置关系
            ILineLabelPosition pLineLpos = new LineLabelPositionClass()
            {
                Parallel = false,  //修改标注的属性
                Perpendicular = true,
                InLine = true
            };
            //用来控制标注冲突
            ILineLabelPlacementPriorities pLinePlace = new LineLabelPlacementPrioritiesClass()
            {
                AboveStart = 5, //让above 和start的优先级为5
                BelowAfter = 4
            };
            //用来实现对ILineLabelPosition 和 ILineLabelPlacementPriorities以及更高级属性的控制
            IBasicOverposterLayerProperties pBOLP = new BasicOverposterLayerPropertiesClass()
            {
                FeatureType = esriBasicOverposterFeatureType.esriOverposterPolygon,
                LineLabelPlacementPriorities = pLinePlace,
                LineLabelPosition = pLineLpos
            };


            //创建标注对象
            ILabelEngineLayerProperties pLableEngine = new LabelEngineLayerPropertiesClass()
            {
                Symbol = pTextSymbol,
                BasicOverposterLayerProperties = pBOLP,
                IsExpressionSimple = true,
                Expression = "[" + fieldName + "]"
            };


            //设置标注的参考比例尺
            IAnnotateLayerTransformationProperties pAnnoLyrPros = pLableEngine as IAnnotateLayerTransformationProperties;
            pAnnoLyrPros.ReferenceScale = 2500000;


            //设置标注可见的最大最小比例尺
            IAnnotateLayerProperties pAnnoPros = pLableEngine as IAnnotateLayerProperties;
            pAnnoPros.AnnotationMaximumScale = 10000;
            pAnnoPros.AnnotationMinimumScale = 500000;
            //pAnnoPros.WhereClause属性  设置过滤条件


            IPALPColl.Add(pAnnoPros);
            pGeoLayer.DisplayAnnotation = true;
        }

 

 

 

c#判断ArcEngine runtime是否安装的代码

我的计算机安装的是Arcgis10 的AE runtime。判断代码具体如下:
private void CheckInStallAERuntime()
            {
                Microsoft.Win32.RegistryKey LocalMachineRegKey = Microsoft.Win32.Registry.LocalMachine;
                Microsoft.Win32.RegistryKey InstallDirRegKey = LocalMachineRegKey.OpenSubKey(@"SOFTWARE\ESRI\Engine10.0\CoreRuntime");           




                if (InstallDirRegKey == null)
                {
                    MessageBox.Show("没有安装ArcGIS Runtime!");
                }
                else
                {
                    string InstallDirStr = InstallDirRegKey.GetValue("InstallDir").ToString();
                    MessageBox.Show("ArcGIS Runtime安装在了如下目录:" + InstallDirStr);
                }
            }

 

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值