示例#1
0
        private ICharacterMarkerSymbol GetMarkerSymbol(bool bLocated)
        {
            //Create a new system draw font
            System.Drawing.Font drawFont = new System.Drawing.Font("ESRI Crime Analysis", 21);

            //Create a new CharacterMarkerSymbol and get the ICharacterMarkerSymbol interface
            ICharacterMarkerSymbol charMarker = new CharacterMarkerSymbolClass();

            //Set the marker symbol properties
            charMarker.Font = (stdole.IFontDisp)OLE.GetIFontDispFromFont(drawFont);

            if (bLocated == true)
            {
                charMarker.CharacterIndex = 56;
                charMarker.Color          = GetRGBColor(255, 0, 0);
                charMarker.Size           = 30;
            }
            else
            {
                charMarker.CharacterIndex = 46;
                charMarker.Color          = GetRGBColor(0, 0, 0);
                charMarker.Size           = 30;
            }
            return(charMarker);
        }
示例#2
0
        private stdole.IFontDisp GetIFontDisp(float size)
        {
            const string    FontFamilyName = "Arial";
            const FontStyle FontStyle      = FontStyle.Bold;

            Font font = new Font(FontFamilyName, size, FontStyle);

            return(OLE.GetIFontDispFromFont(font) as stdole.IFontDisp);
        }
示例#3
0
        public static ITextSymbol makeTextSymbol(string fontName, int fontSize)
        {
            ITextSymbol textSymbol = new TextSymbolClass();

            System.Drawing.Font drawFont = new System.Drawing.Font(fontName, fontSize, FontStyle.Bold);
            textSymbol.Font  = (stdole.IFontDisp)OLE.GetIFontDispFromFont(drawFont);
            textSymbol.Color = GetRGBColor(0, 0, 0);
            ITextPath         textPath         = new BezierTextPathClass(); //to spline the text
            ISimpleTextSymbol simpleTextSymbol = (ISimpleTextSymbol)textSymbol;

            simpleTextSymbol.TextPath = textPath;

            return(textSymbol);
        }
示例#4
0
        private void axMapControl1_OnAfterDraw(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnAfterDrawEvent e)
        {
            //If foreground refreshed
            if (e.viewDrawPhase == (int)esriViewDrawPhase.esriViewForeground)
            {
                //If a line object for splining text exists
                if (m_Polyline != null)
                {
                    //Ensure there's at least two points in the line
                    if (m_PointCollection.PointCount > 1)
                    {
                        //Create a line symbol and grab hold of the ILineSymbol interface
                        ILineSymbol lineSymbol = new SimpleLineSymbolClass();
                        //Set line symbol properties
                        lineSymbol.Color = GetRGBColor(0, 0, 0);
                        lineSymbol.Width = 2;

                        //Create a text symbol and grab hold of the ITextSymbol interface
                        ITextSymbol textSymbol = new TextSymbolClass();
                        //Create a system drawing font symbol with the specified properties
                        System.Drawing.Font drawFont = new System.Drawing.Font("Arial", 16, FontStyle.Bold);

                        //Set the text symbol font by getting the IFontDisp interface
                        textSymbol.Font  = (stdole.IFontDisp)OLE.GetIFontDispFromFont(drawFont);
                        textSymbol.Color = GetRGBColor(0, 0, 0);

                        //Create a text path and grab hold of the ITextPath interface
                        ITextPath textPath = new BezierTextPathClass();                          //to spline the text
                        //Grab hold of the ISimpleTextSymbol interface through the ITextSymbol interface
                        ISimpleTextSymbol simpleTextSymbol = (ISimpleTextSymbol)textSymbol;
                        //Set the text path of the simple text symbol
                        simpleTextSymbol.TextPath = textPath;

                        //Draw the line object and spline the user text around the line
                        object oLineSymbol = lineSymbol;
                        object oTextSymbol = textSymbol;
                        axMapControl1.DrawShape(m_Polyline, ref oLineSymbol);
                        axMapControl1.DrawText(m_Polyline, Text1.Text, ref oTextSymbol);
                    }
                }
            }
        }
示例#5
0
        public static void AddAnnotate(ILayer layer, string fieldName)
        {
            var pGeoLayer = layer as IGeoFeatureLayer;

            if (pGeoLayer != null)
            {
                var ipalpColl = pGeoLayer.AnnotationProperties;
                ipalpColl.Clear();
                IColor fontColor = new RgbColor();
                fontColor.RGB = 255; //字体颜色
                var font     = new Font("宋体", 10, FontStyle.Bold);
                var dispFont = (IFontDisp)OLE.GetIFontDispFromFont(font);

                ITextSymbol pTextSymbol = new TextSymbolClass
                {
                    Color = fontColor,
                    Font  = dispFont,
                    Size  = 12
                };
                ////用来控制标注和要素的相对位置关系

                ILineLabelPosition pLineLpos = new LineLabelPositionClass
                {
                    Parallel = true, //修改标注的属性
                    //Perpendicular = false,
                    Below  = true,
                    InLine = false,
                    Above  = false
                };

                //用来控制标注冲突
                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 + "]"
                };
                //设置标注的参考比例尺
                var pAnnoLyrPros = (IAnnotateLayerTransformationProperties)pLableEngine;
                pAnnoLyrPros.ReferenceScale = 2500000;
                //设置标注可见的最大最小比例尺
                var pAnnoPros = pLableEngine as IAnnotateLayerProperties;
                //pAnnoPros.AnnotationMaximumScale = 2500000;
                //pAnnoPros.AnnotationMinimumScale = 25000000;
                //pAnnoPros.WhereClause属性  设置过滤条件
                ipalpColl.Add(pAnnoPros);
            }
            if (pGeoLayer != null)
            {
                pGeoLayer.DisplayAnnotation = true;
            }
        }