• 图层的自动标注


            /// <summary>
            /// 自动标注图层
            /// </summary>
            /// <param name="pGeoFlyr">矢量图层对象</param>
            /// <param name="pAutoLbl">动态标注对象</param>
            public void SetLayerAutoLabel(IGeoFeatureLayer pGeoFlyr)
            {
                try
                {
                    if (pGeoFlyr == null)
                        return;
                    IAnnotateLayerPropertiesCollection pAnnoProps = pGeoFlyr.AnnotationProperties;

                    pAnnoProps.Clear();

                    IAnnotateLayerProperties pAnnoLayerProps;
                    ILineLabelPosition pPosition;
                    ILineLabelPlacementPriorities pPlacement;
                    IBasicOverposterLayerProperties pBasic;
                    ILabelEngineLayerProperties pLabelEngine;

                    ITextSymbol pTextSymbol = new TextSymbolClass();
                    IRgbColor pColor = new RgbColorClass() { Red = 250, Blue = 0, Green = 0 };
                    stdole.StdFont pFont = new StdFontClass();
                    pFont.Name = "文鼎CS细等线";
                    pFont.Size = 50;
                    pTextSymbol.Font = pFont as stdole.IFontDisp;
                    pTextSymbol.Color = pColor;

                    pPosition = new LineLabelPositionClass();
                    pPosition.Parallel  = true   ;
                    pPosition.InLine = false ;
                    pPosition.Perpendicular = false ;
                    pPosition.Above = true;
                    pPlacement = new LineLabelPlacementPrioritiesClass();
                    pPlacement.AboveStart = 5;
                    pPlacement.BelowAfter = 4;
                    pBasic = new BasicOverposterLayerPropertiesClass();
                    pBasic.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolyline;
                    pBasic.LineLabelPlacementPriorities = pPlacement;
                    pBasic.LineLabelPosition = pPosition;
                    pBasic.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerShape;

                    pLabelEngine = new LabelEngineLayerPropertiesClass();
                    pLabelEngine.Symbol = pTextSymbol;
                    pLabelEngine.BasicOverposterLayerProperties = pBasic;
                    string annoField = "[Shape_Length]";
                    pLabelEngine.Expression = annoField;
                    pAnnoLayerProps = pLabelEngine as IAnnotateLayerProperties;
                    pAnnoLayerProps.LabelWhichFeatures = esriLabelWhichFeatures.esriSelectedFeatures;
                    pAnnoLayerProps.WhereClause = "Shape_Length>40";
                    pAnnoProps.Add(pAnnoLayerProps);
                    pGeoFlyr.AnnotationProperties = pAnnoProps;
                    pGeoFlyr.DisplayAnnotation = true;

                }
                catch (Exception Err)
                {
                    MessageBox.Show(Err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
    注意红色部分字段格式以及条件的书写方式

  • 相关阅读:
    一个关于状态机的问题
    8位同步码修改变4位同步码
    BT1120时序,可以用于自测用
    欧几理德,扩展欧几里德和模线性方程组。
    "旋转的风车"----windows(GDI)绘图
    草滩小恪的学习链接(汇总版)
    酒鬼随机漫步(一个矢量类)
    小题精炼-----初试C语言
    大二(上)------我欠青春一份疯狂
    HDU 1027 Ignatius and the Princess II(康托逆展开)
  • 原文地址:https://www.cnblogs.com/sdustyuleyi/p/2652470.html
Copyright © 2020-2023  润新知