AE中实现Control中的各种图形工具的方法
添加命名空间
using ESRI.ArcGIS.SystemUI;
using ESRI.ArcGIS.Controls;
A类:前面有Controls 后面有tool的工具都可以用同一类的代码实现(最后的tool或toolclass都可以)
示例:
private void 放大ToolStripMenuItem_Click(object sender, EventArgs e)
{
ICommand Cmd = new ControlsMapZoomInTool();
Cmd.OnCreate(this.axMapControl1.Object);
this.axMapControl1.CurrentTool = Cmd as ITool;
}
同类的方法中用到此方法的还有以下等:
放大: ICommand Cmd = new ControlsMapZoomInTool();
缩小: ControlsMapZoomOutTool Cmd = new ControlsMapZoomOutTool();
漫游: ControlsMapPanTool Cmd = new ControlsMapPanTool();
绘制矩形:ControlsNewRectangleTool Cmd = new ControlsNewRectangleTool();
绘制圆:ControlsNewCircleTool Cmd = new ControlsNewCircleTool();
绘制椭圆: ControlsNewEllipseTool Cmd = new ControlsNewEllipseTool();
绘制曲线: ControlsNewCurveTool Cmd = new ControlsNewCurveTool();
绘制直线: ControlsNewLineTool Cmd = new ControlsNewLineTool();
绘制点标记: ControlsNewMarkerTool Cmd = new ControlsNewMarkerTool();
流方法绘图: ControlsNewFreeHandTool Cmd = new ControlsNewFreeHandTool();
墨水绘图: ControlsInkPenTool Cmd = new ControlsInkPenTool();
ControlsInkGenericDrawTool Cmd = new ControlsInkGenericDrawTool();
旋转工具: ControlsMapRotateTool Cmd = new ControlsMapRotateTool();
旋转图形: ControlsRotateElementTool Cmd = new ControlsRotateElementTool();
选择要素:ControlsSelectFeaturesTool Cmd = new ControlsSelectFeaturesTool();
选择图形: ControlsSelectTool Cmd = new ControlsSelectTool();
属性工具: ControlsMapIdentifyTool Cmd = new ControlsMapIdentifyTool();
测量工具: ControlsMapMeasureTool Cmd = new ControlsMapMeasureTool();
超链接工具: ControlsMapHyperlinkTool Cmd = new ControlsMapHyperlinkTool();
B类:Command命令的实现,前面是Controls 后面是CommandClass命令的都可以用这个程序
示例:
全图显示:
ICommand Cmd = new ControlsMapFullExtentCommandClass();
Cmd.OnCreate(this.axMapControl1.Object);
Cmd.OnClick();
类似可以实现的功能有:
坐标查找: ICommand Cmd = new ControlsMapGoToCommand();
查找命令:ICommand Cmd = new ControlsMapFindCommandClass();
创建书签: ICommand Cmd = new ControlsMapCreateBookmarkCommandClass();
墨迹设置:ICommand Cmd = new ControlsInkOptionsCommandClass();
清楚旋转: ICommand Cmd = new ControlsMapClearMapRotationCommandClass();
转到页底: ICommand Cmd = new ControlsMapPageDownCommandClass();
转到页左: ICommand Cmd = new ControlsMapPageLeftCommandClass();
转到页右: ICommand Cmd = new ControlsMapPageRightCommandClass();
转到页上:ICommand Cmd = new ControlsMapPageUpCommandClass();
向右: ICommand Cmd = new ControlsMapRightCommandClass();
向上: ICommand Cmd = new ControlsMapUpCommandClass();
中心放大:ICommand Cmd = new ControlsMapZoomInFixedCommandClass();
中心缩小: ICommand Cmd = new ControlsMapZoomOutFixedCommandClass();
后一视图: ICommand Cmd = new ControlsMapZoomToLastExtentBackCommandClass();
前一视图: ICommand Cmd = new ControlsMapZoomToLastExtentForwardCommandClass();
地方查找: ICommand Cmd = new ControlsMyPlacesCommandClass();
打开文档: ICommand Cmd = new ControlsOpenDocCommandClass();
撤销: ICommand Cmd = new ControlsRedoCommandClass();
图形向左旋转: ICommand Cmd = new ControlsRotateLeftCommandClass();
向右旋转: ICommand Cmd = new ControlsRotateRightCommandClass();
文档另存为: ICommand Cmd = new ControlsSaveAsDocCommandClass();
选择第一个图层中的所有元素:ICommand Cmd = new ControlsSelectAllCommandClass();
选择屏幕中的所有部分: ICommand Cmd = new ControlsSelectScreenCommandClass();
撤销命令:ICommand Cmd = new ControlsUndoCommandClass();
缩放到被选择的部分: ICommand Cmd = new ControlsZoomToSelectedCommandClass();
************************************************************
补充:上面的某些功能的其他实现方法
几个特殊的方法:
private void 全图ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.axMapControl1.Extent = this.axMapControl1.FullExtent;
}
private void 刷新ToolStripMenuItem_Click(object sender, EventArgs e)
{
axMapControl1.Refresh();
}
private void 中心放大ToolStripMenuItem_Click(object sender, EventArgs e)
{
IEnvelope objEnvelope = null;
objEnvelope = axMapControl1.Extent;
objEnvelope.Expand(0.2, 0.2, true);
axMapControl1.Extent = objEnvelope;
}
private void 中心缩小ToolStripMenuItem_Click(object sender, EventArgs e)
{
IEnvelope objEnvelope = null;
objEnvelope = axMapControl1.Extent;
objEnvelope.Expand(2, 2, true);
axMapControl1.Extent = objEnvelope;
}
private void 前一视图ToolStripMenuItem_Click(object sender, EventArgs e)
{
IExtentStack pExtentStack = null;
pExtentStack = axMapControl1.ActiveView.ExtentStack;
if (pExtentStack.CanUndo())
{
pExtentStack.Undo();
}
axMapControl1.Refresh();
}
private void 后一视图ToolStripMenuItem_Click(object sender, EventArgs e)
{
IExtentStack pExtentStack = null;
pExtentStack = axMapControl1.ActiveView.ExtentStack;
if (pExtentStack.CanRedo())
{
pExtentStack.Redo();
}
axMapControl1.Refresh();
}