Exemplo n.º 1
0
        /// <summary>
        /// 插入带文字的注记
        /// </summary>
        /// <param name="point"></param>
        /// <param name="mapControl"></param>
        /// <param name="text"></param>
        /// <returns></returns>

        public static IElement DrawSymbolWithText(IPoint point, AxMapControl mapControl, string text)
        {
            #region 设置样式
            IFontDisp pFont = new StdFont()
            {
                Name = "宋体",
                Size = 5
            } as IFontDisp;

            ITextSymbol pTextSymbol = new TextSymbolClass()
            {
                Color = GetColor(255, 0, 0),
                Font  = pFont,
                Size  = 11
            };
            #endregion
            //设置带注记的元素
            ITextElement pTextElment = null;
            pTextElment = new TextElementClass()
            {
                Symbol    = pTextSymbol,
                ScaleText = true,
                Text      = text
            };
            IElement pEle = pTextElment as IElement;
            pEle.Geometry = point;
            //添加标注
            InsertElement(mapControl, pEle, 1);
            return(pEle);
        }
Exemplo n.º 2
0
        private void CreatePoint(double x, double y)
        {
            IPoint             pPoint      = new PointClass();
            IMap               pMap        = axMapControl.Map;
            IActiveView        pActiveView = pMap as IActiveView;
            IGraphicsContainer pGraphicsContainer;
            IElement           pElement = new MarkerElementClass();

            pGraphicsContainer = (IGraphicsContainer)pActiveView;
            IFormattedTextSymbol pTextSymbol     = new TextSymbolClass();
            IBalloonCallout      pBalloonCallout = CreateBalloonCallout(x, y);
            IRgbColor            pColor          = new RgbColorClass();

            pColor.Red        = 150;
            pColor.Green      = 0;
            pColor.Blue       = 0;
            pTextSymbol.Color = pColor;
            ITextBackground pTextBackground;

            pTextBackground                 = (ITextBackground)pBalloonCallout;
            pTextSymbol.Background          = pTextBackground;
            ((ITextElement)pElement).Symbol = pTextSymbol;
            ((ITextElement)pElement).Text   = "测试";
            pPoint.X          = x;
            pPoint.Y          = y;
            pElement.Geometry = pPoint;
            pGraphicsContainer.AddElement(pElement, 1);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 定义任务区多边形名称注记
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static ITextElement getTextElement(string name)
        {
            //定义任务区名称符号格式
            IRgbColor pColor = new RgbColorClass()
            {
                Red   = 0,
                Blue  = 255,
                Green = 0
            };
            IFontDisp pFont = new StdFont()
            {
                Name = "宋体",
                Bold = true
            } as IFontDisp;
            ITextSymbol pTextSymbol = new TextSymbolClass()
            {
                Color = pColor,
                Font  = pFont,
                Size  = 10
            };
            ITextElement pTextElement = new TextElementClass()
            {
                Symbol    = pTextSymbol,
                ScaleText = true,
                Text      = name
            };

            return(pTextElement);
        }
Exemplo n.º 4
0
        private void AddTextElement(double area, IActiveView pACview)
        {
            ITextElement pTextElement = new TextElementClass();

            pTextElement.Text = (Math.Round(area * 0.000001, 2)).ToString() + " km";

            ITextSymbol pTextSymbol = new TextSymbolClass();
            //IRgbColor pRGB = new RgbColorClass();
            //pRGB.Green = 255;
            //pTextSymbol.Color = pRGB;

            ISimpleTextSymbol pSTextSymbol = (ISimpleTextSymbol)pTextSymbol;

            pSTextSymbol.XOffset = 5;
            pSTextSymbol.YOffset = 5;


            pTextElement.Symbol = pTextSymbol;

            IElement pElement = (IElement)pTextElement;

            pElement.Geometry = clickedPoint;

            IGraphicsContainer pGContainer = (IGraphicsContainer)pACview;

            pGContainer.AddElement(pElement, 0);

            pACview.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 解析符号信息
        /// </summary>
        /// <returns></returns>
        public ptSymbolClass GetSymbolClass(string Label, IList <string> Fieldvalues, double UpperLimit, double LowerLimit)
        {
            ptSymbolClass pSymbolClass = null;

            if (m_pSymbol == null)
            {
                return(null);
            }
            //点符号
            if (m_pSymbol is IMarkerSymbol)
            {
                pSymbolClass = GetMarkerSymbolClass(m_pSymbol);
            }
            else if (m_pSymbol is ILineSymbol)
            {
                pSymbolClass = GetLineSymbolClass(m_pSymbol);
            }
            else if (m_pSymbol is IFillSymbol)
            {
                pSymbolClass = GetFillSymbolClass(m_pSymbol);
            }
            else if (m_pSymbol is I3DChartSymbol)
            {
                pSymbolClass = GetIIIDChartSymbolClass(m_pSymbol);
            }
            else if (m_pSymbol is ITextSymbol)
            {
                pSymbolClass = new TextSymbolClass(m_pSymbol);
            }
            pSymbolClass.Label       = Label;
            pSymbolClass.Fieldvalues = Fieldvalues;
            pSymbolClass.UpperLimit  = UpperLimit;
            pSymbolClass.LowerLimit  = LowerLimit;
            return(pSymbolClass);
        }
Exemplo n.º 6
0
        private void DrawColName()
        {
            IGraphicsContainer pGraContainer = m_pMapControl.Map as IGraphicsContainer;
            ITextElement       pTextElement;
            IElement           pElement;
            IPoint             pAnnoPnt = new PointClass();
            ITextSymbol        sym      = new TextSymbolClass();

            stdole.IFontDisp myfont = (stdole.IFontDisp) new stdole.StdFontClass();
            myfont.Name = "华文细黑";
            sym.Font    = myfont;

            myfont.Bold = true;
            sym.Size    = 8;//SystemInfo.Instance.TextSize;

            Color  color  = ColorTranslator.FromHtml(SystemInfo.Instance.TextColor);
            IColor pColor = new RgbColorClass();

            pColor.RGB = color.B * 65536 + color.G * 256 + color.R;
            sym.Color  = pColor;

            for (int i = 0; i < m_pArrText.Count; i++)
            {
                sym.Text = m_pArrText[i].ToString();
                pAnnoPnt.PutCoords(dblStartX + nWidth * m_pArrPipes.Count, dblStartY + nHeight * (m_pArrText.Count - i));
                pTextElement           = new TextElementClass();
                pTextElement.ScaleText = true;
                pTextElement.Text      = sym.Text;
                pTextElement.Symbol    = sym;
                pElement          = (IElement)pTextElement;
                pElement.Geometry = pAnnoPnt;
                pGraContainer.AddElement(pElement, 0);
                (m_pMapControl.Map as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, m_pMapControl.Extent);
            }
        }
Exemplo n.º 7
0
        public void CreateTextElment(double x, double y, int index)
        {
            IMxDocument doc = ArcMap.Document;
            IMap        map = doc.FocusMap;

            IPoint pPoint = new PointClass();
            //IMap pMap = axMapControl.Map;
            IMap               pMap        = doc.FocusMap;
            IActiveView        pActiveView = pMap as IActiveView;
            IGraphicsContainer pGraphicsContainer;
            IElement           pElement  = new MarkerElementClass();
            IElement           pTElement = new TextElementClass();

            pGraphicsContainer = (IGraphicsContainer)pActiveView;
            IFormattedTextSymbol pTextSymbol     = new TextSymbolClass();
            IBalloonCallout      pBalloonCallout = CreateBalloonCallout(x, y);
            IRgbColor            pColor          = new RgbColorClass();

            pColor.Red        = 150;
            pColor.Green      = 0;
            pColor.Blue       = 0;
            pTextSymbol.Color = pColor;
            ITextBackground pTextBackground;

            pTextBackground                  = (ITextBackground)pBalloonCallout;
            pTextSymbol.Background           = pTextBackground;
            ((ITextElement)pTElement).Symbol = pTextSymbol;
            ((ITextElement)pTElement).Text   = index.ToString();
            pPoint.X = x + 420;
            pPoint.Y = y + 420;
            //axMapControl.CenterAt(pPoint);
            pTElement.Geometry = pPoint;
            pGraphicsContainer.AddElement(pTElement, 1);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 8
0
        // 添加标题
        private void AddTitle()
        {
            // 注记放置位置
            IEnvelope pEnv   = axPageLayoutControl_main.Extent;
            IPoint    pPoint = new PointClass()
            {
                X = (pEnv.XMin + pEnv.XMax) / 2,
                Y = pEnv.YMax - 3
            };

            // 文本符号
            stdole.IFontDisp pFont = new stdole.StdFontClass() as stdole.IFontDisp;
            pFont.Name = "arial";
            ITextSymbol pSymbol = new TextSymbolClass()
            {
                Size  = 360.0,
                Font  = pFont,
                Color = GetRgbColor(0, 0, 0)
            };
            // 添加文本对象
            IElement pElement = new TextElementClass()
            {
                Text     = "观看预设点可见性专题图",
                Size     = 360.0,
                Symbol   = pSymbol,
                Geometry = pPoint
            };

            (axPageLayoutControl_main.PageLayout as IGraphicsContainer).AddElement(pElement, 0);
            axPageLayoutControl_main.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 绘制文字到地图中
        /// </summary>
        /// <params name="text"></params>
        /// <params name="pPoint"></params>
        /// <params name="drawFont"></params>
        void DrawTextToMap(string text, ESRI.ArcGIS.Geometry.IPoint pPoint)
        {
            IElement element;

            ITextElement textElement = new TextElementClass();

            element = textElement as IElement;

            ITextSymbol textSymbol = new TextSymbolClass();

            textSymbol.Color = m_color;
            if (m_pFont != null)
            {
                textSymbol.Font = (stdole.IFontDisp)ESRI.ArcGIS.ADF.COMSupport.OLE.GetIFontDispFromFont(m_pFont);
                textSymbol.Size = Convert.ToDouble(m_pFont.Size);
            }
            element.Geometry = pPoint;

            textElement.Symbol = textSymbol;
            textElement.Text   = text;
            IFeature pFeature = DataEditCommon.SaveAnno(element, text);

            GIS.Common.DataEditCommon.g_pMap.SelectFeature(GIS.Common.DataEditCommon.g_pLayer, pFeature);
            GIS.Common.DataEditCommon.g_pAxMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics | esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewBackground, null, null);
        }
Exemplo n.º 10
0
        public void EnableFeatureLayerLabel(IFeatureLayer pFeaturelayer, string sLableField, IRgbColor pRGB, int size, string angleField)
        {
            //判断图层是否为空
            if (pFeaturelayer == null)
            {
                return;
            }
            IGeoFeatureLayer pGeoFeaturelayer = (IGeoFeatureLayer)pFeaturelayer;
            IAnnotateLayerPropertiesCollection pAnnoLayerPropsCollection;

            pAnnoLayerPropsCollection = pGeoFeaturelayer.AnnotationProperties;
            pAnnoLayerPropsCollection.Clear();

            stdole.IFontDisp pFont = new stdole.StdFont() as stdole.IFontDisp;;  //字体
            ITextSymbol      pTextSymbol;

            pFont.Name = "黑体";
            pFont.Size = 4;
            //未指定字体颜色则默认为黑色
            if (pRGB == null)
            {
                pRGB       = new RgbColorClass();
                pRGB.Red   = 0;
                pRGB.Green = 0;
                pRGB.Blue  = 0;
            }

            pTextSymbol       = new TextSymbolClass();
            pTextSymbol.Color = (IColor)pRGB;
            pTextSymbol.Size  = size; //标注大小

            IBasicOverposterLayerProperties4 pBasicOverposterlayerProps4 = new BasicOverposterLayerPropertiesClass();

            switch (pFeaturelayer.FeatureClass.ShapeType)//判断图层类型
            {
            case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
                pBasicOverposterlayerProps4.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolygon;
                break;

            case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
                pBasicOverposterlayerProps4.FeatureType = esriBasicOverposterFeatureType.esriOverposterPoint;
                break;

            case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
                pBasicOverposterlayerProps4.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolyline;
                break;
            }
            pBasicOverposterlayerProps4.PointPlacementMethod = esriOverposterPointPlacementMethod.esriRotationField;
            //pBasicOverposterlayerProps4.RotationField = angleField;

            ILabelEngineLayerProperties pLabelEnginelayerProps = new LabelEngineLayerPropertiesClass();

            pLabelEnginelayerProps.Expression = "[" + sLableField + "]";
            pLabelEnginelayerProps.Symbol     = pTextSymbol;
            pLabelEnginelayerProps.BasicOverposterLayerProperties = pBasicOverposterlayerProps4 as IBasicOverposterLayerProperties;
            pAnnoLayerPropsCollection.Add((IAnnotateLayerProperties)pLabelEnginelayerProps);
            pGeoFeaturelayer.DisplayAnnotation = true;//很重要,必须设置
            //刷新地图
            axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
        }
Exemplo n.º 11
0
        public ITextElement createTextElement(double x_longitude, double y_latitude, string text_content)
        {
            IBalloonCallout      bc          = CreateBalloonCallout(x_longitude, y_latitude);
            IRgbColor            color_rgb   = new RgbColorClass();
            ITextSymbol          text_symbol = new TextSymbolClass();
            IFormattedTextSymbol ftext_symbol;
            IPoint       point = new PointClass();
            ITextElement text_elt = new TextElementClass();
            double       width, height;
            IElement     e;

            color_rgb.Green   = 255;
            text_symbol.Color = color_rgb;

            ftext_symbol            = text_symbol as IFormattedTextSymbol;
            ftext_symbol.Background = bc as ITextBackground;

            //fts.Size = 8;
            text_symbol.Size = 8;

            width  = this.axMapControl1.Extent.Width / 13;
            height = this.axMapControl1.Extent.Height / 20;
            point.PutCoords(x_longitude + width, y_latitude + height);

            //IMarkerElement me = new MarkerElementClass();
            text_elt.Symbol = text_symbol;
            text_elt.Text   = text_content;

            e          = text_elt as IElement;
            e.Geometry = point;


            return(text_elt);
        }
Exemplo n.º 12
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add AddDataTool.OnMouseDown implementation
            base.OnMouseDown(Button, Shift, X, Y);
            //获得当前活动视图
            IActiveView activeView = m_globeHookHelper.ActiveView;
            //创建新的文本元素
            ITextElement textElement = new TextElementClass();
            //创建文本符号
            ITextSymbol textSymbol = new TextSymbolClass();

            textSymbol.Size = 25;
            //设置文本元素属性
            textElement.Symbol = textSymbol;
            textElement.Text   = DateTime.Now.ToShortDateString();
            IElement element = textElement as IElement;
            //创建点
            IPoint point = new PointClass();

            point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            //设置元素属性
            element.Geometry = point;
            //增加元素到图形的绘制容器
            activeView.GraphicsContainer.AddElement(element, 0);
            //refresh
            activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 13
0
        private void method_0()
        {
            this.m_pMapGrid = new MeasuredGridClass();
            if (this.imapFrame_0 != null)
            {
                this.m_pMapGrid.SetDefaults(this.imapFrame_0);
            }
            (this.m_pMapGrid as IMeasuredGrid).XOrigin       = 0.0;
            (this.m_pMapGrid as IMeasuredGrid).Units         = esriUnits.esriMeters;
            (this.m_pMapGrid as IMeasuredGrid).YOrigin       = 0.0;
            (this.m_pMapGrid as IMeasuredGrid).XIntervalSize = 200.0;
            (this.m_pMapGrid as IMeasuredGrid).YIntervalSize = 200.0;
            (this.m_pMapGrid as IMeasuredGrid).FixedOrigin   = true;
            IGridLabel  labelFormat = this.m_pMapGrid.LabelFormat;
            ITextSymbol symbol      = new TextSymbolClass
            {
                Font              = labelFormat.Font,
                Color             = labelFormat.Color,
                Text              = labelFormat.DisplayName,
                VerticalAlignment = esriTextVerticalAlignment.esriTVABottom
            };

            labelFormat.Font            = symbol.Font;
            labelFormat.Color           = symbol.Color;
            labelFormat.LabelOffset     = 6.0;
            this.m_pMapGrid.LabelFormat = labelFormat;
            if (labelFormat is IMixedFontGridLabel2)
            {
                (labelFormat as IMixedFontGridLabel2).NumGroupedDigits = 0;
            }
        }
Exemplo n.º 14
0
        private void button7_Click(object sender, EventArgs e)
        {
            ITextSymbol textSymbol = new TextSymbolClass();

            textSymbol.Color = m_pFillColor;
            stdole.IFontDisp font = new stdole.StdFontClass() as stdole.IFontDisp;
            font.Bold       = true;
            font.Italic     = true;
            textSymbol.Font = font;
            textSymbol.Size = trackBar1.Value;
            IMap curMap = frmMainOper(OperationType.GetMap) as IMap;

            (curMap as IGraphicsContainer).DeleteAllElements();
            for (int i = 0; i < m_pTarFeatureClass.FeatureCount(null); i++)
            {
                ITextElement curText = new TextElementClass();
                curText.ScaleText = true;
                curText.Symbol    = textSymbol;
                curText.Text      = m_pTarFeatureClass.GetFeature(i).get_Value(m_nTarFieldIndex).ToString();
                IElement  curElement  = curText as IElement;
                IEnvelope curEnvelope = m_pTarFeatureClass.GetFeature(i).Extent;
                IPoint    position    = new PointClass();
                position.PutCoords(curEnvelope.XMin + (curEnvelope.XMax - curEnvelope.XMin) / 2, curEnvelope.YMin + (curEnvelope.YMax - curEnvelope.YMin));
                curElement.Geometry = position;
                (curMap as IGraphicsContainer).AddElement(curElement, i);
            }
            frmMainOper(OperationType.RefreshMapCtrl);
        }
Exemplo n.º 15
0
        private void DrawText(string property, int i)
        {
            IGraphicsContainer pGraContainer = m_pMapControl.Map as IGraphicsContainer;
            ITextElement       pTextElement;
            IElement           pElement;
            IPoint             pAnnoPnt = new PointClass();
            ITextSymbol        sym      = new TextSymbolClass();

            stdole.IFontDisp myfont = (stdole.IFontDisp) new stdole.StdFontClass();
            myfont.Name = "华文细黑";
            sym.Font    = myfont;

            myfont.Bold = true;
            sym.Size    = 8;//SystemInfo.Instance.TextSize;

            Color  color  = ColorTranslator.FromHtml(SystemInfo.Instance.TextColor);
            IColor pColor = new RgbColorClass();

            pColor.RGB = color.B * 65536 + color.G * 256 + color.R;
            sym.Color  = pColor;

            sym.Text = property;
            pAnnoPnt.PutCoords(dblStartX + nWidth * m_LabelPoints.Count + 8, dblStartY + nHeight * (fields.Length - i));//居中显示,并位于表格边线以上m_dblTableHeadWidth/5*3
            pTextElement           = new TextElementClass();
            pTextElement.ScaleText = true;
            pTextElement.Text      = sym.Text;
            pTextElement.Symbol    = sym;
            pElement          = (IElement)pTextElement;
            pElement.Geometry = pAnnoPnt;
            pGraContainer.AddElement(pElement, 0);
        }
Exemplo n.º 16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="lstvalue"></param>
        /// <param name="pageXPart">在X方向所在位置占整个page的比例比例</param>
        /// <param name="pageYPart">在Y方向所在位置占整个page的比例比例</param>
        /// <returns></returns>
        public bool AddText(List <string> lstvalue, double pageXPart, double pageYPart, string fountName, double fontSize)
        {
            pTextElement = new TextElementClass();
            string sValue = lstvalue[0];

            for (int i = 1; i < lstvalue.Count; i++)
            {
                sValue += "\n" + lstvalue[i];
            }
            pTextElement.Text = sValue;

            IElement    pElment = pTextElement as IElement;
            ITextSymbol pSymbol = new TextSymbolClass();

            pSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
            stdole.Font pFont;
            pFont               = new stdole.StdFontClass();
            pFont.Name          = fountName;
            pFont.Size          = (decimal)fontSize;
            pSymbol.Font        = pFont as stdole.IFontDisp;
            pTextElement.Symbol = pSymbol;
            IPoint    pPoint = new PointClass();
            IEnvelope pEnv   = new EnvelopeClass();

            pEnv = this.mainPage.ActiveView.Extent;

            pPoint.PutCoords((pEnv.XMin + pEnv.YMax) * pageXPart, (pEnv.YMin + pEnv.YMax) * pageYPart);

            addText(pTextElement, pPoint);
            return(true);
        }
Exemplo n.º 17
0
 public AnnotationClass(IFeatureLayer pFeatureLayer)
 {
     if (pFeatureLayer != null)
     {
         if (pFeatureLayer is IGeoFeatureLayer)
         {
             IGeoFeatureLayer objGFL = pFeatureLayer as IGeoFeatureLayer;
             IAnnotateLayerPropertiesCollection annoPropsColl = objGFL.AnnotationProperties;
             if (objGFL.DisplayAnnotation && annoPropsColl.Count > 0)
             {
                 IAnnotateLayerProperties             annoLayerProps = null;
                 ESRI.ArcGIS.Carto.IElementCollection null_ESRIArcGISCartoIElementCollection  = null;
                 ESRI.ArcGIS.Carto.IElementCollection null_ESRIArcGISCartoIElementCollection2 = null;
                 annoPropsColl.QueryItem(0, out annoLayerProps, out null_ESRIArcGISCartoIElementCollection, out null_ESRIArcGISCartoIElementCollection2);
                 if (annoLayerProps is ILabelEngineLayerProperties && annoLayerProps.DisplayAnnotation)
                 {
                     ILabelEngineLayerProperties labelProps = annoLayerProps as ILabelEngineLayerProperties;
                     if (annoLayerProps.WhereClause == "" && labelProps.IsExpressionSimple)
                     {
                         IsSingleProperty = true;
                         PropertyName     = labelProps.Expression.Replace("[", "").Replace("]", "");
                         TextSymbol       = new TextSymbolClass(labelProps.Symbol as ISymbol);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pActiveView"></param>
        /// <param name="strText"></param>
        /// <param name="dblX">the center of the text</param>
        /// <param name="dblY">the bottom of characters like "5", "b", etc.; not the bottome of characters like "q"</param>
        /// <param name="dblSize">the size of the characters, not the size of the text box</param>
        /// <param name="intRed"></param>
        /// <param name="intGreen"></param>
        /// <param name="intBlue"></param>
        /// <remarks>
        /// https://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//00480000021m000000
        /// </remarks>
        public static void DrawTextMarker(IActiveView pActiveView, string strText,
                                          double dblX, double dblY, double dblSize = 10, int intRed = 0, int intGreen = 0, int intBlue = 0)
        {
            IElement element;

            ITextElement textElement = new TextElementClass();

            element = textElement as IElement;

            ITextSymbol textSymbol = new TextSymbolClass();

            textSymbol.Color = CHelpFunc.GenerateIRgbColor(intRed, intGreen, intBlue) as IColor;
            textSymbol.Size  = dblSize;
            //textSymbol.Font = dblSize;
            //textSymbol.HorizontalAlignment = GetHorizontalAlignment();
            //textSymbol.VerticalAlignment = GetVerticalAlignment();

            IPoint ipt = new PointClass();

            ipt.PutCoords(dblX, dblY);
            element.Geometry = ipt;

            textElement.Symbol = textSymbol;
            textElement.Text   = strText;

            //textElement.
            pActiveView.GraphicsContainer.AddElement(element, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 19
0
        private void Btn_AddTitle_Click(object sender, EventArgs e)
        {
            ITextSymbol textSymbol = new TextSymbolClass();

            textSymbol.Color = Tool_.PutRGB(0, 0, 0);
            stdole.IFontDisp font = new stdole.StdFontClass() as stdole.IFontDisp;
            font.Bold       = true;
            font.Italic     = true;
            textSymbol.Font = font;
            textSymbol.Size = m_pEnvelopDrawed.Width * 20;
            IGraphicsContainer pGraphicsContainer = Ctrl_PageLayout.ActiveView.GraphicsContainer;
            ITextElement       pTextElement       = new TextElementClass
            {
                ScaleText = true,
                Symbol    = textSymbol,
                Text      = "Title"
            };

            if (m_pTitleElement != null)
            {
                pGraphicsContainer.DeleteElement(m_pTitleElement);
            }
            IElement pElement  = pTextElement as IElement;
            IPoint   pPosition = new PointClass();

            pPosition.PutCoords(
                m_pEnvelopDrawed.XMin + (m_pEnvelopDrawed.XMax - m_pEnvelopDrawed.XMin) / 2,
                m_pEnvelopDrawed.YMin + (m_pEnvelopDrawed.YMax - m_pEnvelopDrawed.YMin) / 2);
            pElement.Geometry = pPosition;
            pGraphicsContainer.AddElement(pElement, 0);
            m_pTitleElement = pElement;
            Ctrl_PageLayout.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 20
0
        private void AddBalloonCalloutLabel(string strName, string strText, IPoint pPointAnchor, IElementCollection pElementCollection)
        {
            ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass();

            pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;
            IRgbColor pRgbColorFillSymbol = new RgbColorClass();

            pRgbColorFillSymbol.RGB = fColor;
            //pRgbColorFillSymbol.Red = Color.White.R;
            //pRgbColorFillSymbol.Green = Color.White.G;
            //pRgbColorFillSymbol.Blue = Color.White.B;
            //byte bt = 0;
            //pRgbColorFillSymbol.Transparency = bt;
            pSimpleFillSymbol.Color = pRgbColorFillSymbol;
            //IBalloonCallout 接口
            IBalloonCallout pBalloonCallout = new BalloonCalloutClass(); //弹出标签的背景

            pBalloonCallout.Style           = _style;                    //选择弹出标签样式,请尝试另外两种样式
            pBalloonCallout.Symbol          = pSimpleFillSymbol;         //填充
            pBalloonCallout.LeaderTolerance = 1;
            pBalloonCallout.AnchorPoint     = pPointAnchor;              //定位点
            //创建点标注
            ITextSymbol          pTextSymbol          = new TextSymbolClass();
            IFormattedTextSymbol pFormattedTextSymbol = pTextSymbol as IFormattedTextSymbol;

            pFormattedTextSymbol.Background = pBalloonCallout as ITextBackground;//设置背景

            //字体相关设置
            IRgbColor pRgbColorTextSymbol = new RgbColorClass();//字体颜色

            pRgbColorTextSymbol.RGB = tColor;
            //pRgbColorTextSymbol.Red = 0;
            //pRgbColorTextSymbol.Green = 0;
            //pRgbColorTextSymbol.Blue = 0;
            pFormattedTextSymbol.Color               = pRgbColorTextSymbol;
            pFormattedTextSymbol.Font.Name           = "宋体";
            pFormattedTextSymbol.Size                = _FontSize;
            pFormattedTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;//对齐方式
            pFormattedTextSymbol.VerticalAlignment   = esriTextVerticalAlignment.esriTVATop;

            ISimpleTextSymbol pSimpleTextSymbol = pTextSymbol as ISimpleTextSymbol;

            pSimpleTextSymbol.XOffset = 15;
            pSimpleTextSymbol.YOffset = 0;

            //加点标签
            ITextElement pTextElement = new TextElementClass();

            pTextElement.Symbol = pFormattedTextSymbol as ITextSymbol;
            pTextElement.Text   = strText;//显示的标注文本

            IElement pElement = pTextElement as IElement;

            pElement.Geometry = pPointAnchor as IGeometry;//位置   pPointPosition
            IElementProperties pElementProperties = pElement as IElementProperties;

            pElementProperties.Name = strName;//IElement的名称

            pElementCollection.Add(pElementProperties as IElement, -1);
        }
Exemplo n.º 21
0
        private IElement method_0(IActiveView iactiveView_0, string string_8, double double_2, double double_3,
                                  IEnvelope ienvelope_0)
        {
            ITextElement element = new TextElementClass();
            ITextSymbol  symbol  = new TextSymbolClass
            {
                HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter,
                VerticalAlignment   = esriTextVerticalAlignment.esriTVACenter
            };
            IFontDisp font = symbol.Font;

            font.Size      = 7.09M;
            symbol.Font    = font;
            element.Symbol = symbol;
            element.Text   = string_8;
            IElement  element2 = element as IElement;
            IPoint    origin   = new PointClass();
            IEnvelope bounds   = new EnvelopeClass();

            origin.PutCoords(double_2, double_3);
            element2.Geometry = origin;
            element2.QueryBounds(iactiveView_0.ScreenDisplay, bounds);
            if (bounds.Width > ienvelope_0.Width)
            {
                double sx = ienvelope_0.Width / bounds.Width;
                double sy = ienvelope_0.Height / bounds.Height;
                (element2 as ITransform2D).Scale(origin, sx, sy);
            }
            return(element2);
        }
Exemplo n.º 22
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            //Get the active view
            IActiveView activeView = m_hookHelper.ActiveView;

            //Create a new text element
            ITextElement textElement = new TextElementClass();
            //Create a text symbol
            ITextSymbol textSymbol = new TextSymbolClass();

            textSymbol.Size = 25;

            //Set the text element properties
            textElement.Symbol = textSymbol;
            textElement.Text   = DateTime.Now.ToShortDateString();

            //QI for IElement
            IElement element = (IElement)textElement;
            //Create a point
            IPoint point = new PointClass();

            point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            //Set the elements geometry
            element.Geometry = point;

            //Add the element to the graphics container
            activeView.GraphicsContainer.AddElement(element, 0);
            //Refresh the graphics
            activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 23
0
        /// <summary>
        /// 显示指定图层指定字段的标注
        /// </summary>
        /// <param name="geoLayer">要设置注标注的图层(IFeatureLayer as IGeoFeatureLayer)</param>
        /// <param name="fieldName">显示标注的字段</param>
        /// <param name="fontName">标注的字体</param>
        /// <param name="size">标注的大小</param>
        public static void ShowLabel(this IGeoFeatureLayer geoLayer, string fieldName, string fontName = "宋体", int size = 12)
        {
            //标注属性集
            IAnnotateLayerPropertiesCollection annotateLyrProColl = geoLayer.AnnotationProperties;

            annotateLyrProColl.Clear();

            //普通标准属性(另一个是Maplex标准属性)
            ILabelEngineLayerProperties labelEngine = new LabelEngineLayerPropertiesClass();

            labelEngine.Expression = $"[{fieldName}]";

            //字体
            IFontDisp fontDisp = new StdFont()
            {
                Name = fontName, Bold = false
            } as IFontDisp;

            //标注符号
            ITextSymbol textSymbol = new TextSymbolClass();

            textSymbol.Color   = ColorCreate.GetIColor(0, 0, 0);
            textSymbol.Font    = fontDisp;
            textSymbol.Size    = size;
            labelEngine.Symbol = textSymbol;

            //设置同名标注:默认为移除同名标注,应设为每个要素放置一个标注
            IBasicOverposterLayerProperties basicOverpLyrPro = labelEngine.BasicOverposterLayerProperties as IBasicOverposterLayerProperties;

            basicOverpLyrPro.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerShape;//每个要素放置一个标注

            annotateLyrProColl.Add(labelEngine as IAnnotateLayerProperties);
            geoLayer.DisplayAnnotation = true;
        }
Exemplo n.º 24
0
 private void btnDenominatorTextSymbol_Click(object sender, EventArgs e)
 {
     try
     {
         frmSymbolSelector selector = new frmSymbolSelector();
         ISymbol           pSym     = null;
         if (this.m_FractionTextSymbol.DenominatorTextSymbol != null)
         {
             pSym = (ISymbol)((IClone)this.m_FractionTextSymbol.DenominatorTextSymbol).Clone();
         }
         else
         {
             pSym = new TextSymbolClass();
         }
         selector.SetSymbol(pSym);
         selector.SetStyleGallery(this.m_pSG);
         if (selector.ShowDialog() == DialogResult.OK)
         {
             this.m_FractionTextSymbol.DenominatorTextSymbol = selector.GetSymbol() as ITextSymbol;
             this.btnDenominatorTextSymbol.Style             = this.m_FractionTextSymbol.DenominatorTextSymbol;
             this.btnDenominatorTextSymbol.Invalidate();
             this.method_0(e);
         }
     }
     catch
     {
     }
 }
Exemplo n.º 25
0
        public static IElement CreateTextElement(IPoint point, IColor color, string text, IFontConfig fontConfig)
        {
            stdole.IFontDisp fontDisp = new StdFontClass() as IFontDisp;
            fontDisp.Name          = fontConfig.Font.Name;
            fontDisp.Size          = (decimal)fontConfig.Font.Size;
            fontDisp.Italic        = fontConfig.Font.Italic;
            fontDisp.Underline     = fontConfig.Font.Underline;
            fontDisp.Bold          = fontConfig.Font.Bold;
            fontDisp.Strikethrough = fontConfig.Font.Strikeout;

            ITextSymbol textSymbol = new TextSymbolClass();

            textSymbol.Font  = fontDisp;
            textSymbol.Color = color;
            textSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
            textSymbol.VerticalAlignment   = esriTextVerticalAlignment.esriTVACenter;

            ITextElement textElement = new TextElementClass();

            textElement.Symbol    = textSymbol;
            textElement.ScaleText = true;
            textElement.Text      = text;

            IElement element = textElement as IElement;

            element.Geometry = point;
            return(element);
        }
Exemplo n.º 26
0
        public void OnMouseDown(int button, int shift, int x, int y)
        {
            IRubberBand ipRubber = new RubberEnvelopeClass();
            IEnvelope   env      = ipRubber.TrackNew(this.hk.PageLayoutControl.ActiveView.ScreenDisplay, null) as IEnvelope;

            _insertTextFrm      = new InsertTextForm();
            _insertTextFrm.Text = "插入标题";
            _insertTextFrm.lblTextContent.Text = "标题内容";
            _dlgResult = _insertTextFrm.ShowDialog();
            if (_dlgResult == DialogResult.OK)
            {
                ITextSymbol textSymbol = new TextSymbolClass();
                textSymbol.Font  = _insertTextFrm.TextFont;
                textSymbol.Size  = _insertTextFrm.TextSize;
                textSymbol.Angle = _insertTextFrm.TextAngle;
                textSymbol.Color = _insertTextFrm.TextColor;

                //Create a text element
                ITextElement textElement = new TextElementClass();
                textElement.Symbol    = textSymbol;
                textElement.Text      = _insertTextFrm.InsertText;
                textElement.ScaleText = true;

                //QI to IElment
                IElement element = (IElement)textElement;
                //Set the TextElement's geometry
                element.Geometry = env;

                //Add the element to the GraphicsContainer
                this.hk.PageLayoutControl.ActiveView.GraphicsContainer.AddElement(element, 0);
                //Refresh the PageLayout
                this.hk.PageLayoutControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, element, null);
            }
        }
Exemplo n.º 27
0
        // 添加标题
        public void AddTitle(string text)
        {
            // 放置位置
            IEnvelope pEnv   = axPageLayoutControl_main.Extent;
            IPoint    pPoint = new PointClass()
            {
                X = (pEnv.XMin + pEnv.XMax) / 2,
                Y = pEnv.YMax - 4
            };
            // 文本符号
            ITextSymbol pTextSymbol = new TextSymbolClass()
            {
                Font  = GetFontDisp(30, true),
                Color = GetRgbColor(0, 0, 0)
            };
            // 文本对象
            IElement pElement = new TextElementClass()
            {
                Text     = text,
                Symbol   = pTextSymbol,
                Geometry = pPoint
            };

            (axPageLayoutControl_main.PageLayout as IGraphicsContainer).AddElement(pElement, 0);
            axPageLayoutControl_main.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 28
0
        private bool OnLocation()
        {
            if (d3 == null)
            {
                return(false);
            }
            bool bX = double.TryParse(this.te_X.Text, out x);
            bool bY = double.TryParse(this.te_Y.Text, out y);

            if (!bX || !bY)
            {
                return(false);
            }
            IVector3    vect  = null;
            IEulerAngle angle = null;

            d3.Camera.GetCamera(out vect, out angle);
            if (d3.Terrain.IsRegistered)
            {
                double z = d3.Terrain.GetElevation(x, y, Gvitech.CityMaker.RenderControl.gviGetElevationType.gviGetElevationFromDatabase);
                vect.Set(x, y, z);
            }
            else
            {
                vect.Set(x, y, vect.Z);
            }

            IImagePointSymbol imagePointSymbol = new ImagePointSymbolClass();

            imagePointSymbol.ImageName = Path.Combine(Application.StartupPath, "..\\Resource\\Images\\POI\\Location.png");
            imagePointSymbol.Size      = SystemInfo.Instance.SymbolSize;
            imagePointSymbol.Alignment = gviPivotAlignment.gviPivotAlignBottomCenter;
            IPoint pt = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ);

            pt.SetCoords(vect.X, vect.Y, vect.Z, 0, 0);
            IRenderPoint renderPoint = d3.ObjectManager.CreateRenderPoint(pt, imagePointSymbol, d3.ProjectTree.RootID);

            renderPoint.MaxVisibleDistance = 10000000000.0;

            ITextSymbol textSymbol = new TextSymbolClass();

            textSymbol.TextAttribute = new TextAttributeClass
            {
                TextColor = Convert.ToUInt32(SystemInfo.Instance.TextColor, 16),
                TextSize  = SystemInfo.Instance.TextSize
            };
            textSymbol.PivotAlignment = gviPivotAlignment.gviPivotAlignTopCenter;
            ILabel label = d3.ObjectManager.CreateLabel(d3.ProjectTree.RootID);

            label.Position           = pt;
            label.MaxVisibleDistance = 10000000000.0;
            label.TextSymbol         = textSymbol;
            label.Text = this.te_X.Text + "," + this.te_Y.Text;
            this.listRender.Add(renderPoint);
            this.listRender.Add(label);

            d3.Camera.LookAt(vect, 500, angle);
            return(true);
        }
Exemplo n.º 29
0
        internal string AddTextToMap(string text, IGeometry geom, IColor color, bool IsTempGraphic = false, int size = 12)
        {
            if (geom == null || ArcMap.Document == null || ArcMap.Document.FocusMap == null)
            {
                return(string.Empty);
            }

            IElement element = null;

            geom.Project(ArcMap.Document.FocusMap.SpatialReference);

            if (geom.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                var te = new TextElementClass() as ITextElement;
                te.Text = text;

                var ts = new TextSymbolClass();
                ts.Size = size;
                ts.VerticalAlignment   = esriTextVerticalAlignment.esriTVACenter;
                ts.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;

                te.Symbol = ts;

                element = te as IElement;
            }

            if (element == null)
            {
                return(string.Empty);
            }

            element.Geometry = geom;

            var mxdoc = ArcMap.Application.Document as IMxDocument;
            var av    = mxdoc.FocusMap as IActiveView;
            var gc    = av as IGraphicsContainer;

            // store guid
            var eprop = element as IElementProperties;

            eprop.Name = Guid.NewGuid().ToString();

            if (IsTempGraphic)
            {
                TempGraphicsList.Add(eprop.Name);
            }
            else
            {
                MapGraphicsList.Add(eprop.Name);
            }

            gc.AddElement(element, 0);

            av.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

            RaisePropertyChanged(() => HasMapGraphics);

            return(eprop.Name);
        }
Exemplo n.º 30
0
        //添加标注
        void itemaddlable_Click(object sender, EventArgs e)
        {
        //    //使用TextElment绘制标注, fieldName为要绘制的属性
        //public static void AddLable(AxMapControl axMapControl, ILayer layer, string fieldName)
        //{
            ILayer layer = Global.mainmap.Map.get_Layer(0);
            
            IRgbColor pColor = new RgbColorClass()
            {
                Red = 255,
                Blue = 0,
                Green = 0
            };
            IFontDisp pFont = new StdFont()
            {
                Name = "宋体",
                Size = 5
            } as IFontDisp;
            
            ITextSymbol pTextSymbol = new TextSymbolClass()
            {
                Color = pColor,
                Font = pFont,
                Size = 11
            };

            IGraphicsContainer pGraContainer = Global.mainmap.Map as IGraphicsContainer;

            //遍历要标注的要素
            IFeatureLayer pFeaLayer = layer as IFeatureLayer;
            IFeatureClass pFeaClass = pFeaLayer.FeatureClass;
            IFeatureCursor pFeatCur = pFeaClass.Search(null, false);
            IFeature pFeature = pFeatCur.NextFeature();
            int index = pFeature.Fields.FindField("NAME");//要标注的字段的索引
            IEnvelope pEnv = null;
            ITextElement pTextElment = null;
            IElement pEle = null;
            while (pFeature != null)
            {
                //使用地理对象的中心作为标注的位置
                pEnv = pFeature.Extent;
                IPoint pPoint = new PointClass();
                pPoint.PutCoords(pEnv.XMin + pEnv.Width * 0.5, pEnv.YMin + pEnv.Height * 0.5);

                pTextElment = new TextElementClass()
                {
                    Symbol = pTextSymbol,
                    ScaleText = true,
                    Text = pFeature.get_Value(index).ToString()
                };
                pEle = pTextElment as IElement;
                pEle.Geometry = pPoint;
                //添加标注
                pGraContainer.AddElement(pEle, 0);
                pFeature = pFeatCur.NextFeature();
            }
            (Global.mainmap.Map as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, Global.mainmap.Extent);
       
        }
Exemplo n.º 31
0
        /// <summary>
        /// Annotate Layer
        /// </summary>
        /// <param name="layer"></param>
        /// <param name="labelField"></param>
        /// <author>Shen Yongyuan</author>
        /// <date>20091111</date>
        public static void AnnotateLayer(ILayer layer, string labelField)
        {
            IFeatureLayer    feaLayer    = layer as IFeatureLayer;
            IGeoFeatureLayer geoFeaLayer = layer as IGeoFeatureLayer;
            IAnnotateLayerPropertiesCollection pAnnoProps = geoFeaLayer.AnnotationProperties;

            pAnnoProps.Clear();

            ITextSymbol pTextSyl = new TextSymbolClass();
            Font        fnt      = new System.Drawing.Font("宋体", 10f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);

            pTextSyl.Size = 10;
            //pTextSyl.Font = ESRI.ArcGIS.ADF.COMSupport.OLE.GetIFontDispFromFont(fnt) as stdole.IFontDisp;
            pTextSyl.Color = Town.ArcGIS.Color.ToEsriColor(System.Drawing.Color.Black);

            IBasicOverposterLayerProperties pBasic = new BasicOverposterLayerPropertiesClass();

            if (feaLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
            {
                ILineLabelPosition            pPosition      = new LineLabelPositionClass();
                ILineLabelPlacementPriorities pPlacementLine = new LineLabelPlacementPrioritiesClass();

                pBasic.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolygon;
                pBasic.LineLabelPlacementPriorities = pPlacementLine;
                pBasic.LineLabelPosition            = pPosition;
            }
            else if (feaLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint)
            {
                IPointPlacementPriorities pPlacementPoint = new PointPlacementPrioritiesClass();
                pBasic.FeatureType = esriBasicOverposterFeatureType.esriOverposterPoint;
                pBasic.PointPlacementPriorities = pPlacementPoint;
                pBasic.PointPlacementOnTop      = false;
                pBasic.PointPlacementMethod     = esriOverposterPointPlacementMethod.esriAroundPoint;
            }
            else if (feaLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
            {
                ILineLabelPosition            pPosition      = new LineLabelPositionClass();
                ILineLabelPlacementPriorities pPlacementLine = new LineLabelPlacementPrioritiesClass();

                pBasic.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolyline;
                pBasic.LineLabelPlacementPriorities = pPlacementLine;
                pBasic.LineLabelPosition            = pPosition;
            }

            pBasic.LabelWeight   = esriBasicOverposterWeight.esriHighWeight;
            pBasic.FeatureWeight = esriBasicOverposterWeight.esriNoWeight;

            ILabelEngineLayerProperties pLabelEngine = new LabelEngineLayerPropertiesClass();

            pLabelEngine.Symbol = pTextSyl;
            pLabelEngine.BasicOverposterLayerProperties = pBasic;
            pLabelEngine.Expression = "[" + labelField + "]";

            IAnnotateLayerProperties pAnnoLayerProps = pLabelEngine as IAnnotateLayerProperties;

            pAnnoProps.Add(pAnnoLayerProps);
            geoFeaLayer.DisplayAnnotation = true;
        }
Exemplo n.º 32
0
        public static void SetLayerAnnotation(IGeoFeatureLayer geolyr, string field)
        {
            geolyr.AnnotationProperties.Clear();
            IBasicOverposterLayerProperties pBasic = new BasicOverposterLayerPropertiesClass();
            ILabelEngineLayerProperties pLableEngine = new LabelEngineLayerPropertiesClass();
            ITextSymbol textSymbol = new TextSymbolClass();

            string lable = "[" + field + "]";
            pLableEngine.Expression = lable;
            pLableEngine.IsExpressionSimple = true;
            pBasic.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerShape;
            pLableEngine.BasicOverposterLayerProperties = pBasic;
            pLableEngine.Symbol = textSymbol;
            geolyr.AnnotationProperties.Add(pLableEngine as IAnnotateLayerProperties);
        }
Exemplo n.º 33
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            stdole.IFontDisp pFont = (stdole.IFontDisp)new stdole.StdFontClass();
            pFont.Name = textFont.Text.Trim();
               // pFont.Size = Convert.ToInt32(textSize.Text.Trim());
               // pTextElement.Symbol.Angle = Convert.ToDouble(textAngle.Text.Trim());

            ITextSymbol ptextSymbol = new TextSymbolClass();
            ptextSymbol.Angle = Convert.ToDouble(textAngle.Text.Trim());
            ptextSymbol.Font = pFont;
            ptextSymbol.Text = textBox1.Text;
            pTextElement.Text = textBox1.Text;
            ptextSymbol.Size = Convert.ToDouble(textSize.Text.Trim());
            pTextElement.Symbol = ptextSymbol;
            this.Close ();
        }
Exemplo n.º 34
0
        public void ShowCoordinatesOnMap(AxGlobeControl axGlobeControl)
        {
            try
            {
                ITextSymbol pTextSymbol = new TextSymbolClass();
                //pTextSymbol.Font = new Font("Consolas", 10, FontStyle.Regular);    //设置字体
                pTextSymbol.Size = 12;          //字体大小
                pTextSymbol.Color = BaseGISTools.TransColorToAEColor(Color.White);    //字体颜色

                myTextElement = new TextElementClass(); ;
                myTextElement.Symbol = pTextSymbol; //设置样式
                myTextElement.Text = "这是现实的信息 \n 这是第二行 \n 这是第三行";

                graphicsLayer = axGlobeControl.GlobeDisplay.Scene.BasicGraphicsLayer;
                graphicsContain3D = (IGraphicsContainer3D)graphicsLayer;
                graphicsContain3D.AddElement(myTextElement as IElement);
                axGlobeControl.GlobeDisplay.RefreshViewers();
            }
            catch { }
        }
        private IElement GetElement(IGeometry geometry, string text, float size)
        {
            IElement element;

            ITextElement textElement = new TextElementClass();
            element = textElement as IElement;

            ITextSymbol textSymbol = new TextSymbolClass();
            textSymbol.Color = ColorSelection.GetColor();
            textSymbol.Size = Convert.ToDouble(size);
            textSymbol.Font = GetIFontDisp(size);
            textSymbol.HorizontalAlignment = GetHorizontalAlignment();
            textSymbol.VerticalAlignment = GetVerticalAlignment();

            element.Geometry = geometry;

            textElement.Symbol = textSymbol;
            textElement.Text = text;

            return element;
        }
Exemplo n.º 36
0
        /// <summary>
        /// �����ı���ʾ��
        /// </summary>
        /// <param name="x">��ʾ���ʶ��λ��X����</param>
        /// <param name="y">��ʾ���ʶ��λ��Y����</param>
        public void CreateTextElment(AxMapControl axMapControl1, double x, double y, string strText)
        {
            IPoint pPoint = new PointClass();
            IMap pMap = axMapControl1.Map;
            IActiveView pActiveView = pMap as IActiveView;
            IGraphicsContainer pGraphicsContainer;
            IElement pElement = new MarkerElementClass();
            IElement pTElement = new TextElementClass();
            pGraphicsContainer = (IGraphicsContainer)pActiveView;
            IFormattedTextSymbol pTextSymbol = new TextSymbolClass();
            IBalloonCallout pBalloonCallout = CreateBalloonCallout(x, y);
            IRgbColor pColor = new RgbColorClass();
            pColor.Red = 150;
            pColor.Green = 0;
            pColor.Blue = 0;
            pTextSymbol.Color = pColor;
            ITextBackground pTextBackground;
            pTextBackground = (ITextBackground)pBalloonCallout;
            pTextSymbol.Background = pTextBackground;
            ((ITextElement)pTElement).Symbol = pTextSymbol;
            ((ITextElement)pTElement).Text = strText;

            IPoint p = new PointClass();
            //���õ������
            p.PutCoords(x, y);
            IElementProperties ipElemProp;
            IMarkerElement ipMarkerElement = new MarkerElementClass();
            IPictureMarkerSymbol ipPicMarker = new PictureMarkerSymbolClass();
            ipPicMarker.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, "D:\\pro\\ArcGisView\\ArcGisView\\1.bmp");
            ipPicMarker.Size = 24;
            IRgbColor ipRGBTrans = new RgbColorClass();
            ipRGBTrans.RGB = 0xffffff;
            ipPicMarker.BitmapTransparencyColor = ipRGBTrans as IColor;
            ipMarkerElement.Symbol = ipPicMarker as IMarkerSymbol;
            IElement ipElement = ipMarkerElement as IElement;
            ipElement.Geometry = p as IGeometry;
            axMapControl1.ActiveView.GraphicsContainer.AddElement(ipElement, 0);

            pPoint.X = x + 42;
            pPoint.Y = y + 42;
            pTElement.Geometry = pPoint;
            pGraphicsContainer.AddElement(pTElement, 1);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 37
0
        /// <summary>
        /// 创建注记层
        /// </summary>
        /// <param name="strFeaClsName">注记层名称</param>
        /// <param name="destDataset">待创建的注记层所在的featuredataset</param>
        /// <param name="ipInputFields">注记层字段</param>
        public static IFeatureClass CreateAnnotation(IFeatureClass pInputCls, IFeatureDataset destDataset, IFields ipInputFields)
        {
            try
            {
                //要素类标识信息
                IObjectClassDescription ipObjectClassDesc = new AnnotationFeatureClassDescription();
                IFeatureClassDescription ipFeatClassDesc = (IFeatureClassDescription)ipObjectClassDesc;

                IAnnoClass pAnnoClass = pInputCls.Extension as IAnnoClass;
                double scale = pAnnoClass.ReferenceScale;

                IUID ipCLSID = ipObjectClassDesc.InstanceCLSID;
                ipCLSID.Value = "esriCore.AnnotationFeature";

                IUID ipExtCLSID = ipObjectClassDesc.ClassExtensionCLSID;
                ipExtCLSID.Value = "esriCore.AnnotationFeatureClassExtension";

                //IField ipField;
                IFields ipFields = ipObjectClassDesc.RequiredFields;
                IFieldsEdit ipFieldsEdit = (IFieldsEdit)ipFields;
                int numFields = ipInputFields.FieldCount;

                esriFieldType type;
                for (int i = 0; i < numFields; i++)
                {
                    IField ipField = ipInputFields.get_Field(i);
                    type = ipField.Type;
                    if (type != esriFieldType.esriFieldTypeOID && type != esriFieldType.esriFieldTypeGeometry)
                    {
                        string fldName = ipField.Name;
                        int fldIndex = ipFields.FindField(fldName);

                        if (fldIndex == -1)
                            ipFieldsEdit.AddField(ipField);
                    }
                }

                //工作空间
                IWorkspace ipWorkspace = destDataset.Workspace;
                IFeatureWorkspaceAnno ipFeatureWorkspaceAnno = (IFeatureWorkspaceAnno)ipWorkspace;

                //显示比例
                IGraphicsLayerScale ipGraphicsLayerScale = new GraphicsLayerScaleClass();
                ipGraphicsLayerScale.ReferenceScale = scale;
                ipGraphicsLayerScale.Units = pAnnoClass.ReferenceScaleUnits;

                //符号信息
                //' set up symbol collection
                ISymbolCollection pSymbolColl = new SymbolCollectionClass();

                ITextSymbol myTxtSym = new TextSymbolClass();
                //Set the font for myTxtSym
                stdole.IFontDisp myFont = new stdole.StdFontClass() as stdole.IFontDisp;
                IFont pFt = (IFont)myFont;
                pFt.Name = "Courier New";

                myTxtSym.Font = myFont;

                // Set the Color for myTxtSym to be Dark Red
                IRgbColor myColor = new RgbColorClass();
                myColor.Red = 150;
                myColor.Green = 0;
                myColor.Blue = 0;
                myTxtSym.Color = myColor;

                // Set other properties for myTxtSym
                myTxtSym.Angle = 0;
                myTxtSym.RightToLeft = false;
                myTxtSym.VerticalAlignment = esriTextVerticalAlignment.esriTVABaseline;
                myTxtSym.HorizontalAlignment = esriTextHorizontalAlignment.esriTHAFull;
                myTxtSym.Size = 9;

                ISymbol pSymbol = (ISymbol)myTxtSym;
                pSymbolColl.set_Symbol(0, pSymbol);

                //set up the annotation labeling properties including the expression
                IAnnotateLayerProperties pAnnoProps = new LabelEngineLayerPropertiesClass();
                pAnnoProps.FeatureLinked = true;
                pAnnoProps.AddUnplacedToGraphicsContainer = false;
                pAnnoProps.CreateUnplacedElements = true;
                pAnnoProps.DisplayAnnotation = true;
                pAnnoProps.UseOutput = true;

                ILabelEngineLayerProperties pLELayerProps = (ILabelEngineLayerProperties)pAnnoProps;
                IAnnotationExpressionEngine aAnnoVBScriptEngine = new AnnotationVBScriptEngineClass();
                pLELayerProps.ExpressionParser = aAnnoVBScriptEngine;
                pLELayerProps.Expression = "[DESCRIPTION]";
                pLELayerProps.IsExpressionSimple = true;
                pLELayerProps.Offset = 0;
                pLELayerProps.SymbolID = 0;
                pLELayerProps.Symbol = myTxtSym;

                IAnnotateLayerTransformationProperties pATP = (IAnnotateLayerTransformationProperties)pAnnoProps;
                double dRefScale = ipGraphicsLayerScale.ReferenceScale;
                pATP.ReferenceScale = dRefScale;
                pATP.Units = esriUnits.esriMeters;
                pATP.ScaleRatio = 1;

                IAnnotateLayerPropertiesCollection pAnnoPropsColl = new AnnotateLayerPropertiesCollectionClass();
                pAnnoPropsColl.Add(pAnnoProps);

                //' use the AnnotationFeatureClassDescription co - class to get the list of required fields and the default name of the shape field
                IObjectClassDescription pOCDesc = new AnnotationFeatureClassDescriptionClass();
                IFeatureClassDescription pFDesc = (IFeatureClassDescription)pOCDesc;

                IFields pReqFields = pOCDesc.RequiredFields;
                IUID pInstCLSID = pOCDesc.InstanceCLSID;
                IUID pExtCLSID = pOCDesc.ClassExtensionCLSID;
                string bsShapeFieldName = pFDesc.ShapeFieldName;

                IDataset pDs = (IDataset)pInputCls;

                //创建
                string bstName = ipFeatClassDesc.ShapeFieldName;
                IFeatureClass pOutFcls =
                    ipFeatureWorkspaceAnno.CreateAnnotationClass(pDs.Name, ipFields, pOCDesc.InstanceCLSID,
                                                                 pOCDesc.ClassExtensionCLSID, pInputCls.ShapeFieldName, "", destDataset, null, pAnnoPropsColl,
                                                                 ipGraphicsLayerScale, pSymbolColl, true);
                return pOutFcls;
            }
            catch(Exception exp)
            {
                Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString());

                return null;
            }
            return null;
        }
Exemplo n.º 38
0
        /// <summary>
        /// 为PageLayout对象添加图例对象
        /// </summary>
        /// <param name="pPageLayout">PageLayout对象</param>
        /// <param name="pEnvelope">图例添加的位置</param>
        public static void AddLegendToPageLayout(AxPageLayoutControl axpagelayoutcontrol, IEnvelope pEnvelope)
        {
            IPageLayout pageLayout;
            pageLayout = axpagelayoutcontrol.PageLayout;
            try
            {
                IActiveView pActiveView = pageLayout as IActiveView;
                IMap pMap = pActiveView.FocusMap;
                IGraphicsContainer pGraphicsContainer = pActiveView as IGraphicsContainer;
                IMapFrame pMapFrame = pGraphicsContainer.FindFrame(pMap) as IMapFrame;
                UID pUID = new UID();
                pUID.Value = "{7A3F91E4-B9E3-11d1-8756-0000F8751720}";
                ISymbolBackground pSymbolBackground = new SymbolBackgroundClass();
                IFillSymbol pFillSymbol = new SimpleFillSymbolClass();
                ILineSymbol pLineSymbol = new SimpleLineSymbolClass();
                pFillSymbol.Color = GetRgbColor(255, 255, 255);
                pLineSymbol.Color = GetRgbColor(255, 255, 255);
                pFillSymbol.Outline = pLineSymbol;
                pSymbolBackground.FillSymbol = pFillSymbol;
                IMapSurroundFrame pMapSurroundFrame = pMapFrame.CreateSurroundFrame(pUID, null);
                pMapSurroundFrame.Background = pSymbolBackground;
                IElement pElement = pMapSurroundFrame as IElement;
                pElement.Geometry = pEnvelope;
                IMapSurround pMapSurround = pMapSurroundFrame.MapSurround;
                ILegend pLegend = pMapSurround as ILegend;
                pLegend.ClearItems();
                pLegend.Title = "图例";
                ITextSymbol pTextSymbol = new TextSymbolClass();
                pTextSymbol.Size = 10;
                pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
                ILegendItem pLegendItem = null;

                for (int i = 0; i < pActiveView.FocusMap.LayerCount; i++)
                {
                    ILayer pLayer = pActiveView.FocusMap.get_Layer(i);
                    if (pLayer is IFeatureLayer)
                    {
                        IFeatureLayer pFLayer = pLayer as IFeatureLayer;
                        IFeatureClass pFeatureClass = pFLayer.FeatureClass;
                        if (pFeatureClass.FeatureType == esriFeatureType.esriFTAnnotation)
                        {
                            continue;
                        }
                        else
                        {
                            pLegendItem = new HorizontalBarLegendItemClass();
                            pLegendItem.Layer = pLayer;
                            pLegendItem.Columns = 1;
                            pLegendItem.ShowDescriptions = false;
                            pLegendItem.ShowHeading = false;
                            pLegendItem.ShowLabels = true;
                            pLegendItem.LayerNameSymbol = pTextSymbol;
                            pLegend.AddItem(pLegendItem);
                        }
                    }
                }
            }
            catch(Exception  ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    private void setupLayerLabels(ITemporalLayer trackingLayer, string labelField)
    {
      //cast TrackingLayerLabels from the temporal layer
      ITrackingLayerLabels layerLabels = (ITrackingLayerLabels)trackingLayer;

      //set the labels properties
      layerLabels.LabelFieldName = labelField;
      layerLabels.LabelFeatures = true;

      // create text symbol
      ITextSymbol textSymbol = new TextSymbolClass();
      textSymbol.Color = (IColor)Converter.ToRGBColor(Color.Red);
      textSymbol.Size = 15;
      textSymbol.Font = Converter.ToStdFont(new Font(new FontFamily("Arial"), 15.0f, FontStyle.Regular));
      textSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
      textSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABaseline;

      layerLabels.TextSymbol = textSymbol;
    }
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            //Get the active view
            IActiveView activeView = m_hookHelper.ActiveView;

            //Create a new text element
            ITextElement textElement = new TextElementClass();
            //Create a text symbol
            ITextSymbol textSymbol = new TextSymbolClass();
            textSymbol.Size = 25;

            //Set the text element properties
            textElement.Symbol = textSymbol;
            textElement.Text = DateTime.Now.ToShortDateString();

            //QI for IElement
            IElement element = (IElement) textElement;
            //Create a point
            IPoint point = new PointClass();
            point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(X,Y);
            //Set the elements geometry
            element.Geometry = point;

            //Add the element to the graphics container
            activeView.GraphicsContainer.AddElement(element, 0);
            //Refresh the graphics
            activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); 

        }
Exemplo n.º 41
0
        private ITextElement MakeTextElement(IPoint pPoint, string strText, string sFontName, bool Centered = false, long FontSize = 8)
        {
            // Setup a color
            IRgbColor pRGBColor = new RgbColorClass();
            pRGBColor.Blue = 0;
            pRGBColor.Red = 0;
            pRGBColor.Green = 0;

            // Set text element at the right place
            ITextElement pTextElement = new TextElementClass();
            IElement pElement = pTextElement as IElement;
            pElement.Geometry = pPoint;

            // Setup a Font
            IFontDisp pFontDisp = new stdole.StdFontClass() as IFontDisp;
            pFontDisp.Name = sFontName;

            // Setup a TextSymbol that the TextElement will draw with
            ITextSymbol pTextSymbol = new TextSymbolClass();
            pTextSymbol.Font = pFontDisp;
            pTextSymbol.Color = pRGBColor;
            pTextSymbol.Size = FontSize;

            // Center if appropriate
            if (Centered == true)
            {
                pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
                pTextSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
            }
            else
            {
                pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
                pTextSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop;
            }

            // Give the TextSymbol and string to the TextElement
            pTextElement.Symbol = pTextSymbol;
            pTextElement.Text = strText;

            return pTextElement;
        }
        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;
        }
Exemplo n.º 43
0
        private void btnAnno_Click(object sender, EventArgs e)
        {
            IGeoFeatureLayer pGeoFeatLyr = this.mainMapControl.get_Layer(0) as IGeoFeatureLayer;
            //获得AnnotateLayerPropertiesCollection
            IAnnotateLayerPropertiesCollection pAnnoLyrProCollection = pGeoFeatLyr.AnnotationProperties;
            pAnnoLyrProCollection.Clear();
            //创建并设置TextSymbol
            ITextSymbol pTextSymbol = new TextSymbolClass();
            System.Drawing.Font pFont = new System.Drawing.Font("Castellar", 15.0F);
            //pTextSymbol.Font = ESRI.ArcGIS.Utility.COMSupport.OLE.GetIFontDispFromFont(pFont) as stdole.IFontDisp;//转换.NET的Font
            pTextSymbol.Color = getRGBColor(255, 0, 0);
            //创建LineLabelPosition
            ILineLabelPosition pLineLabelPosition = new LineLabelPositionClass();
            pLineLabelPosition.Parallel = false;
            pLineLabelPosition.Perpendicular = true;
            //创建LineLabelPlacementPriorities
            ILineLabelPlacementPriorities pLineLablePlacementPriorities = new LineLabelPlacementPrioritiesClass();
            //创建BasicOverposterLayerProperties
            IBasicOverposterLayerProperties pBasicOverposterLayerProperties = new BasicOverposterLayerPropertiesClass();
            pBasicOverposterLayerProperties.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolyline;
            pBasicOverposterLayerProperties.LineLabelPlacementPriorities = pLineLablePlacementPriorities;
            pBasicOverposterLayerProperties.LineLabelPosition = pLineLabelPosition;
            //创建LabelEngineLayerProperties
            ILabelEngineLayerProperties pLabelEnginLayerProperties = new LabelEngineLayerPropertiesClass();
            pLabelEnginLayerProperties.Symbol = pTextSymbol;
            pLabelEnginLayerProperties.BasicOverposterLayerProperties = pBasicOverposterLayerProperties;
            pLabelEnginLayerProperties.Expression = "[NAME]";

            IAnnotateLayerProperties pAnnoLyrPro = pLabelEnginLayerProperties as IAnnotateLayerProperties;
            pAnnoLyrProCollection.Add(pAnnoLyrPro);//添加,关键
            pGeoFeatLyr.DisplayAnnotation = true;//确定显示

            this.mainMapControl.Refresh();
        }
Exemplo n.º 44
0
        /// <summary>
        /// 绘制文字到地图中
        /// </summary>
        /// <params name="text"></params>
        /// <params name="pPoint"></params>
        /// <params name="drawFont"></params>
        void DrawTextToMap(string text, ESRI.ArcGIS.Geometry.IPoint pPoint)
        {
            IElement element;

            ITextElement textElement = new TextElementClass();
            element = textElement as IElement;

            ITextSymbol textSymbol = new TextSymbolClass();
            textSymbol.Color = m_color;
            if (m_pFont != null)
            {
                textSymbol.Font = (stdole.IFontDisp)ESRI.ArcGIS.ADF.COMSupport.OLE.GetIFontDispFromFont(m_pFont);
                textSymbol.Size = Convert.ToDouble(m_pFont.Size);
            }
            element.Geometry = pPoint;

            textElement.Symbol = textSymbol;
            textElement.Text = text;
            IFeature pFeature = DataEditCommon.SaveAnno(element, text);
            GIS.Common.DataEditCommon.g_pMap.SelectFeature(GIS.Common.DataEditCommon.g_pLayer, pFeature);
                        GIS.Common.DataEditCommon.g_pAxMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics | esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewBackground, null, null);
        }
Exemplo n.º 45
0
        //坐标画点
        public static void CreatPoint(AxMapControl axMapControl,double x,double y,int m)
        {
            //首先要实现容器接口
            IGraphicsContainer pGraphicsContainer = axMapControl.ActiveView as IGraphicsContainer;
            //pGraphicsContainer.DeleteAllElements();//清空容器里面所有的元素

            //设置点的坐标
            IPoint pPoint = new PointClass();
            pPoint.PutCoords(x, y);

            //IMarkerElement用来获得symbol属性
            IMarkerElement pMarkerElement = new MarkerElementClass();

            //用ISimpleMarkerSymbol来设置点的属性
            ISimpleMarkerSymbol pSymbol = new SimpleMarkerSymbolClass();
            IRgbColor pRGBcolor = new RgbColorClass();
            pRGBcolor.Red = 0;
            pRGBcolor.Green =220;
            pRGBcolor.Blue = 0;
               // pSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
            pSymbol.Size = 5;
            pSymbol.Color = pRGBcolor;//绿色
            pSymbol.Style = esriSimpleMarkerStyle.esriSMSCross;
            pSymbol.Outline = false;

            pMarkerElement.Symbol = pSymbol;

            //IEnvelope envelop=new EnvelopeClass();
            pPoint.Envelope.SetEmpty();
            //IElement用来获得Geometry属性
            IElement pElement = pMarkerElement as IElement;
            //把IPoint转换为为IGeoMetry也能实现
            //IGeometry pGeometry = pPoint as IGeometry;
            //pElement.Geometry = pGeometry;
            //设置点的标签;
            ITextSymbol pTextSymbol = new TextSymbolClass();
            pTextSymbol.Size = 10;
            pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
            ITextElement texElement = new TextElementClass();
            texElement.Symbol = pTextSymbol;
            texElement.Text = m.ToString();
            IElement tElement = texElement as IElement;
            texElement.ScaleText = true;

            pElement.Geometry = pPoint;
            tElement.Geometry = pPoint;

            //在容器里添加元素
            pGraphicsContainer.AddElement(pElement, 0);
            pGraphicsContainer.AddElement(tElement, 0);
            pElement.Activate(axMapControl.ActiveView.ScreenDisplay);
              //tElement.Activate(axMapControl.ActiveView.ScreenDisplay);
            axMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pElement, null);
               // axMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, tElement, null);
        }
Exemplo n.º 46
0
        public static void AddTextElement(AxPageLayoutControl PageLayoutControl, double x, double y, string textName)
        {
            IPageLayout pPageLayout;
            IActiveView pAV;
            IGraphicsContainer pGraphicsContainer;
            IPoint pPoint;
            ITextElement pTextElement;
            IElement pElement;
            ITextSymbol pTextSymbol;
            IRgbColor pColor;
            pPageLayout = PageLayoutControl.PageLayout;
            pAV = (IActiveView)pPageLayout;
            pGraphicsContainer = (IGraphicsContainer)pPageLayout;
            pTextElement = new TextElementClass();

            IFontDisp pFont = new StdFontClass() as IFontDisp;
            pFont.Bold = true;
            pFont.Name = "宋体";
            pFont.Size = 26;

            pColor = new RgbColorClass();
            pColor.Red = 255;

            pTextSymbol = new TextSymbolClass();
            pTextSymbol.Color = (IColor)pColor;
            pTextSymbol.Font = pFont;

            pTextElement.Text = textName;
            pTextElement.Symbol = pTextSymbol;

            pPoint = new PointClass();
            pPoint.X = x;
            pPoint.Y = y;

            pElement = (IElement)pTextElement;
            pElement.Geometry = (IGeometry)pPoint;
            pGraphicsContainer.AddElement(pElement, 0);

            pAV.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 47
0
        private void AddBalloonCalloutLabel(string strName, string strText, IPoint pPointAnchor, IElementCollection pElementCollection)
        {
            ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass();
            pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;
            IRgbColor pRgbColorFillSymbol = new RgbColorClass();

            pRgbColorFillSymbol.RGB = fColor;
            //pRgbColorFillSymbol.Red = Color.White.R;
            //pRgbColorFillSymbol.Green = Color.White.G;
            //pRgbColorFillSymbol.Blue = Color.White.B;
            //byte bt = 0;
            //pRgbColorFillSymbol.Transparency = bt;
            pSimpleFillSymbol.Color = pRgbColorFillSymbol;
            //IBalloonCallout 接口
            IBalloonCallout pBalloonCallout = new BalloonCalloutClass();//弹出标签的背景
            pBalloonCallout.Style = _style;//选择弹出标签样式,请尝试另外两种样式
            pBalloonCallout.Symbol = pSimpleFillSymbol;//填充
            pBalloonCallout.LeaderTolerance = 1;
            pBalloonCallout.AnchorPoint = pPointAnchor;//定位点
            //创建点标注
            ITextSymbol pTextSymbol = new TextSymbolClass();
            IFormattedTextSymbol pFormattedTextSymbol = pTextSymbol as IFormattedTextSymbol;
            pFormattedTextSymbol.Background = pBalloonCallout as ITextBackground;//设置背景

            //字体相关设置
            IRgbColor pRgbColorTextSymbol = new RgbColorClass();//字体颜色
            pRgbColorTextSymbol.RGB = tColor;
            //pRgbColorTextSymbol.Red = 0;
            //pRgbColorTextSymbol.Green = 0;
            //pRgbColorTextSymbol.Blue = 0;
            pFormattedTextSymbol.Color = pRgbColorTextSymbol;
            pFormattedTextSymbol.Font.Name = "宋体";
            pFormattedTextSymbol.Size = _FontSize;
            pFormattedTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;//对齐方式
            pFormattedTextSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop;

            ISimpleTextSymbol pSimpleTextSymbol = pTextSymbol as ISimpleTextSymbol;
            pSimpleTextSymbol.XOffset = 15;
            pSimpleTextSymbol.YOffset = 0;

            //加点标签
            ITextElement pTextElement = new TextElementClass();
            pTextElement.Symbol = pFormattedTextSymbol as ITextSymbol;
            pTextElement.Text = strText;//显示的标注文本

            IElement pElement = pTextElement as IElement;
            pElement.Geometry = pPointAnchor as IGeometry;//位置   pPointPosition
            IElementProperties pElementProperties = pElement as IElementProperties;
            pElementProperties.Name = strName;//IElement的名称

            pElementCollection.Add(pElementProperties as IElement, -1);
        }
Exemplo n.º 48
0
        //�鿴���߲����Ƶ����
        public static void TVScansHatchRoutes(AxMapControl ppAxMapControl)
        {
            IFeatureLayer pFeatTVSurveyLayer = UtilityFunction.FindFeatLayer("Sewer TV Surveys", ppAxMapControl);
            //�����ı�����
            ITextSymbol pTxtSymbol = new TextSymbolClass();
            IRgbColor pRgbColor = new RgbColorClass();
            pRgbColor.Red = 255;
            stdole.IFontDisp pFont = (stdole.IFontDisp)new stdole.StdFont();
            pFont.Name = "Arial";
            pFont.Bold = true;
            pTxtSymbol.Font = pFont;
            pTxtSymbol.Size = 13;
            pTxtSymbol.Angle = 0;
            pTxtSymbol.Color = pRgbColor as IColor;
            pTxtSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
            pTxtSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
            //ʹ���߷��Ų���
            ISimpleLineSymbol pHatchSymbol = new SimpleLineSymbolClass();
            pHatchSymbol.Color = pRgbColor as IColor;
            pHatchSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
            pHatchSymbol.Width = 2;
            //ʹ���߷��Ų���С�ģȣ��ԣã�
            ISimpleLineSymbol pHatchSymbol2 = new SimpleLineSymbolClass();
            pHatchSymbol2.Style = esriSimpleLineStyle.esriSLSSolid;
            pHatchSymbol2.Color = pRgbColor as IColor;

            bool bEnds = true;
            bool bEndsOnly = true;
            double dHatchLen = 5;
            double dTxtInterval = 1;
            double dHatchOffset = 0;
            bool bOverRideMajor = false;
            double dMajorAngle = 0;
            string graphicslayername = "Sewer TV Surveys Graphics Layer";
            HatchDraw(ppAxMapControl, pHatchSymbol, pHatchSymbol2, pTxtSymbol, pFeatTVSurveyLayer, bEnds, bEndsOnly, dHatchLen, dTxtInterval, dHatchOffset, dMajorAngle, bOverRideMajor, graphicslayername);

            ppAxMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 49
0
        /// <summary>
        /// ����ע��ʵ��
        /// </summary>
        /// <param name="pITable">���ݱ����</param>
        /// <param name="entinyNode">VCT�ռ�ʵ��ڵ�</param>
        public override void CreateFeature(ITable pITable, EntityNode entinyNode)
        {
            try
            {
                AnnotationNode pAnnotationNode = entinyNode as AnnotationNode;
                if (pAnnotationNode != null)
                {
                    IFeatureClass pFeatureCls = pITable as IFeatureClass;
                    this.Feature = pFeatureCls.CreateFeature();

                    ///��ʶ�븳ֵ
                    int dBSMIndex = -1;
                    dBSMIndex = this.Feature.Fields.FindField(m_strEntityIDFiled);
                    if (dBSMIndex != -1)
                        this.Feature.set_Value(dBSMIndex, pAnnotationNode.EntityID);

                    ///Ҫ�ش��븳ֵ
                    int dSYDMIndex = -1;
                    dSYDMIndex = this.Feature.Fields.FindField(m_strYSDMField);
                    if (dSYDMIndex != -1)
                        this.Feature.set_Value(dSYDMIndex, pAnnotationNode.FeatureCode);

                    IAnnotationFeature pAnnotationFeature = Feature as IAnnotationFeature;
                    if (pAnnotationFeature != null)
                    {
                        /////ע�����ݸ�ֵ
                        ITextElement pTextElement = new TextElementClass();
                        ITextSymbol pTextSymbol = new TextSymbolClass();
                        pTextSymbol.Angle = pAnnotationNode.Angle;

                        pTextElement.Text = pAnnotationNode.Text;
                        pTextElement.Symbol = pTextSymbol;
                        pAnnotationFeature.Annotation = pTextElement as IElement;
                    }

                    IPoint pPoint = new PointClass();
                    pPoint.PutCoords(pAnnotationNode.PointLocation.X, pAnnotationNode.PointLocation.Y);

                    (this.Feature as IFeature).Shape = pPoint;

                    this.Feature.Store();
                }
            }
            catch (Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
            }
        }
		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);
					}
				}
			}
		}
Exemplo n.º 51
0
        private string GetFormattedString(string strTextContent, string strFontName, Single sngFontSizeInPoints, double sngMaxWidthInPoints, long hanging)
        {
            System.Array varWordArray;
            IMxApplication pMxApp = ArcMap.Application as IMxApplication;
            IAppDisplay pAppDisplay = pMxApp.Display;
            IDisplayTransformation pTransformation = pAppDisplay.DisplayTransformation;
            IFontDisp pTextFont = new stdole.StdFontClass() as IFontDisp;
            ITextSymbol pTextSymbol = new TextSymbolClass();
            double dblXSize;
            double dblYSize;
            string strGoodWidth = "";
            string strFinalString = "";
            string strTestString = "";
            int i;

            // Split the string into an array of words
            varWordArray = strTextContent.Split(' ') as System.Array;

            // Set up the Font
            pTextFont.Name = strFontName;
            pTextFont.Size = decimal.Parse(sngFontSizeInPoints.ToString());

            // Setup the Text Symbol
            pTextSymbol.Font = pTextFont;

            // Setup spacing string for hanging indent
            int pSpaces, i3;
            string hangingIndent;
            pAppDisplay.StartDrawing(pAppDisplay.hDC, 0);
            hangingIndent = ""; //minimum hanging indent
            if (hanging > 0)
            {
                pTextSymbol.GetTextSize(pAppDisplay.hDC, pTransformation, " ", out dblXSize, out dblYSize);
                pSpaces = (int)System.Math.Round(hanging / dblXSize);
                for (i3 = 0; i3 == pSpaces; i3++)
                {
                    hangingIndent = hangingIndent + " ";
                }
            } // do nothing if hanging is 0
            pAppDisplay.FinishDrawing(); // done setting up the hanging indent

            // Add each word into the test string and test for width
            pAppDisplay.StartDrawing(pAppDisplay.hDC, 0);
            long linesAdded = 0;

            for (i = 0; i <= (int)varWordArray.GetUpperBound(0); i++)
            {
                if (strGoodWidth != "")
                {
                    strTestString = strGoodWidth + " " + varWordArray.GetValue(i);
                }
                else
                {
                    strTestString = varWordArray.GetValue(i).ToString();
                }

                // Get the TextSize
                if (linesAdded == 0)
                {
                    pTextSymbol.GetTextSize(pAppDisplay.hDC, pTransformation, strTestString, out dblXSize, out dblYSize);
                }
                else
                {
                    pTextSymbol.GetTextSize(pAppDisplay.hDC, pTransformation, "    " + strTestString, out dblXSize, out dblYSize);
                }

                // If the word added is < max width keep adding to the line, else make a new one
                if (dblXSize < sngMaxWidthInPoints)
                {
                    strGoodWidth = strTestString;
                }
                else
                {
                    if (linesAdded == 0)
                    {
                        strFinalString = hangingIndent + strGoodWidth;
                    }
                    else
                    {
                        strFinalString = strFinalString + Environment.NewLine + hangingIndent + "    " + strGoodWidth;
                    }
                    linesAdded = linesAdded + 1;
                    strGoodWidth = varWordArray.GetValue(i).ToString();
                }
            }

            strFinalString = strFinalString + Environment.NewLine + hangingIndent + "    " + strGoodWidth;
            pAppDisplay.FinishDrawing();

            //return strFinalString.Substring(2);
            return strFinalString;
        }
Exemplo n.º 52
0
 public static ITextSymbol CreateTextSymbol(Color pColor, IFontDisp pFont, double pSize, string sText)
 {
     ITextSymbol symbol = new TextSymbolClass();
     symbol.Color = ColorHelper.CreateColor(pColor);
     symbol.Font = pFont;
     symbol.Size = pSize;
     symbol.Text = sText;
     return symbol;
 }
Exemplo n.º 53
0
        //添加文本
        public bool AddText()
        {
            pTextElement = new TextElementClass();
            pTextElement.Text = "输入文本";

            IElement pElment = pTextElement as IElement;
            ITextSymbol pSymbol = new TextSymbolClass();
            pSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
            stdole.Font pFont;
            pFont = new stdole.StdFontClass();
            pFont.Name = "verdana";
            pFont.Size = 40;
            pSymbol.Font = pFont as stdole.IFontDisp;
            pTextElement.Symbol = pSymbol;
            addText(pTextElement, null);
            return true;
        }
Exemplo n.º 54
0
        /// <summary>
        /// ����һ��TextElement
        /// </summary>
        /// <params name="text"></params>
        /// <returns></returns>
        ITextElement CreateTextElement(string text)
        {
            //����һ��TextSymbol
            ITextSymbol txtSymbol = new TextSymbolClass();

            //��������
            Font dispFont = new Font("Arial", 10, FontStyle.Regular);
            txtSymbol.Font = (stdole.IFontDisp)ESRI.ArcGIS.ADF.COMSupport.OLE.GetIFontDispFromFont(dispFont);

            //��������
            txtSymbol.Color = TransColorToAEColor(Color.Red); //��ɫ

            //����һ��TextElement
            ITextElement txtElement = new TextElementClass();
            txtElement.Symbol = txtSymbol;
            txtElement.Text = text;

            return txtElement;
        }
Exemplo n.º 55
0
        private IFeatureClass CreateFeatureClass(IFeatureDataset featureDataset,TableStructureNode tableStructureNode, FeatureCodeNode featureCodeNode)
        {
            try
            {
                if (featureDataset != null)
                {
                    IFeatureClassDescription fcDesc = new FeatureClassDescriptionClass();
                    IObjectClassDescription ocDesc = (IObjectClassDescription)fcDesc;

                    ///�������ݱ��ֶ�
                    IFieldChecker fieldChecker = new FieldCheckerClass();
                    IEnumFieldError enumFieldError = null;
                    IFields validatedFields = CreateFileds(tableStructureNode, featureCodeNode);
                    ///�ֶ���Ϣ��֤
                    IFields fixFields = null;
                    fieldChecker.ValidateWorkspace = featureDataset.Workspace;
                    fieldChecker.Validate(validatedFields, out enumFieldError, out fixFields);

                    ////����FeatureClass
                    IFeatureClass featureClass = null;
                    if (tableStructureNode.IsGeometryTable)
                    {
                        ////������ע��FeatureClass
                        if (featureCodeNode.GeometryType != "")
                        {
                            featureClass = featureDataset.CreateFeatureClass(featureCodeNode.TableName,
                               fixFields, ocDesc.InstanceCLSID, ocDesc.ClassExtensionCLSID,
                               esriFeatureType.esriFTSimple, fcDesc.ShapeFieldName, "");
                        }
                        else
                        {
                            ///����ע��
                            IFormattedTextSymbol pTxtSymbo=new TextSymbolClass();

                            IFeatureWorkspaceAnno pFeatureWorkspaceAnno = this.m_pIDataset.Workspace as IFeatureWorkspaceAnno;

                            IGraphicsLayerScale pGraphSacle = new GraphicsLayerScaleClass();
                            pGraphSacle.Units = ESRI.ArcGIS.esriSystem.esriUnits.esriFeet;
                            //pGraphSacle.ReferenceScale=1000;

                            ISymbolCollection pSymbolCollection = new SymbolCollectionClass();

                            IAnnotateLayerProperties pAnnoLayerProp = new LabelEngineLayerPropertiesClass();
                            pAnnoLayerProp.FeatureLinked = true;
                            pAnnoLayerProp.CreateUnplacedElements = false;
                            pAnnoLayerProp.DisplayAnnotation = true;
                            pAnnoLayerProp.UseOutput = true;

                            IAnnotationExpressionEngine pAnnoExpressionEngine =new AnnotationVBScriptEngineClass();
                            ILabelEngineLayerProperties pLabelEngineLayerProperties = pAnnoLayerProp as ILabelEngineLayerProperties;
                            pLabelEngineLayerProperties.ExpressionParser = pAnnoExpressionEngine;
                            pLabelEngineLayerProperties.Expression = "[DESCRIPTION]";
                            pLabelEngineLayerProperties.IsExpressionSimple = true;
                            pLabelEngineLayerProperties.Offset = 0;
                            pLabelEngineLayerProperties.SymbolID = 0;
                            pLabelEngineLayerProperties.Symbol = pTxtSymbo;

                            IAnnotateLayerTransformationProperties pAnnoLayerTransProp = pAnnoLayerProp as IAnnotateLayerTransformationProperties;
                            pAnnoLayerTransProp.ReferenceScale=200;
                            pAnnoLayerTransProp.Units= ESRI.ArcGIS.esriSystem.esriUnits.esriFeet;
                            pAnnoLayerTransProp.ScaleRatio=1;

                            IAnnotateLayerPropertiesCollection pAnnoLayerProptyCollection =new AnnotateLayerPropertiesCollectionClass();
                           pAnnoLayerProptyCollection.Add(pAnnoLayerProp);

                           featureClass= pFeatureWorkspaceAnno.CreateAnnotationClass(featureCodeNode.TableName,fixFields,ocDesc.InstanceCLSID
                               ,ocDesc.ClassExtensionCLSID,fcDesc.ShapeFieldName,"",featureDataset,null,
                               pAnnoLayerProptyCollection, pGraphSacle, pSymbolCollection,true);
                        }
                    }
                    else
                    {
                        ///�����ǿռ�����
                    }
                    return featureClass;
                }
                return null;
            }
            catch(Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                return null;
            }
        }
Exemplo n.º 56
0
        public void CreateTextElment(double x, double y)
        {
            IPoint pPoint = new PointClass();
            IMap pMap = axMapControl.Map;
            IActiveView pActiveView = pMap as IActiveView;
            IGraphicsContainer pGraphicsContainer;
            IElement pElement = new MarkerElementClass();
            IElement pTElement = new TextElementClass();
            pGraphicsContainer = (IGraphicsContainer)pActiveView;
            IFormattedTextSymbol pTextSymbol = new TextSymbolClass();
            IBalloonCallout pBalloonCallout = CreateBalloonCallout(x, y);
            IRgbColor pColor = new RgbColorClass();
            pColor.Red = 150;
            pColor.Green = 0;
            pColor.Blue = 0;
            pTextSymbol.Color = pColor;
            ITextBackground pTextBackground;
            pTextBackground = (ITextBackground)pBalloonCallout;
            pTextSymbol.Background = pTextBackground;
            ((ITextElement)pTElement).Symbol = pTextSymbol;
            ((ITextElement)pTElement).Text = "测试";
            pPoint.X = x + 42;
            pPoint.Y = y + 42;

            //axMapControl.CenterAt(pPoint);
            pTElement.Geometry = pPoint;
            pGraphicsContainer.AddElement(pTElement, 1);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 57
0
        public static void drawText(string text, IPoint pt, IRgbColor color, AxMapControl mapControl)
        {
            ITextSymbol pTextSymbol = new TextSymbolClass();
            pTextSymbol.Size = 10;
            pTextSymbol.Color = color;
            ITextElement pTextElement = new TextElementClass();
            pTextElement.Text = text;
            pTextElement.ScaleText = false;
            pTextElement.Symbol = pTextSymbol;

            IElement pElement = pTextElement as IElement;
            pElement.Geometry = pt;

            IGraphicsContainer pGraphicsContainer = mapControl.Map as IGraphicsContainer;
            IActiveView pActiveView = mapControl.ActiveView;
            pGraphicsContainer.AddElement(pElement, 0);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 58
0
 public void showAnnotationByScale()
 {
     IMap pMap = axMapControl.Map;
     IFeatureLayer pFeaturelayer = pMap.get_Layer(0) as IFeatureLayer;
     IGeoFeatureLayer pGeoFeatureLayer = pFeaturelayer as IGeoFeatureLayer;
     //创建标注集接口,可以对标注进行添加、删除、查询、排序等操作
     IAnnotateLayerPropertiesCollection pAnnotateLayerPropertiesCollection = new AnnotateLayerPropertiesCollectionClass();
     pAnnotateLayerPropertiesCollection = pGeoFeatureLayer.AnnotationProperties;
     pAnnotateLayerPropertiesCollection.Clear();
     //创建标注的颜色
     IRgbColor pRgbColor = new RgbColorClass();
     pRgbColor.Red = 255;
     pRgbColor.Green = 0;
     pRgbColor.Blue = 0;
     //创建标注的字体样式
     ITextSymbol pTextSymbol = new TextSymbolClass();
     pTextSymbol.Color = pRgbColor;
     pTextSymbol.Size = 12;
     pTextSymbol.Font.Name = "宋体";
     //定义 ILineLabelPosition接口,用来管理line features的标注属性,指定标注和线要素的位置关系
     ILineLabelPosition pLineLabelPosition = new LineLabelPositionClass();
     pLineLabelPosition.Parallel = false;
     pLineLabelPosition.Perpendicular = true;
     pLineLabelPosition.InLine = true;
     //定义 ILineLabelPlacementPriorities接口用来控制标注冲突
     ILineLabelPlacementPriorities pLineLabelPlacementPriorities = new LineLabelPlacementPrioritiesClass();
     pLineLabelPlacementPriorities.AboveStart = 5;
     pLineLabelPlacementPriorities.BelowAfter = 4;
     //定义 IBasicOverposterLayerProperties 接口实现 LineLabelPosition 和 LineLabelPlacementPriorities对象的控制
     IBasicOverposterLayerProperties pBasicOverposterLayerProperties = new BasicOverposterLayerPropertiesClass();
     pBasicOverposterLayerProperties.LineLabelPlacementPriorities = pLineLabelPlacementPriorities;
     pBasicOverposterLayerProperties.LineLabelPosition = pLineLabelPosition;
     pBasicOverposterLayerProperties.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolygon;
     //创建标注对象
     ILabelEngineLayerProperties pLabelEngineLayerProperties = new LabelEngineLayerPropertiesClass();
     //设置标注符号
     pLabelEngineLayerProperties.Symbol = pTextSymbol;
     pLabelEngineLayerProperties.BasicOverposterLayerProperties = pBasicOverposterLayerProperties;
     //声明标注的Expression是否为Simple
     pLabelEngineLayerProperties.IsExpressionSimple = true;
     //设置标注字段
     pLabelEngineLayerProperties.Expression = "[DIQU]";
     //定义IAnnotateLayerTransformationProperties 接口用来控制feature layer的display of dynamic labels
     IAnnotateLayerTransformationProperties pAnnotateLayerTransformationProperties = pLabelEngineLayerProperties as IAnnotateLayerTransformationProperties;
     //设置标注参考比例尺
     pAnnotateLayerTransformationProperties.ReferenceScale = 500000;
     //定义IAnnotateLayerProperties接口,决定FeatureLayer动态标注信息
     IAnnotateLayerProperties pAnnotateLayerProperties = pLabelEngineLayerProperties as IAnnotateLayerProperties;
     //设置显示标注最大比例尺
     pAnnotateLayerProperties.AnnotationMaximumScale = 500000;
     //设置显示标注的最小比例
     pAnnotateLayerProperties.AnnotationMinimumScale = 25000000;
     //决定要标注的要素
     pAnnotateLayerProperties.WhereClause = "DIQU<>'宿州市'";
     //将创建好的标注对象添加到标注集对象中
     pAnnotateLayerPropertiesCollection.Add(pAnnotateLayerProperties);
     //声明标注是否显示
     pGeoFeatureLayer.DisplayAnnotation = true;
     //刷新视图
     this.axMapControl.Refresh();
 }
Exemplo n.º 59
0
        private void CreatePoint(double x, double y)
        {
            IPoint pPoint = new PointClass();
            IMap pMap = axMapControl.Map;
            IActiveView pActiveView = pMap as IActiveView;
            IGraphicsContainer pGraphicsContainer;
            IElement pElement = new MarkerElementClass();

            pGraphicsContainer = (IGraphicsContainer)pActiveView;
            IFormattedTextSymbol pTextSymbol = new TextSymbolClass();
            IBalloonCallout pBalloonCallout = CreateBalloonCallout(x, y);
            IRgbColor pColor = new RgbColorClass();
            pColor.Red = 150;
            pColor.Green = 0;
            pColor.Blue = 0;
            pTextSymbol.Color = pColor;
            ITextBackground pTextBackground;
            pTextBackground = (ITextBackground)pBalloonCallout;
            //pTextSymbol.Background = pTextBackground;
            //((ITextElement)pElement).Symbol = pTextSymbol;
            //((ITextElement)pElement).Text = "测试";
            pPoint.X = x + 42;
            pPoint.Y = y + 42;

            pPoint.PutCoords(x, y);
            ISpatialReferenceFactory pSRF = new SpatialReferenceEnvironmentClass();
            pPoint.SpatialReference = pSRF.CreateProjectedCoordinateSystem(2414);
            pPoint.Project(pSRF.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_Beijing1954));

            pElement.Geometry = pPoint;
            pGraphicsContainer.AddElement(pElement, 1);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Exemplo n.º 60
0
        private List<string> ExportSymbol(IStyleGallery sg,string symbolType, int col, int row, int size,int width, int labelsize, int label_h, int size_w, int size_h, double height, string cat, IPageLayout3 layout)
        {
            List<string> pdfpages = new List<string>();
            IGraphicsContainer con = layout as IGraphicsContainer;
            IPage page = layout.Page;
            int r = 0;
            int c = 0;
            int p = 0;
            IEnumStyleGalleryItem items = sg.get_Items(symbolType, "", cat);
            IStyleGalleryItem item = items.Next();
            while (item != null)
            {
                #region Symbol
                if (symbolType == "Marker Symbols")
                {
                    IMarkerElement mele = new MarkerElementClass();
                    IPoint ptn = new PointClass();
                    ptn.PutCoords(c * size_w + size / 2, height - (r * size_h + size / 2));
                    IElement ele_i = mele as IElement;
                    ele_i.Geometry = ptn;
                    IMarkerSymbol sym_m = item.Item as IMarkerSymbol;
                    sym_m.Size = size;
                    mele.Symbol = sym_m;
                    con.AddElement(ele_i, 0);
                }
                else if (symbolType == "Line Symbols")
                {
                    ILineElement lele = new LineElementClass();
                    IPolyline line = new PolylineClass();
                    IPoint ptn_f = new PointClass();
                    ptn_f.PutCoords(c * size_w + size / 4, height - (r * size_h + size * 3 / 4));
                    IPoint ptn_t = new PointClass();
                    ptn_t.PutCoords(c * size_w + size * 3 / 4, height - (r * size_h + size / 4));
                    line.FromPoint = ptn_f;
                    line.ToPoint = ptn_t;
                    IElement ele_i = lele as IElement;
                    ele_i.Geometry = line;
                    ILineSymbol sym_l = item.Item as ILineSymbol;
                    sym_l.Width = width;
                    lele.Symbol = sym_l;
                    con.AddElement(ele_i, 0);
                }
                else if (symbolType == "Fill Symbols")
                {
                    IRectangleElement fele = new RectangleElementClass();
                    IFillShapeElement fsele = fele as IFillShapeElement;
                    IEnvelope env_f = new EnvelopeClass();
                    env_f.PutCoords(c * size_w + size / 4, height - (r * size_h + size * 3 / 4), c * size_w + size * 3 / 4, height - (r * size_h + size / 4));
                    IElement ele_i = fele as IElement;
                    ele_i.Geometry = env_f;
                    IFillSymbol sym_f = item.Item as IFillSymbol;
                    fsele.Symbol = sym_f;
                    con.AddElement(ele_i, 0);
                }

                #endregion

                if (cbGrid.Checked)
                {
                    #region Grid
                    IEnvelope env_g = new EnvelopeClass();
                    env_g.PutCoords(c * size_w, height - r * size_h, c * size_w + size_w, height - r * size_h - size_h);
                    IRectangleElement gele = new RectangleElementClass();
                    IElement ele_g = gele as IElement;
                    ele_g.Geometry = env_g;
                    IFillSymbol sym_g = new SimpleFillSymbolClass();
                    IRgbColor color_g = new RgbColorClass();
                    color_g.NullColor = true;
                    sym_g.Color = color_g;
                    IFillShapeElement fshp_g = ele_g as IFillShapeElement;
                    fshp_g.Symbol = sym_g;
                    con.AddElement(ele_g, 0);
                    #endregion
                }

                #region Label
                ITextElement tele = new ParagraphTextElementClass();
                IElement ele_t = tele as IElement;
                tele.Text = item.Name;
                IEnvelope env_l = new EnvelopeClass();
                env_l.PutCoords(c * size_w, height - r * size_h - size_h + label_h, c * size_w + size_w, height - r * size_h - size_h);
                env_l.PutCoords(c * size_w, height - r * size_h - size_h + label_h, c * size_w + size_w, height - r * size_h - size_h);
                env_l.PutCoords(c * size_w, height - r * size_h - size_h + label_h, c * size_w + size_w, height - r * size_h - size_h);
                env_l.PutCoords(c * size_w, height - r * size_h - size_h + label_h, c * size_w + size_w, height - r * size_h - size_h);
                env_l.PutCoords(c * size_w, height - r * size_h - size_h + label_h, c * size_w + size_w, height - r * size_h - size_h);
                ele_t.Geometry = env_l;
                ITextSymbol sym_label = new TextSymbolClass();
                sym_label.Size = labelsize/2;
                IRgbColor color = new RgbColorClass();
                color.NullColor = true;
                ISimpleLineSymbol sym_border = new SimpleLineSymbolClass();
                sym_border.Color = color;
                ISymbolBorder border = new SymbolBorderClass();
                border.LineSymbol = sym_border;
                IFrameProperties fp = ele_t as IFrameProperties;
                fp.Border = border;
                con.AddElement(ele_t, 0);
                #endregion

                if (c < col - 1)
                {
                    c++;
                }
                else
                {
                    c = 0;
                    if (r < row - 1)
                    {
                        r++;
                    }
                    else
                    {
                        IActiveView av = layout as IActiveView;
                        string temp_pdf = System.IO.Path.GetTempFileName() + ".pdf";
                        ExportPDF(av, temp_pdf);
                        pdfpages.Add(temp_pdf);
                        con.DeleteAllElements();
                        r = 0;
                        c = 0;
                        p++;
                    }
                }
                item = items.Next();
            }
            if (con.Next() != null)
            {
                IActiveView av = layout as IActiveView;
                string temp_pdf = System.IO.Path.GetTempFileName() + ".pdf";
                ExportPDF(av, temp_pdf);
                pdfpages.Add(temp_pdf);
                con.DeleteAllElements();
            }
            return pdfpages;
        }