欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#制作鷹眼的詳細全過程(帶注釋)實例代碼

 更新時間:2013年03月16日 22:42:46   作者:  
C#制作鷹眼的詳細全過程(帶注釋)實例代碼,需要的朋友可以參考一下

axMapControl1是主控件,axMapControl2是鷹眼控件

要看清楚事件響應(yīng)

 

1.鷹眼地圖資源載入

復(fù)制代碼 代碼如下:

privatevoid axMapControl1_OnMapReplaced(object sender, IMapControlEvents2_OnMapReplacedEvent e)

        {

            //當主地圖顯示控件的地圖更換時,鷹眼中的地圖也跟隨更換

            axMapControl2.LoadMxFile(axMapControl1.DocumentFilename);

            axMapControl2.Extent = axMapControl2.FullExtent;

        }


2.繪制鷹眼矩形框
復(fù)制代碼 代碼如下:

private void axMapControl1_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e)

        {

 

            // 得到新范圍

            IEnvelope pEnv = (IEnvelope)e.newEnvelope;

 

            IGraphicsContainer pGra = axMapControl2.Map as IGraphicsContainer;

            IActiveView pAv = pGra as IActiveView;

            //在繪制前,清除axMapControl2中的任何圖形元素

            pGra.DeleteAllElements();

 

            IRectangleElement pRectangleEle = new RectangleElementClass();

            IElement pEle = pRectangleEle as IElement;

            pEle.Geometry = pEnv;

 

            //設(shè)置鷹眼圖中的紅線框

            IRgbColor pColor = new RgbColorClass();

            pColor.Red = 255;

            pColor.Green = 0;

            pColor.Blue = 0;

            pColor.Transparency = 255;

            //產(chǎn)生一個線符號對象

            ILineSymbol pOutline = new SimpleLineSymbolClass();

            pOutline.Width = 2;

            pOutline.Color = pColor;

 

            //設(shè)置顏色屬性

            pColor = new RgbColorClass();

            pColor.Red = 255;

            pColor.Green = 0;

            pColor.Blue = 0;

            pColor.Transparency = 0;

            //設(shè)置填充符號的屬性

            IFillSymbol pFillSymbol = new SimpleFillSymbolClass();

            pFillSymbol.Color = pColor;

            pFillSymbol.Outline = pOutline;

 

            IFillShapeElement pFillShapeEle = pEle as IFillShapeElement;

            pFillShapeEle.Symbol = pFillSymbol;

            pGra.AddElement((IElement)pFillShapeEle, 0);

            pAv.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

        }
 


3. 實現(xiàn)互動
復(fù)制代碼 代碼如下:

   private void axMapControl2_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)

        {

            IPoint pPt=new PointClass ();

            pPt.PutCoords (e.mapX ,e.mapY );

            //改變主控件的視圖范圍

            axMapControl1 .CenterAt (pPt );

        }


相關(guān)文章

最新評論