zoukankan      html  css  js  c++  java
  • ArcEngine实现pagelayout中文本元素的属性对话框

    1. 效果如上图,有点难看

    源码如下

    public partial class Properties : Form
        {
            IPageLayoutControlDefault pPageLayout = null;
            ITextElement pTextElement = null;
            ITextSymbol pTextSymbol = null;
            ICharacterOrientation pCharacterOrientation = null;
            IGraphicsContainer pGraphicsContainer = null;

            public Properties(IPageLayoutControlDefault pageLayout,ITextElement textElement)
            {
                InitializeComponent();
                pPageLayout = pageLayout;
                pTextElement = textElement;
                pTextSymbol = pTextElement.Symbol;
                pGraphicsContainer = pageLayout.ActiveView.GraphicsContainer;
            }

            private void Properties_Load(object sender, EventArgs e)
            {
                textBox1.Text = pTextElement.Text;
                textBox2.Text = pTextSymbol.Font.Name + "  " + pTextSymbol.Font.Size.ToString();
                numericUpDown1.Value = (decimal)(pTextSymbol.Angle);
                checkB.Checked = pTextSymbol.Font.Bold;
                checkU.Checked = pTextSymbol.Font.Underline;
                checkI.Checked = pTextSymbol.Font.Italic;

                pCharacterOrientation = pTextSymbol as ICharacterOrientation;
                checkO.Checked = pCharacterOrientation.CJKCharactersRotation;
            }

            private void buttonChange_Click(object sender, EventArgs e)     //更改字体
            {
                FontDialog fontDialog = new FontDialog();
                if (fontDialog.ShowDialog() == DialogResult.OK)
                {
                    Font selectFont = fontDialog.Font;
                    textBox2.Text = selectFont.Name + "  " + selectFont.Size.ToString();
                    stdole.IFontDisp pFont = ESRI.ArcGIS.ADF.COMSupport.OLE.GetIFontDispFromFont(selectFont) as stdole.IFontDisp;

                    pTextSymbol.Font = pFont;
                }
            }

            private void buttonOK_Click(object sender, EventArgs e)     //确定
            {
                pCharacterOrientation = pTextSymbol as ICharacterOrientation;
                pCharacterOrientation.CJKCharactersRotation = checkO.Checked;

                stdole.IFontDisp pFont = pTextSymbol.Font;
                pFont.Bold = checkB.Checked;
                pFont.Underline = checkU.Checked;
                pFont.Italic = checkI.Checked;
                pTextSymbol.Font = pFont;

                pTextElement.Text = textBox1.Text;
                pTextElement.Symbol = pTextSymbol;
                pGraphicsContainer.UpdateElement(pTextElement as IElement);
                pPageLayout.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                this.Close();
                this.Dispose();
            }

            private void buttonCancel_Click(object sender, EventArgs e)     //取消
            {
                this.Close();
                this.Dispose();
               
            }

          


        }

    使用时要在主界面中的Pagelayout空间中编写双击事件,如下

    private void axPageLayoutControl1_OnDoubleClick(object sender, IPageLayoutControlEvents_OnDoubleClickEvent e)
            {
                IElement pelement, selectElement = null;

                IGraphicsContainerSelect pGraphicsContainerSelect = pPageLayout.PageLayout as IGraphicsContainerSelect;
                IGraphicsContainer pGraphicsContainer = pPageLayout.PageLayout as IGraphicsContainer;
                pGraphicsContainer.Reset();
                pelement = pGraphicsContainer.Next();
               
                while (pelement != null)
                {
                    if (pelement.HitTest(e.pageX, e.pageY, 0.1))
                    {
                        if (pelement is ITextElement)
                        {
                            selectElement = pelement;
                        }

                    }

                    pelement = pGraphicsContainer.Next();
                }

                if (selectElement is ITextElement)
                {
                    Properties propertiesForm = new Properties(pPageLayout, selectElement as ITextElement);
                    propertiesForm.Visible = true;
                }

            }

    没有做文本元素位置选择的功能,感觉那个作用作用不大,因为位置可以通过Select Element工具调整

  • 相关阅读:
    ubuntu12.04 LTS 安装vmware 错误解决方法
    Linux 下的Bluetooth 架构 分类: Android驱动 20120316 11:07 492人阅读 评论(0) 收藏 举报 实战Linux Bluetooth编程(一) 协议栈概述
    通过DEFINE 生存config.h 配置
    Git的初次使用 ; Git常用命令查询 ; Git push ; Git pull 20111216 17:32 在介绍安装和简单使用前,先看一下百度百科中的简介吧: ———————————
    Android BCM4330 蓝牙BT驱动调试记录
    Linux的cpufreq(动态变频)技术
    高通平台android开发总结
    ssh 客户端配置文件
    Jprofile使用随笔_1_安装与监控linux
    服务器cpu占用100%,如何排查(java进程&sql)
  • 原文地址:https://www.cnblogs.com/caodajieup/p/2193891.html
Copyright © 2011-2022 走看看