ArcEngie开发-添加MapFrame

下面是添加图框的基本方法和步骤:

///<summary>
///添加地图框架
///</summary>
///<paramname="sender"></param>
///<paramname="e"></param>
private void wndBtnAddMapFrame_ItemClick(objectsender, ItemClickEventArgse)
{
   IEnvelope envelop= new EnvelopeClass();
   envelop.XMin= 2;
   envelop.YMin= 2;
   envelop.XMax= 5;
   envelop.YMin= 5;
   IMapFrame p_MapFrame= newMapFrameClass();
   p_MapFrame.Map=new MapClass();
   IElement ele= p_MapFrame as IElement;
   wndPageLayout.AddElement((IElement)p_MapFrame,envelop,null, null, 0);
 
   IGraphicsContainerSelect graphSelect = wndPageLayout.PageLayoutas IGraphicsContainerSelect;
   graphSelect.SelectElement(ele);
   wndPageLayout.Refresh(esriViewDrawPhase.esriViewGraphicSelection,null,null);
}
本例中自己定义了一个Envelope,在实际开发中,这个图框的大小可以通过绘制矩形框获取,或者根据现有页面自动生成,如下:
        private void wndBtnAddMapFrame_ItemClick(object sender, ItemClickEventArgs e)
        {            
            double width, height;
            wndPageLayout.Page.QuerySize(out width, out height);

            IEnvelope pEnvelop = new EnvelopeClass();
            pEnvelop.PutCoords(0, 0, width, height);
            pEnvelop.Expand(0.5, 0.3, true);

            IMapFrame p_MapFrame = new MapFrameClass();
            IMap pMap = new MapClass();
            p_MapFrame.Map = pMap;
            p_MapFrame.Map.Name = "New Data Frame";
            IElement ele = p_MapFrame as IElement;
            wndPageLayout.AddElement((IElement)p_MapFrame, pEnvelop, null, null, 0);

            IGraphicsContainerSelect graphSelect = wndPageLayout.PageLayout as IGraphicsContainerSelect;
            graphSelect.SelectElement(ele);
            wndPageLayout.Refresh(esriViewDrawPhase.esriViewGraphics, null, null);     
        }

当然,与这种处理方法效果等价的最简单的办法是直接调用添加MapFrame的ICommand命令,如下:

            ICommand pCmd = new ControlsPageNewMapCommand();
            pCmd.OnCreate(wndPageLayout.Object);
            pCmd.OnClick();  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

深蓝静音

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

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

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

打赏作者

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

抵扣说明:

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

余额充值