zoukankan      html  css  js  c++  java
  • arcengine C# 布局插入文本

     using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using ESRI.ArcGIS.Controls;
    using ESRI.ArcGIS.Geometry;
    using ESRI.ArcGIS.Analyst3D;
    using ESRI.ArcGIS.Carto;
    using ESRI.ArcGIS.Display;
    using ESRI.ArcGIS.esriSystem;
    using ESRI.ArcGIS.Geodatabase;
    using ESRI.ArcGIS.GeoAnalyst;
    using stdole;

    public 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 = 20;

                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);

            }

            private void button2_Click_1(object sender, EventArgs e)
            {
                AddTextElement(this.axPageLayoutControl1, 10, 10, "gisoracle欢迎你 Email:gisoracle@126.com,或QQ:276529800联系");
            }
    参考:http://www.gisbase.cn/chxnews.asp?id=1019

  • 相关阅读:
    py笔记之循环结构
    PY学习记录#5
    PY学习记录#4
    py笔记之选择结构
    PY学习记录#3
    分享一个可以随时随地写代码的工具
    PY学习记录#2
    日记啊
    Tarjan学习笔记
    Docker commands
  • 原文地址:https://www.cnblogs.com/gisoracle/p/1701965.html
Copyright © 2011-2022 走看看