出圖時加上指北針的代碼

protected virtual void PutNorthArrow()
        {//地圖指北針 目前沒有處理   2007-10-22 by xxd
            double xMin,xMax,yMin,yMax;
            IEnvelope aFrameExtent=(this.MapFrame as IElement).Geometry .Envelope ;
            xMin = aFrameExtent.XMax-0.1-2;//指北針的寬度爲2,高度爲3,位置距離地圖最上角0.1 0.1
            xMax = aFrameExtent.XMax-0.1;
            yMin = aFrameExtent.YMax-0.1-3;
            yMax = aFrameExtent.YMax-0.1;
            IEnvelope pEnv =new EnvelopeClass();
            pEnv.PutCoords( xMin,yMin,xMax,yMax);
            UID pID = new  UIDClass();
            pID.Value = "esriCarto.MarkerNorthArrow";
            IMapSurround pMapSurround  = this.CreateSurround(pID,pEnv,"North Arrow",this.MapFrame,this.PageLayout.PageLayout);
            IMarkerNorthArrow pMarkerNorthArrow = pMapSurround as IMarkerNorthArrow; //QI 
            ICharacterMarkerSymbol pCharacterMarkerSymbol = pMarkerNorthArrow.MarkerSymbol as ICharacterMarkerSymbol; //clones the symbol 
            pCharacterMarkerSymbol.CharacterIndex = 167 ;//change the symbol 
            pCharacterMarkerSymbol.Color = GeoUtilities.CreateColor (0,0,0);
            pCharacterMarkerSymbol.Angle = 0;
            pCharacterMarkerSymbol.Size = 100;
            pMarkerNorthArrow.MarkerSymbol = pCharacterMarkerSymbol;//'set it back  
            
//            pEnv.PutCoords(1, 1, 3.4, 2.4);
//            pID.Value = "esriCarto.Legend";//增加legend
//            pMapSurround = CreateSurround(pID, pEnv, "Legend", this.MapFrame,this.PageLayout.PageLayout); //Refresh the graphics 
           
        }
        public IMapSurround CreateSurround(UID pID, IEnvelope pEnv,string strName,IMapFrame pMapFrame,IPageLayout pPageLayout)
        {
            IGraphicsContainer pGraphicsContainer = pPageLayout as IGraphicsContainer;
            IActiveView pActiveView = pPageLayout as IActiveView;
            IMapSurroundFrame  pMapSurroundFrame = pMapFrame.CreateSurroundFrame(pID, null) ;//MapSurroundFrames are related to MapFrames MapFrames hold Maps
            pMapSurroundFrame.MapSurround.Name = this.ElementNamePrefix+strName; //Set the geometry of the MapSurroundFrame to give it a location 
            //Activate it and add it to the PageLayout's graphics container
            IElement pElement = pMapSurroundFrame as IElement;  //MapSurrounds are held in a MapSurroundFram
            pElement.Geometry = pEnv;
            pElement.Activate(pActiveView.ScreenDisplay); //'Allow the legend frame size to be altered after the legend has been  'added to the GraphicsContainer 
            ITrackCancel PTrack = new CancelTrackerClass();
            pElement.Draw(pActiveView.ScreenDisplay, PTrack );
            pGraphicsContainer.AddElement(pElement, 0 );
            //Re-apply the change to the Legend MapSurroundFrame Geometry 
            //pElement.Geometry = pEnv ;
            return pMapSurroundFrame.MapSurround;
        }
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章