ArcEngie开发-添加NeatLine

添加图廓线,图廓线的真实面目是FrameElement,添加方法如下:

        private void wndBtnAddNeatLine_ItemClick(object sender, ItemClickEventArgs e)
        {
            //实验代码:
            //添加整理图廓线  图廓线的真实面目是FrameElement
            FrameElement pFrameElement = new FrameElementClass();
            IFrameElement pIFrameElement = pFrameElement as IFrameElement;
            pIFrameElement.Border = new SymbolBorder();

            //如果要放在页面边缘内部:
            IEnvelope pEnvelope = wndPageLayout.Page.PrintableBounds;
            pFrameElement.Geometry = pEnvelope;
            //这个是Page的边缘,按照这个Envelop,将Border的gap设置为-10即可。
            IFrameProperties pFrameProperties = pIFrameElement as IFrameProperties;
            IBorder pBorder = pFrameProperties.Border;
            if (pBorder != null)
            {
                IFrameDecoration pFrameDecoration = pBorder as IFrameDecoration;
                pFrameDecoration.HorizontalSpacing = -10;
                pFrameDecoration.VerticalSpacing = -10;
            }
            pFrameProperties.Border = pBorder; //注意IFrameDecoration::Border是非引用接口(■―■),因此一定要反代回去,否则值不会改变
            pFrameElement.Geometry = pEnvelope;

            //添加进去。放在页面内部的话,必须创建单独的FrameElement对象
            wndPageLayout.ActiveView.GraphicsContainer.AddElement(pFrameElement as IElement, 0);
            wndPageLayout.ActiveView.Refresh();
        }
上面这段代码,在Page的内部页面边缘添加整理线,如果要把NeatLine放到所有选择了的要素或者所有要素周围,则应该用下面的做法:

        private void wndBtnAddNeatLine_ItemClick(object sender, ItemClickEventArgs e)
        {
            //实验代码:
            //添加整理图廓线  图廓线的真实面目是FrameElement
            FrameElement pFrameElement = new FrameElementClass();
            IFrameElement pIFrameElement = pFrameElement as IFrameElement;
            pIFrameElement.Border = new SymbolBorder();

            //否则,放到所有选择了的要素或者所有要素周围
            IGraphicsContainer graphicsContainer = wndPageLayout.PageLayout as IGraphicsContainer;
            IGraphicsContainerSelect pGraphicsContainerSelect = wndPageLayout.PageLayout as IGraphicsContainerSelect;
            IEnumElement pEnumElement = pGraphicsContainerSelect.SelectedElements;
            IGroupElement pGroupElement = new GroupElementClass();
            pEnumElement.Reset();
            IElement pElement = pEnumElement.Next();

            while (pElement != null)
            {
                pGroupElement.AddElement(pElement);
                pElement = pEnumElement.Next();
            }

            if (pGroupElement.ElementCount != 0)
            {
                //获取包含所有选择要素的最小矩形框
                IEnvelope pEnvelope = new EnvelopeClass();
                IElement pTagGroupElement = pGroupElement as IElement;
                pTagGroupElement.QueryBounds(wndPageLayout.ActiveView.ScreenDisplay as IDisplay, pEnvelope);

                //这种方式获取的矩形框和实用QueryBounds得到的结果一样
                IPolygon pPolygon = new PolygonClass();
                pTagGroupElement.QueryOutline(wndPageLayout.ActiveView.ScreenDisplay as IDisplay, pPolygon);

                pElement = pFrameElement as IElement;
                //
                //如果要组合所有要素,就将GroupElement和新建的FrameElement组合成新的GroupElement,然后加进去
                IGroupElement pGroupElement2 = new GroupElementClass();
                pGroupElement2.AddElement(pTagGroupElement);
                pGroupElement2.AddElement(pElement);
                pElement = pGroupElement2 as IElement;
                //

                //如果不组合,就直接添加新建的GroupElement
                wndPageLayout.ActiveView.GraphicsContainer.AddElement(pElement as IElement, 0);
                wndPageLayout.ActiveView.Refresh();
            }
        }

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

深蓝静音

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值