修改PageLayout NorthArrow 备注

修改PageLayout中的元素(NorthArrow)获取得到 MapSurroundFrame后,不能直接修改MapSurround属性,否则在删除元素时会出错.首先要将styleGalleryItem.Item 转换为 IMarkerNorthArrow 然后修改 MarkerSymbol 属性

 public override void OnClick()
        {
            // TODO: Add ElementProp.OnClick implementation
            IGraphicsContainerSelect pPageLayoutGraphicsSelect = m_pageLayoutCtrl.PageLayout as IGraphicsContainerSelect;
            IElement pElement = pPageLayoutGraphicsSelect.SelectedElement(0);
            IElementProperties pElementProp = pElement as IElementProperties;
            IStyleGalleryItem styleGalleryItem;

            IEnvelope eExtent=pElement.Geometry.Envelope;  //只在图形的最初始范围

            SymbolForm symbolForm = new SymbolForm();
            //Get the IStyleGalleryItem
        //    System.Windows.Forms.MessageBox.Show(pElementProp.Type);
       //     System.Windows.Forms.MessageBox.Show(pElementProp.Name);
         
            if (pElement is IMapSurroundFrame)
            {
                System.Windows.Forms.MessageBox.Show("是一个IMapSurroundFrame");
                IMapSurroundFrame pMapSf=pElement as IMapSurroundFrame;
               
                IMapSurround pMapSurround = pMapSf.MapSurround;
                if (pMapSurround is ILegend)
                {
                    ILegend pLgd = pMapSurround as ILegend;
                    System.Windows.Forms.MessageBox.Show(pLgd.Title);             
                }
                else if (pMapSurround is IMarkerNorthArrow)
                {
                    styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassNorthArrows);

                   // pMapSf.MapSurround =  (IMapSurround)styleGalleryItem.Item;
                    symbolForm.Dispose();
                    INorthArrow pNArrow= (INorthArrow)pMapSf.MapSurround;
                    IMarkerNorthArrow pmNArrow = (IMarkerNorthArrow)pMapSf.MapSurround;
                  //  ICharacterMarkerSymbol pMarker = pmNArrow.MarkerSymbol as ICharacterMarkerSymbol;
                    IMarkerNorthArrow pMakerNArrowItem = styleGalleryItem.Item as IMarkerNorthArrow;
             //       IMarkerSymbol pMarker=;
                   
                    //cMs.CharacterIndex = 34;
                    pmNArrow.MarkerSymbol = pMakerNArrowItem.MarkerSymbol;

                //    IStyleGalleryItem pMark = styleGalleryItem.Item as ICharacterMarkerSymbol;
                    // if (pMark==null) return;
                 //   pmNArrow.MarkerSymbol = pMark;
                    // pMapSf.MapSurround = pMark;

                    IColor color1=new RgbColorClass();
                    color1.RGB=34567;
                    pNArrow.Color = color1;
                    pNArrow.Refresh();
                }
           //     m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics,pMapSf, null);

                //QI to IElement and set its geometry
                 //pElement.Geometry = envelope;
            }
            else if (pElement is IPictureElement)
            {
                System.Windows.Forms.MessageBox.Show("是一个IPictureElement");

            }
            else if (pElement is ITextElement)
            {
                System.Windows.Forms.MessageBox.Show("是一个Textelement");
                ITextElement txtElement = pElement as ITextElement;
                txtElement.Text = "修改标题";
       
            }
            m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics,null, null);
        }

posted @ 2008-02-19 21:47 xc# 阅读(69) 评论(0)  编辑 收藏 所属分类: GIS相关

标题  
姓名  
主页
Email (只有博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
 
另存  打印
最新IT新闻:
· Joost借道TOM在线 将正式进军中国
· 微软副总裁公开承认Vista存在问题
· 互联网DNS存在重大漏洞 黑客可能控制网络流量
· Opera提出网络标准课程 发布标准教育倡议
· SubSonic 2.1 版本发布