C#制作鷹眼的詳細(xì)全過(guò)程(帶注釋)實(shí)例代碼
axMapControl1是主控件,axMapControl2是鷹眼控件
要看清楚事件響應(yīng)
1.鷹眼地圖資源載入
privatevoid axMapControl1_OnMapReplaced(object sender, IMapControlEvents2_OnMapReplacedEvent e)
{
//當(dāng)主地圖顯示控件的地圖更換時(shí),鷹眼中的地圖也跟隨更換
axMapControl2.LoadMxFile(axMapControl1.DocumentFilename);
axMapControl2.Extent = axMapControl2.FullExtent;
}
2.繪制鷹眼矩形框
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)生一個(gè)線符號(hào)對(duì)象
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è)置填充符號(hào)的屬性
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. 實(shí)現(xiàn)互動(dòng)
private void axMapControl2_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
{
IPoint pPt=new PointClass ();
pPt.PutCoords (e.mapX ,e.mapY );
//改變主控件的視圖范圍
axMapControl1 .CenterAt (pPt );
}
相關(guān)文章
Unity實(shí)現(xiàn)模型點(diǎn)擊事件的方法
這篇文章主要介紹了Unity實(shí)現(xiàn)模型點(diǎn)擊事件的方法,本文通過(guò)多種方法給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-05-05c# 調(diào)用Surfer軟件,添加引用的具體操作方法
本篇文章主要是對(duì)c#中調(diào)用Surfer軟件,添加引用的具體操作方法進(jìn)行了介紹,需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助2014-01-01C#操作mysql數(shù)據(jù)庫(kù)的代碼實(shí)例
這篇文章為大家提供了一個(gè)C#操作mysql數(shù)據(jù)庫(kù)的實(shí)例,大家可以參考使用2013-11-11