• 图层的自动标注


            /// <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);
                }
            }
    注意红色部分字段格式以及条件的书写方式

  • 相关阅读:
    别了,DjVu!
    DjVu转PDF
    我的电子书历程
    连续翻页浏览器面临的共同问题
    对超过2TB的硬盘进行分区需要使用parted
    DB2常用命令
    CentOS增加网卡
    mysql相关参数解读
    max_user_connections参数设置试验
    mysql最大连接数试验
  • 原文地址:https://www.cnblogs.com/sdustyuleyi/p/2652470.html
Copyright © 2020-2023  润新知