基于插件技术的GIS应用框架(C# + ArcEngine9.3)(八)
--------------------------插件初始化(4)
上一小节中,我们介绍了命令插件如何调用地图编辑引擎来实现相应的编辑操作;与此相类似,我们同样可以通过编辑引擎接口设置编辑引擎当前的编辑任务,草图工具则通过读取框架对象的当前编辑任务来创建不同类型的FeedBack,从而绘制出草图,并输出这个草图的Geometry对象返回给编辑任务,编辑任务则通过获取草图工具输出的Geometry,来进行相应的图形处理。
编辑任务 - 分割图形,如何实现呢?首先我们看分割图形任务的实现类,代码如下:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Windows.Forms;
using esriCarto;
using esriControls;
using esriSystem;
using esriDisplay;
using esriGeometry;
using esriGeoDatabase;
using AxeMap.AxeMapEngine;
using AxeMap.Library;
using AxeMap.AxeMapEngine.Interface;
namespace AxeMap.AxeMapEngine.Implement
{
public class AxCutFeature : IAxEditTask
{
private IAxApplication _App;
/// <summary>
/// Name
/// </summary>
public string Name
{
get
{
return "Cut Feature";
}
}
/// <summary>
/// Enabled
/// </summary>
public bool Enabled
{
get
{
esriGeometryType pType;
if ((_App.MapEngine.CurrentFeatureLayer == null) || (!_App.MapEngine.IsBeingEdited))
{
return false;
}
else
{
pType = _App.MapEngine.CurrentFeatureLayer.FeatureClass.ShapeType;
if ((pType == esriGeometryType.esriGeometryPolygon) || (pType == esriGeometryType.esriGeometryPolyline))
{
return (_App.MapEngine.CurrentFeatureLayer as IFeatureSelection).SelectionSet.Count > 0;
}
else
{
return false;
}
}
}
}
/// <summary>
/// GeometyType
/// </summary>
public esriGeometry.esriGeometryType GeometyType
{
get
{
return esriGeometryType.esriGeometryPolyline;
}
}