//1局部刷新
pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics,null, null);
PartialRefresh
参数 Map视图 Layout视图
esriViewBackground Map grids Page/snap grid
esriViewGeography Layers Unused
esriViewGeoSelection Feature selection Unused
esriViewGraphics Labels/graphics Graphics
esriViewGraphicSelection Graphic selection Element selection
esriViewForeground Unused Snap guides
//3TOC符号选择器
new ToolbarMenuClass()
.AddItem(new RemoveLayer(), -1, 0, false, esriCommandStyles.esriCommandStyleTextOnly);
.AddItem(new ZoomToLayer(), -1, 1, true, esriCommandStyles.esriCommandStyleTextOnly);
.AddItem(object item, int SubType = 0, int index = -1, bool beginGroup = false, esriCommandStyles Style = esriCommandStyles.esriCommandStyleIconAndText);
axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
esriTOCControlItem item=esriTOCControlItem.esriTOCControlItemNone;
IBasicMap map=null;//返回点击的Map
//返回点击的东西的类型(None:没有对象,Map对象,Layer对象,Heading对象的标题,LegendClass对象)
ILayer layer=null;//返回点击的图层
object other=null;//返回图例组对象LegendGroup
object index=null;//返回图例组中图例类索引,根据索引和图例组可获得特定的图例类
//4鹰眼
private void axMapControl1_OnExtentUpdated(object sender ,IMapControlEvents2_OnExtentUpdatedEvent e)
{
IGraphicsContainer pGC = axMapControl2.Map as IGraphicsContainer;
pGC.DeleteAllElements();
IRgbColor color=new RgbColorClass();
color.Red=255;
ISimpleLineSymbol pSLS=new SimpleLineSymbolClass();
pSLS.Color=color;
ISimpleFillSymbol pSFS=new SimpleFillSymbolClass();
color=new RgbColorClass();
color.Transparency=0;
pSFS.Color=color;
pSFS.Outline=pSLS;
IElement pE=new RectangleElementClass();
pE.Geometry=(IEnvelope)e.newEnvelope;
IFillShapeElement pFSE=pE as IFillShapeElement;
pFSE.Symbol=pSFS;
pGC.AddElement(pFSE as IElement,0);
axMapControl2.Refresh();
}
private void axMapControl1_OnMapReplaced(object sender ,IMapControlEvents2_OnMapReplacedEvent e)
{
if (axMapControl1.LayerCount > 0)
{
axMapControl2.Map = new MapClass();
for (int i = 0; i <= axMapControl1.Map.LayerCount - 1; i++)
{
axMapControl2.AddLayer(axMapControl1.get_Layer(i));
}
axMapControl2.Extent = axMapControl1.Extent;
axMapControl2.Refresh();
}
}
private void axMapControl2_OnMouseMove(object sender ,IMapControlEvents2_OnMouseMoveEvent e)
{
if (e.button == 1)
{
IPoint pPoint = new PointClass();
pPoint.PutCoords(e.mapX, e.mapY);
axMapControl1.CenterAt(pPoint);
axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null,
null);
}
}
private void axMapControl2_OnMouseDown(object sender ,IMapControlEvents2_OnMouseDownEvent e)
{
if (axMapControl2.Map.LayerCount > 0)
{
if (e.button == 1)
{
IPoint pPoint = new PointClass();
pPoint.PutCoords(e.mapX, e.mapY);
axMapControl1.CenterAt(pPoint);
axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null,
null);
}
else if (e.button == 2)
{
IEnvelope pEnv = axMapControl2.TrackRectangle();
axMapControl1.Extent = pEnv;
axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null,
null);
}
}
}
//5屏幕坐标转地图坐标
using ESRI.ArcGIS.Display;
IScreenDisplay screenDisplay = activeView.ScreenDisplay;
IDisplayTransformation displayTransformation = screenDisplay.DisplayTransformation;
displayTransformation.ToMapPoint(screenPoint.X, screenPoint.Y);
//更新axPageLayoutControl
IObjectCopy objectCopy = new ObjectCopyClass();
object toOverwriteMap = axPageLayoutControl1.ActiveView.FocusMap;//axPageLayoutControl1的当前数据框
objectCopy.Overwrite(objectCopy.Copy(axMapControl1.Map), ref toOverwriteMap);//用当前axMapControl1的数据框替换axPageLayoutControl1的数据框