ArcGIS Engine - 自定义编辑器,绘制点、线、面、弧线,编辑折点。

在这里插入图片描述

1.绘制点

using System;
using System.Drawing;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.ADF.CATIDs;
using ESRI.ArcGIS.Controls;
using System.Windows.Forms;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;

namespace Com.XXW.NTSL.EditorTool
{
    /// <summary>
    /// Summary description for DrawPointTool.
    /// </summary>
    [Guid("30ce6ad4-971f-4260-99df-c12bdd650c39")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("Com.XXW.NTSL.EditorTool.DrawPointTool")]
    public sealed class DrawPointTool : BaseTool
    {
        #region COM Registration Function(s)
        [ComRegisterFunction()]
        [ComVisible(false)]
        static void RegisterFunction(Type registerType)
        {
            // Required for ArcGIS Component Category Registrar support
            ArcGISCategoryRegistration(registerType);

            //
            // TODO: Add any COM registration code here
            //
        }

        [ComUnregisterFunction()]
        [ComVisible(false)]
        static void UnregisterFunction(Type registerType)
        {
            // Required for ArcGIS Component Category Registrar support
            ArcGISCategoryUnregistration(registerType);

            //
            // TODO: Add any COM unregistration code here
            //
        }

        #region ArcGIS Component Category Registrar generated code
        /// <summary>
        /// Required method for ArcGIS Component Category registration -
        /// Do not modify the contents of this method with the code editor.
        /// </summary>
        private static void ArcGISCategoryRegistration(Type registerType)
        {
            string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
            ControlsCommands.Register(regKey);

        }
        /// <summary>
        /// Required method for ArcGIS Component Category unregistration -
        /// Do not modify the contents of this method with the code editor.
        /// </summary>
        private static void ArcGISCategoryUnregistration(Type registerType)
        {
            string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
            ControlsCommands.Unregister(regKey);

        }

        #endregion
        #endregion

        private IHookHelper m_hookHelper;
        private ILayer pLayer;

        public DrawPointTool(ILayer Layer)
        {
            pLayer = Layer;

            //
            // TODO: Define values for the public properties
            //
            base.m_category = ""; //localizable text 
            base.m_caption = "";  //localizable text 
            base.m_message = "";  //localizable text
            base.m_toolTip = "";  //localizable text
            base.m_name = "";   //unique id, non-localizable (e.g. "MyCategory_MyTool")
            try
            {
                //
                // TODO: change resource name if necessary
                //
                string bitmapResourceName = GetType().Name + ".bmp";
                base.m_bitmap = new Bitmap(GetType(), bitmapResourceName);
                base.m_cursor = new System.Windows.Forms.Cursor(GetType(), GetType().Name + ".cur");
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");
            }
        }

        #region Overridden Class Methods

        /// <summary>
        /// Occurs when this tool is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            if (m_hookHelper == null)
                m_hookHelper = new HookHelperClass();

            m_hookHelper.Hook = hook;

            // TODO:  Add DrawPointTool.OnCreate implementation
        }

        /// <summary>
        /// Occurs when this tool is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add DrawPointTool.OnClick implementation
        }

        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button == 1)
            {
                IPoint pPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

                //将绘制的点保存到图层
                AddFeature(pLayer, pPoint);

                //刷新图层
                IActiveView pActiveView = m_hookHelper.ActiveView;
                pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, pLayer, null);
            }
            
        }

        public override void OnMouseMove(int Button, int Shift, int X, int Y)
        {
            
        }

        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            
        }

        /// <summary>
        /// 添加实体对象到地图图层(添加线、面要素)
        /// </summary>
        /// <param name="layerName">图层名称</param>
        /// <param name="pGeometry">绘制形状(线、面)</param>
        private void AddFeature(ILayer pLayer, IGeometry pGeometry)
        {
            //得到要添加地物的图层
            IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
            if (pFeatureLayer != null)
            {
                //定义一个地物类, 把要编辑的图层转化为定义的地物类
                IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
                //先定义一个编辑的工作空间, 然后将其转化为数据集, 最后转化为编辑工作空间
                IWorkspaceEdit w = (pFeatureClass as IDataset).Workspace as IWorkspaceEdit;
                IFeature pFeature;

                //在内存创建一个用于暂时存放编辑数据的要素(FeatureBuffer)
                IFeatureBuffer pFeatureBuffer = pFeatureClass.CreateFeatureBuffer();
                //定义游标
                IFeatureCursor pFtCursor;
                //查找到最后一条记录, 游标指向该记录后再进行插入操作
                pFtCursor = pFeatureClass.Search(null, true);
                pFeature = pFtCursor.NextFeature();
                //开始插入新的实体对象(插入对象要使用Insert游标)
                pFtCursor = pFeatureClass.Insert(true);
                try
                {
                    //向缓存游标的Shape属性赋值
                    pFeatureBuffer.Shape = pGeometry;
                }
                catch (COMException ex)
                {
                    MessageBox.Show("绘制的几何图形超出了边界!");
                    return;
                }
                
                object featureOID = pFtCursor.InsertFeature(pFeatureBuffer);
                //保存实体
                pFtCursor.Flush();

                //释放游标
                Marshal.ReleaseComObject(pFtCursor);

                //选中要素
                IFeatureSelection pFeatureSelection = pLayer as IFeatureSelection;
                pFeatureSelection.Add(pFeatureClass.GetFeature((int)featureOID));
            }
            else
            {
                MessageBox.Show("未发现图层");
            }
        }

        #endregion
    }
}

2.绘制线

using System;
using System.Drawing;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.ADF.CATIDs;
using ESRI.ArcGIS.Controls;
using System.Windows.Forms;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;

namespace Com.XXW.NTSL.EditorTool
{
    /// <summary>
    /// Summary description for DrawPolylineTool.
    /// </summary>
    [Guid("c0e21075-d1ae-45c1-bfe5-ae53479cc91d")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("Com.XXW.NTSL.EditorTool.DrawPolylineTool")]
    public sealed class DrawPolylineTool : BaseTool
    {
        #region COM Registration Function(s)
        [ComRegisterFunction()]
        [ComVisible(false)]
        static void RegisterFunction(Type registerType)
        {
            // Required for ArcGIS Component Category Registrar support
            ArcGISCategoryRegistration(registerType);

            //
            // TODO: Add any COM registration code here
            //
        }

        [ComUnregisterFunction()]
        [ComVisible(false)]
        static void UnregisterFunction(Type registerType)
        {
            // Required for ArcGIS Component Category Registrar support
            ArcGISCategoryUnregistration(registerType);

            //
            // TODO: Add any COM unregistration code here
            //
        }

        #region ArcGIS Component Category Registrar generated code
        /// <summary>
        /// Required method for ArcGIS Component Category registration -
        /// Do not modify the contents of this method with the code editor.
        /// </summary>
        private static void ArcGISCategoryRegistration(Type registerType)
        {
            string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
            ControlsCommands.Register(regKey);

        }
        /// <summary>
        /// Required method for ArcGIS Component Category unregistration -
        /// Do not modify the contents of this method with the code editor.
        /// </summary>
        private static void ArcGISCategoryUnregistration(Type registerType)
        {
            string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
            ControlsCommands.Unregister(regKey);

        }

        #endregion
        #endregion

        private IHookHelper m_hookHelper;
        private INewLineFeedback m_NewLineFeedback;
        private ILayer pLayer;

        public DrawPolylineTool(ILayer Layer)
        {
            pLayer = Layer;
            //
            // TODO: Define values for the public properties
            //
            base.m_category = ""; //localizable text 
            base.m_caption = "";  //localizable text 
            base.m_message = "";  //localizable text
            base.m_toolTip = "";  //localizable text
            base.m_name = "";   //unique id, non-localizable (e.g. "MyCategory_MyTool")
            try
            {
                //
                // TODO: change resource name if necessary
                //
                string bitmapResourceName = GetType().Name + ".bmp";
                base.m_bitmap = new Bitmap(GetType(), bitmapResourceName);
                base.m_cursor = new System.Windows.Forms.Cursor(GetType(), GetType().Name + ".cur");
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");
            }
        }

        #region Overridden Class Methods

        /// <summary>
        /// Occurs when this tool is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            if (m_hookHelper == null)
                m_hookHelper = new HookHelperClass();

            m_hookHelper.Hook = hook;

            // TODO:  Add DrawPolylineTool.OnCreate implementation
        }

        /// <summary>
        /// Occurs when this tool is clicked
        /// </summary>
        public override void OnClick()
        {
            
        }

        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button == 1)
            {
                IPoint pPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                if (m_NewLineFeedback == null)
                {
                    m_NewLineFeedback = new NewLineFeedback();
                    m_NewLineFeedback.Display = m_hookHelper.ActiveView.ScreenDisplay;
                    m_NewLineFeedback.Start(pPoint);
                }
                else
                {
                    m_NewLineFeedback.AddPoint(pPoint);
                }
            }
        }

        public override void OnMouseMove(int Button, int Shift, int X, int Y)
        {
            IPoint pPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            if (m_NewLineFeedback != null)
            {
                m_NewLineFeedback.MoveTo(pPoint);
            }
        }

        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            
        }

        public override void OnDblClick()
        {
            if (m_NewLineFeedback != null)
            {
                IPolyline pPolyline = m_NewLineFeedback.Stop();
                m_NewLineFeedback = null;

                //将绘制的点保存到图层
                AddFeature(pLayer, pPolyline);

                //刷新图层
                IActiveView pActiveView = m_hookHelper.ActiveView;
                pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, pLayer, null);
            }
        }

        /// <summary>
        /// 添加实体对象到地图图层(添加线、面要素)
        /// </summary>
        /// <param name="layerName">图层名称</param>
        /// <param name="pGeometry">绘制形状(线、面)</param>
        private void AddFeature(ILayer pLayer, IGeometry pGeometry)
        {
            //得到要添加地物的图层
            IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
            if (pFeatureLayer != null)
            {
                //定义一个地物类, 把要编辑的图层转化为定义的地物类
                IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
                //先定义一个编辑的工作空间, 然后将其转化为数据集, 最后转化为编辑工作空间
                IWorkspaceEdit w = (pFeatureClass as IDataset).Workspace as IWorkspaceEdit;
                IFeature pFeature;

                //开始事务操作
                w.StartEditing(true);
                //开始编辑
                w.StartEditOperation();

                //在内存创建一个用于暂时存放编辑数据的要素(FeatureBuffer)
                IFeatureBuffer pFeatureBuffer = pFeatureClass.CreateFeatureBuffer();
                //定义游标
                IFeatureCursor pFtCursor;
                //查找到最后一条记录, 游标指向该记录后再进行插入操作
                pFtCursor = pFeatureClass.Search(null, true);
                pFeature = pFtCursor.NextFeature();
                //开始插入新的实体对象(插入对象要使用Insert游标)
                pFtCursor = pFeatureClass.Insert(true);
                try
                {
                    //向缓存游标的Shape属性赋值
                    pFeatureBuffer.Shape = pGeometry;
                }
                catch (COMException ex)
                {
                    MessageBox.Show("绘制的几何图形超出了边界!");
                    return;
                }

                object featureOID = pFtCursor.InsertFeature(pFeatureBuffer);
                //保存实体
                pFtCursor.Flush();

                //释放游标
                Marshal.ReleaseComObject(pFtCursor);

                //选中要素
                IFeatureSelection pFeatureSelection = pLayer as IFeatureSelection;
                pFeatureSelection.Add(pFeatureClass.GetFeature((int)featureOID));
            }
            else
            {
                MessageBox.Show("未发现图层");
            }
        }

        #endregion
    }
}

3.绘制面

using System;
using System.Drawing;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.ADF.CATIDs;
using ESRI.ArcGIS.Controls;
using System.Windows.Forms;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;

namespace Com.XXW.NTSL.EditorTool
{
    /// <summary>
    /// Summary description for DrawPolygonTool.
    /// </summary>
    [Guid("38bbe890-eade-4303-acd4-3768e2106c49")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("Com.XXW.NTSL.EditorTool.DrawPolygonTool")]
    public sealed class DrawPolygonTool : BaseTool
    {
        #region COM Registration Function(s)
        [ComRegisterFunction()]
        [ComVisible(false)]
        static void RegisterFunction(Type registerType)
        {
            // Required for ArcGIS Component Category Registrar support
            ArcGISCategoryRegistration(registerType);

            //
            // TODO: Add any COM registration code here
            //
        }

        [ComUnregisterFunction()]
        [ComVisible(false)]
        static void UnregisterFunction(Type registerType)
        {
            // Required for ArcGIS Component Category Registrar support
            ArcGISCategoryUnregistration(registerType);

            //
            // TODO: Add any COM unregistration code here
            //
        }

        #region ArcGIS Component Category Registrar generated code
        /// <summary>
        /// Required method for ArcGIS Component Category registration -
        /// Do not modify the contents of this method with the code editor.
        /// </summary>
        private static void ArcGISCategoryRegistration(Type registerType)
        {
            string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
            ControlsCommands.Register(regKey);

        }
        /// <summary>
        /// Required method for ArcGIS Component Category unregistration -
        /// Do not modify the contents of this method with the code editor.
        /// </summary>
        private static void ArcGISCategoryUnregistration(Type registerType)
        {
            string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
            ControlsCommands.Unregister(regKey);

        }

        #endregion
        #endregion

        private IHookHelper m_hookHelper;
        private INewPolygonFeedback m_NewPolygonFeedback;
        private ILayer pLayer;

        public DrawPolygonTool(ILayer Layer)
        {
            pLayer = Layer;
            //
            // TODO: Define values for the public properties
            //
            base.m_category = ""; //localizable text 
            base.m_caption = "";  //localizable text 
            base.m_message = "";  //localizable text
            base.m_toolTip = "";  //localizable text
            base.m_name = "";   //unique id, non-localizable (e.g. "MyCategory_MyTool")
            try
            {
                //
                // TODO: change resource name if necessary
                //
                string bitmapResourceName = GetType().Name + ".bmp";
                base.m_bitmap = new Bitmap(GetType(), bitmapResourceName);
                base.m_cursor = new System.Windows.Forms.Cursor(GetType(), GetType().Name + ".cur");
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");
            }
        }

        #region Overridden Class Methods

        /// <summary>
        /// Occurs when this tool is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            if (m_hookHelper == null)
                m_hookHelper = new HookHelperClass();

            m_hookHelper.Hook = hook;

            // TODO:  Add DrawPolygonTool.OnCreate implementation
        }

        /// <summary>
        /// Occurs when this tool is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add DrawPolygonTool.OnClick implementation
        }

        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button == 1)
            {
                IPoint pPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

                if (m_NewPolygonFeedback == null)
                {
                    m_NewPolygonFeedback = new NewPolygonFeedback();
                    m_NewPolygonFeedback.Display = m_hookHelper.ActiveView.ScreenDisplay;
                    m_NewPolygonFeedback.Start(pPoint);
                }
                else
                {
                    m_NewPolygonFeedback.AddPoint(pPoint);
                } 

            }
            
        }

        public override void OnMouseMove(int Button, int Shift, int X, int Y)
        {
            IPoint pPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            if (m_NewPolygonFeedback != null)
            {
                m_NewPolygonFeedback.MoveTo(pPoint);
            }
            
        }

        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            
        }

        public override void OnDblClick()
        {
            if (m_NewPolygonFeedback != null)
            {
                IPolygon pPolygon = m_NewPolygonFeedback.Stop();
                m_NewPolygonFeedback = null;

                //将绘制的点保存到图层
                AddFeature(pLayer, pPolygon);

                //刷新图层
                IActiveView pActiveView = m_hookHelper.ActiveView;
                pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, pLayer, null);
            }
        }

        /// <summary>
        /// 添加实体对象到地图图层(添加线、面要素)
        /// </summary>
        /// <param name="layerName">图层名称</param>
        /// <param name="pGeometry">绘制形状(线、面)</param>
        private void AddFeature(ILayer pLayer, IGeometry pGeometry)
        {
            //得到要添加地物的图层
            IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
            if (pFeatureLayer != null)
            {
                //定义一个地物类, 把要编辑的图层转化为定义的地物类
                IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
                //先定义一个编辑的工作空间, 然后将其转化为数据集, 最后转化为编辑工作空间
                IWorkspaceEdit w = (pFeatureClass as IDataset).Workspace as IWorkspaceEdit;
                IFeature pFeature;

                //在内存创建一个用于暂时存放编辑数据的要素(FeatureBuffer)
                IFeatureBuffer pFeatureBuffer = pFeatureClass.CreateFeatureBuffer();
                //定义游标
                IFeatureCursor pFtCursor;
                //查找到最后一条记录, 游标指向该记录后再进行插入操作
                pFtCursor = pFeatureClass.Search(null, true);
                pFeature = pFtCursor.NextFeature();
                //开始插入新的实体对象(插入对象要使用Insert游标)
                pFtCursor = pFeatureClass.Insert(true);
                try
                {
                    //向缓存游标的Shape属性赋值
                    pFeatureBuffer.Shape = pGeometry;
                }
                catch (COMException ex)
                {
                    MessageBox.Show("绘制的几何图形超出了边界!");
                    return;
                }

                object featureOID = pFtCursor.InsertFeature(pFeatureBuffer);
                //保存实体
                pFtCursor.Flush();

                //释放游标
                Marshal.ReleaseComObject(pFtCursor);

                //选中要素
                IFeatureSelection pFeatureSelection = pLayer as IFeatureSelection;
                pFeatureSelection.Add(pFeatureClass.GetFeature((int)featureOID));
            }
            else
            {
                MessageBox.Show("未发现图层");
            }
        }

        #endregion
    }
}

4.绘制弧线

using System;
using System.Drawing;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.ADF.CATIDs;
using ESRI.ArcGIS.Controls;
using System.Windows.Forms;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;

namespace Com.XXW.NTSL.EditorTool
{
    /// <summary>
    /// Summary description for DrawArcTool.
    /// </summary>
    [Guid("2b027ad2-7d99-4dd5-a163-4ed618764c15")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("Com.XXW.NTSL.EditorTool.DrawArcTool")]
    public sealed class DrawArcTool : BaseTool
    {
        #region COM Registration Function(s)
        [ComRegisterFunction()]
        [ComVisible(false)]
        static void RegisterFunction(Type registerType)
        {
            // Required for ArcGIS Component Category Registrar support
            ArcGISCategoryRegistration(registerType);

            //
            // TODO: Add any COM registration code here
            //
        }

        [ComUnregisterFunction()]
        [ComVisible(false)]
        static void UnregisterFunction(Type registerType)
        {
            // Required for ArcGIS Component Category Registrar support
            ArcGISCategoryUnregistration(registerType);

            //
            // TODO: Add any COM unregistration code here
            //
        }

        #region ArcGIS Component Category Registrar generated code
        /// <summary>
        /// Required method for ArcGIS Component Category registration -
        /// Do not modify the contents of this method with the code editor.
        /// </summary>
        private static void ArcGISCategoryRegistration(Type registerType)
        {
            string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
            ControlsCommands.Register(regKey);

        }
        /// <summary>
        /// Required method for ArcGIS Component Category unregistration -
        /// Do not modify the contents of this method with the code editor.
        /// </summary>
        private static void ArcGISCategoryUnregistration(Type registerType)
        {
            string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
            ControlsCommands.Unregister(regKey);

        }

        #endregion
        #endregion

        private IHookHelper m_hookHelper;
        private INewArcFeedback m_NewArcFeedback;
        private IDisplayFeedback pDisplayFeedback;
        private ILayer pLayer;
        private int i = 0;

        public DrawArcTool(ILayer Layer)
        {
            pLayer = Layer;
            //
            // TODO: Define values for the public properties
            //
            base.m_category = ""; //localizable text 
            base.m_caption = "";  //localizable text 
            base.m_message = "";  //localizable text
            base.m_toolTip = "";  //localizable text
            base.m_name = "";   //unique id, non-localizable (e.g. "MyCategory_MyTool")
            try
            {
                //
                // TODO: change resource name if necessary
                //
                string bitmapResourceName = GetType().Name + ".bmp";
                base.m_bitmap = new Bitmap(GetType(), bitmapResourceName);
                base.m_cursor = new System.Windows.Forms.Cursor(GetType(), GetType().Name + ".cur");
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");
            }
        }

        #region Overridden Class Methods

        /// <summary>
        /// Occurs when this tool is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            if (m_hookHelper == null)
                m_hookHelper = new HookHelperClass();

            m_hookHelper.Hook = hook;
            
        }

        public override void OnClick()
        {
            
        }

        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            IPoint pPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            if (Button == 1)
            {
                if (m_NewArcFeedback == null)
                {
                    m_NewArcFeedback = new NewArcFeedbackClass();

                    pDisplayFeedback = m_NewArcFeedback as IDisplayFeedback;

                    pDisplayFeedback.Display = m_hookHelper.ActiveView.ScreenDisplay;

                    m_NewArcFeedback.Start(pPoint);

                    i++;

                    return;
                }
                if (i == 1)
                {
                    m_NewArcFeedback.SetEndpoint(pPoint);

                    i++;

                    return;
                }
                if(i == 2)
                {
                    //停止绘制
                    ICircularArc circularArc = new CircularArcClass();

                    m_NewArcFeedback.Stop(pPoint, out circularArc);

                    AddArc(pLayer, circularArc);

                    m_NewArcFeedback = null;

                    i = 0;
                    return;
                }
            }
            
        }

        public override void OnMouseMove(int Button, int Shift, int X, int Y)
        {
            IPoint pPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            if (m_NewArcFeedback != null)
            {
                if (m_NewArcFeedback.Arc != null)
                {
                    pDisplayFeedback.MoveTo(pPoint);
                }
            }
        }

        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            
        }

        /// <summary>
        /// 将绘制弧线保存并添加显示
        /// </summary>
        /// <param name="circularArc"></param>
        private void AddArc(ILayer pLayer, ICircularArc circularArc)
        {
            if (pLayer != null)
            {
                IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
                IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;

                if (pFeatureClass != null)
                {
                    if (pFeatureClass.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline)
                    {
                        // 获取绘制的弧线
                        IPolyline ArcPolyline = new PolylineClass();
                        ISegmentCollection segementColl = (ISegmentCollection)ArcPolyline;
                        ISegment segment = (ISegment)circularArc;
                        segementColl.AddSegment(segment);

                        //将绘制的弧线保存到图层
                        AddFeature(pLayer, ArcPolyline);

                    }
                    if (pFeatureClass.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon)
                    {
                        // 获取绘制的弧线
                        IPolygon ArcPolygon = new PolygonClass();
                        ISegmentCollection segementColl = (ISegmentCollection)ArcPolygon;
                        ISegment segment = (ISegment)circularArc;
                        segementColl.AddSegment(segment);

                        //将绘制的弧线保存到图层
                        AddFeature(pLayer, ArcPolygon);

                    }

                    //刷新图层
                    IActiveView pActiveView = m_hookHelper.ActiveView;
                    pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, pLayer, null);
                }
                else
                {
                    MessageBox.Show("未发现要素!");
                }
            }
            else
            {
                MessageBox.Show("未发现图层!");
            }
            
        }

        /// <summary>
        /// 添加实体对象到图层(添加线、面要素)
        /// </summary>
        /// <param name="layerName">图层名称</param>
        /// <param name="pGeometry">绘制形状(线、面)</param>
        private void AddFeature(ILayer pLayer, IGeometry pGeometry)
        {
            //得到要添加地物的图层
            IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
            if (pFeatureLayer != null)
            {
                //定义一个地物类, 把要编辑的图层转化为定义的地物类
                IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
                //先定义一个编辑的工作空间, 然后将其转化为数据集, 最后转化为编辑工作空间
                IWorkspaceEdit WorkspaceEdit = (pFeatureClass as IDataset).Workspace as IWorkspaceEdit;
                IFeature pFeature;

                //开始事务操作
                WorkspaceEdit.StartEditing(true);
                //开始编辑
                WorkspaceEdit.StartEditOperation();

                //在内存创建一个用于暂时存放编辑数据的要素(FeatureBuffer)
                IFeatureBuffer pFeatureBuffer = pFeatureClass.CreateFeatureBuffer();
                //定义游标
                IFeatureCursor pFtCursor;
                //查找到最后一条记录, 游标指向该记录后再进行插入操作
                pFtCursor = pFeatureClass.Search(null, true);
                pFeature = pFtCursor.NextFeature();
                //开始插入新的实体对象(插入对象要使用Insert游标)
                pFtCursor = pFeatureClass.Insert(true);
                try
                {
                    //向缓存游标的Shape属性赋值
                    pFeatureBuffer.Shape = pGeometry;
                }
                catch (COMException ex)
                {
                    MessageBox.Show("绘制的几何图形超出了边界!");
                    return;
                }

                object featureOID = pFtCursor.InsertFeature(pFeatureBuffer);
                //保存实体
                pFtCursor.Flush();
               
                //释放游标
                Marshal.ReleaseComObject(pFtCursor);

                //选中要素
                IFeatureSelection pFeatureSelection = pLayer as IFeatureSelection;
                pFeatureSelection.Add(pFeatureClass.GetFeature((int)featureOID));
            }
            else
            {
                MessageBox.Show("未发现图层");
            }
        }

        #endregion
    }
}

5.增加折点

using System;
using System.Drawing;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.ADF.CATIDs;
using ESRI.ArcGIS.Controls;
using System.Windows.Forms;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;

namespace Com.XXW.NTSL.EditorTool
{
    /// <summary>
    /// Summary description for EditorAddPoint. 
    /// </summary>
    [Guid("5baa7888-3d50-42cb-a0ad-9e64af24a910")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("Com.XXW.NTSL.EditorTool.EditorAddPoint")]
    public sealed class EditorAddPoint : BaseTool
    {
        #region COM Registration Function(s)
        [ComRegisterFunction()]
        [ComVisible(false)]
        static void RegisterFunction(Type registerType)
        {
            // Required for ArcGIS Component Category Registrar support
            ArcGISCategoryRegistration(registerType);

            //
            // TODO: Add any COM registration code here
            //
        }

        [ComUnregisterFunction()]
        [ComVisible(false)]
        static void UnregisterFunction(Type registerType)
        {
            // Required for ArcGIS Component Category Registrar support
            ArcGISCategoryUnregistration(registerType);

            //
            // TODO: Add any COM unregistration code here
            //
        }

        #region ArcGIS Component Category Registrar generated code
        /// <summary>
        /// Required method for ArcGIS Component Category registration -
        /// Do not modify the contents of this method with the code editor.
        /// </summary>
        private static void ArcGISCategoryRegistration(Type registerType)
        {
            string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
            ControlsCommands.Register(regKey);

        }
        /// <summary>
        /// Required method for ArcGIS Component Category unregistration -
        /// Do not modify the contents of this method with the code editor.
        /// </summary>
        private static void ArcGISCategoryUnregistration(Type registerType)
        {
            string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
            ControlsCommands.Unregister(regKey);

        }

        #endregion
        #endregion

        private IHookHelper m_hookHelper;
        private IEngineEditor pEngineEditor;

        public EditorAddPoint(IEngineEditor EngineEditor)
        {
            pEngineEditor = EngineEditor;
            //
            // TODO: Define values for the public properties
            //
            base.m_category = ""; //localizable text 
            base.m_caption = "";  //localizable text 
            base.m_message = "";  //localizable text
            base.m_toolTip = "";  //localizable text
            base.m_name = "";   //unique id, non-localizable (e.g. "MyCategory_MyTool")
            try
            {
                //
                // TODO: change resource name if necessary
                //
                string bitmapResourceName = GetType().Name + ".bmp";
                base.m_bitmap = new Bitmap(GetType(), bitmapResourceName);
                base.m_cursor = new System.Windows.Forms.Cursor(GetType(), GetType().Name + ".cur");
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");
            }
        }

        #region Overridden Class Methods

        /// <summary>
        /// Occurs when this tool is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            if (m_hookHelper == null)
                m_hookHelper = new HookHelperClass();

            m_hookHelper.Hook = hook;

            // TODO:  Add EditorAddPoint.OnCreate implementation
        }

        /// <summary>
        /// Occurs when this tool is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add EditorAddPoint.OnClick implementation
        }

        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            IPoint pPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            if (Button == 1)
            {
                // 获取点测试
                IEngineEditSketch m_pSketch = pEngineEditor as IEngineEditSketch;
                IHitTest hitShape = (IHitTest)m_pSketch.Geometry;
                IPoint hitPoint = new PointClass();
                double hitDistance = 0;
                int hitPartIndex = 0;
                int hitSegmentIndex = 0;
                bool bRightSide = false;
                esriGeometryHitPartType hitPartType = esriGeometryHitPartType.esriGeometryPartNone;
                double searchRadius = 1;

                // 节点判断
                hitPartType = esriGeometryHitPartType.esriGeometryPartVertex;
                bool isTrue = hitShape.HitTest(pPoint, searchRadius, hitPartType, hitPoint, ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref bRightSide);
                if (isTrue) return; //已存在节点,不需要添加

                // 点击测试
                hitPartType = esriGeometryHitPartType.esriGeometryPartBoundary;
                isTrue = hitShape.HitTest(pPoint, searchRadius, hitPartType, hitPoint, ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref bRightSide);

                // 添加节点 
                if (isTrue)
                {
                    // 草图操作开始
                    IEngineSketchOperation pSketchOp = new EngineSketchOperationClass();
                    pSketchOp.Start(pEngineEditor);
                    pSketchOp.SetMenuString("Insert Vertex (Custom)");
                    // 获取点串
                    IGeometryCollection pGeoCol = (IGeometryCollection)m_pSketch.Geometry;
                    IPointCollection pPathOrRingPtCol = (IPointCollection)pGeoCol.get_Geometry(hitPartIndex);
                    // 插入节点
                    object missing = Type.Missing;
                    object hitSegmentIndexObject = hitSegmentIndex;
                    object partIndexObject = hitPartIndex;
                    pPathOrRingPtCol.AddPoint(hitPoint, ref missing, ref hitSegmentIndexObject);
                    // 移除旧的,添加新的
                    pGeoCol.RemoveGeometries(hitPartIndex, 1);
                    pGeoCol.AddGeometry((IGeometry)pPathOrRingPtCol, ref partIndexObject, ref missing);
                    // 草图操作完成
                    esriEngineSketchOperationType opType = esriEngineSketchOperationType.esriEngineSketchOperationVertexAdded;
                    pSketchOp.Finish(null, opType, hitPoint);
                }
            }
        }

        public override void OnMouseMove(int Button, int Shift, int X, int Y)
        {
            
        }

        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            
        }


        #endregion
    }
}

6.删除折点

using System;
using System.Drawing;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.ADF.CATIDs;
using ESRI.ArcGIS.Controls;
using System.Windows.Forms;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.SystemUI;

namespace Com.XXW.NTSL.EditorTool
{
    /// <summary>
    /// Summary description for EditorDeletePoint.
    /// </summary>
    [Guid("f8560298-7770-4528-9ec5-b1b69ebf9ad5")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("Com.XXW.NTSL.EditorTool.EditorDeletePoint")]
    public sealed class EditorDeletePoint : BaseTool
    {
        #region COM Registration Function(s)
        [ComRegisterFunction()]
        [ComVisible(false)]
        static void RegisterFunction(Type registerType)
        {
            // Required for ArcGIS Component Category Registrar support
            ArcGISCategoryRegistration(registerType);

            //
            // TODO: Add any COM registration code here
            //
        }

        [ComUnregisterFunction()]
        [ComVisible(false)]
        static void UnregisterFunction(Type registerType)
        {
            // Required for ArcGIS Component Category Registrar support
            ArcGISCategoryUnregistration(registerType);

            //
            // TODO: Add any COM unregistration code here
            //
        }

        #region ArcGIS Component Category Registrar generated code
        /// <summary>
        /// Required method for ArcGIS Component Category registration -
        /// Do not modify the contents of this method with the code editor.
        /// </summary>
        private static void ArcGISCategoryRegistration(Type registerType)
        {
            string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
            ControlsCommands.Register(regKey);

        }
        /// <summary>
        /// Required method for ArcGIS Component Category unregistration -
        /// Do not modify the contents of this method with the code editor.
        /// </summary>
        private static void ArcGISCategoryUnregistration(Type registerType)
        {
            string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
            ControlsCommands.Unregister(regKey);

        }

        #endregion
        #endregion

        private IHookHelper m_hookHelper;
        private IEngineEditor pEngineEditor;

        public EditorDeletePoint(IEngineEditor EngineEditor)
        {
            pEngineEditor = EngineEditor;
            //
            // TODO: Define values for the public properties
            //
            base.m_category = ""; //localizable text 
            base.m_caption = "";  //localizable text 
            base.m_message = "";  //localizable text
            base.m_toolTip = "";  //localizable text
            base.m_name = "";   //unique id, non-localizable (e.g. "MyCategory_MyTool")
            try
            {
                //
                // TODO: change resource name if necessary
                //
                string bitmapResourceName = GetType().Name + ".bmp";
                base.m_bitmap = new Bitmap(GetType(), bitmapResourceName);
                base.m_cursor = new System.Windows.Forms.Cursor(GetType(), GetType().Name + ".cur");
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");
            }
        }

        #region Overridden Class Methods

        /// <summary>
        /// Occurs when this tool is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            if (m_hookHelper == null)
                m_hookHelper = new HookHelperClass();

            m_hookHelper.Hook = hook;

            // TODO:  Add EditorDeletePoint.OnCreate implementation
        }

        /// <summary>
        /// Occurs when this tool is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add EditorDeletePoint.OnClick implementation
        }

        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            IPoint pPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            if (Button == 1)
            {
                // 获取点测试
                IEngineEditSketch m_pSketch = pEngineEditor as IEngineEditSketch;
                IHitTest hitShape = (IHitTest)m_pSketch.Geometry;
                IPoint hitPoint = new PointClass();
                double hitDistance = 0;
                int hitPartIndex = 0;
                int hitSegmentIndex = 0;
                bool bRightSide = false;
                esriGeometryHitPartType hitPartType = esriGeometryHitPartType.esriGeometryPartNone;
                double searchRadius = 1;

                // 节点判断
                hitPartType = esriGeometryHitPartType.esriGeometryPartVertex;
                bool isTrue = hitShape.HitTest(pPoint, searchRadius, hitPartType, hitPoint, ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref bRightSide);
                // 删除节点 
                if (isTrue)
                {
                    // 草图操作开始
                    IEngineSketchOperation pSketchOp = new EngineSketchOperationClass();
                    pSketchOp.Start(pEngineEditor);
                    pSketchOp.SetMenuString("Delete Vertex (Custom)");
                    // 获取点串
                    IGeometryCollection pGeoCol = (IGeometryCollection)m_pSketch.Geometry;
                    IPointCollection pPathOrRingPtCol = (IPointCollection)pGeoCol.get_Geometry(hitPartIndex);
                    // 删除节点
                    object missing = Type.Missing;
                    object partIndexObject = hitPartIndex;
                    pPathOrRingPtCol.RemovePoints(hitSegmentIndex, 1);
                    // 移除旧的,添加新的
                    pGeoCol.RemoveGeometries(hitPartIndex, 1);
                    pGeoCol.AddGeometry((IGeometry)pPathOrRingPtCol, ref partIndexObject, ref missing);
                    // 草图操作完成
                    esriEngineSketchOperationType opType = esriEngineSketchOperationType.esriEngineSketchOperationVertexDeleted;
                    pSketchOp.Finish(null, opType, hitPoint);
                }
            }

        }

        public override void OnMouseMove(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add EditorDeletePoint.OnMouseMove implementation
        }

        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add EditorDeletePoint.OnMouseUp implementation
        }
        #endregion
    }
}

7.主窗体事件

using Com.XXW.NTSL.Base;
using Com.XXW.NTSL.EditorTool;
using Com.XXW.NTSL.Framework;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.SystemUI;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Com.XXW.NTSL.EditorManagement
{
    public partial class EditorToolBar : Form
    {
        private int x, y;
        private ILayer pLayer;
        private static AxMapControl MapControl;
        private static IEngineEditor pEngineEditor;

        public EditorToolBar(ILayer Layer)
        {
            //获取主窗体
            MainForm mainForm = MainForm.GetInstance();

            MapControl = mainForm.MapControl;

            pLayer = Layer;

            InitializeComponent();

            //根据几何类型更新工具可用性
            UpdataEnabled();
        }

        /// <summary>
        /// Load事件
        /// </summary>
        private void EditorToolBar_Load(object sender, EventArgs e)
        {
            IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
            IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
            IDataset dataset = pFeatureClass as IDataset;
            IWorkspace workspace = dataset.Workspace;

            //启动编辑
            pEngineEditor = new EngineEditorClass();
            pEngineEditor.EnableUndoRedo(true);
            pEngineEditor.StartEditing(workspace, MapControl.Map);
            pEngineEditor.StartOperation();

            //设置目标图层
            IEngineEditLayers pEditLayer = pEngineEditor as IEngineEditLayers;
            pEditLayer.SetTargetLayer(pFeatureLayer, 0);

            //草图工具
            ICommand pSketch = new ControlsEditingSketchToolClass();
            pSketch.OnCreate(MapControl.Object);
            MapControl.CurrentTool = pSketch as ITool;
        }

        /// <summary>
        /// 选择要素
        /// </summary>
        private void EditorSelect_Click(object sender, EventArgs e)
        {
            CancelCheck();
            IEngineEditTask pEngineEditTask = pEngineEditor.GetTaskByUniqueName("ControlToolsEditing_CreateNewFeatureTask");
            pEngineEditor.CurrentTask = pEngineEditTask;
            ICommand pEditor = new ControlsEditingEditToolClass();
            pEditor.OnCreate(MapControl.Object);
            MapControl.CurrentTool = pEditor as ITool;
        }

        /// <summary>
        /// 添加点
        /// </summary>
        private void EditorPoint_Click(object sender, EventArgs e)
        {
            CancelCheck();
            ICommand pEditor = new DrawPointTool(pLayer);
            pEditor.OnCreate(MapControl.Object);
            MapControl.CurrentTool = pEditor as ITool;
        }

        /// <summary>
        /// 添加线
        /// </summary>
        private void EditorLine_Click(object sender, EventArgs e)
        {
            CancelCheck();
            ICommand pEditor = new DrawPolylineTool(pLayer);
            pEditor.OnCreate(MapControl.Object);
            MapControl.CurrentTool = pEditor as ITool;
        }

        /// <summary>
        /// 添加面
        /// </summary>
        private void EditorPolygon_Click(object sender, EventArgs e)
        {
            CancelCheck();
            ICommand pEditor = new DrawPolygonTool(pLayer);
            pEditor.OnCreate(MapControl.Object);
            MapControl.CurrentTool = pEditor as ITool;
        }

        /// <summary>
        /// 添加弧线
        /// </summary>
        private void EditorArc_Click(object sender, EventArgs e)
        {
            CancelCheck();
            ICommand pEditor = new DrawArcTool(pLayer);
            pEditor.OnCreate(MapControl.Object);
            MapControl.CurrentTool = pEditor as ITool;
        }

        /// <summary>
        /// 追踪要素
        /// </summary>
        private void EditorTrace_Click(object sender, EventArgs e)
        {
            CancelCheck();

        }

        /// <summary>
        /// 编辑折点
        /// </summary>
        private void EditorBreak_Click(object sender, EventArgs e)
        {
            if (pEngineEditor.SelectionCount != 0)
            {
                CancelCheck();
                EditorAddPoint.Enabled = true;
                EditorDeletePoint.Enabled = true;

                //设置任务
                IEngineEditTask pEngineEditTask = pEngineEditor.GetTaskByUniqueName("ControlToolsEditing_ModifyFeatureTask");
                pEngineEditor.CurrentTask = pEngineEditTask;
                ICommand pEditor = new ControlsEditingEditToolClass();
                pEditor.OnCreate(MapControl.Object);
                MapControl.CurrentTool = pEditor as ITool;
            }
            else
            {
                EditorBreak.Checked = true;
                MessageBox.Show("请选择要编辑的要素!","提示",MessageBoxButtons.OK);
            }
            
        }

        /// <summary>
        /// 添加折点 
        /// </summary>
        private void EditorAddPoint_Click(object sender, EventArgs e)
        {
            EditorAddPoint.Checked = false;
            EditorDeletePoint.Checked = false;
            ICommand pEditor = new EditorAddPoint(pEngineEditor);
            pEditor.OnCreate(MapControl.Object);
            MapControl.CurrentTool = pEditor as ITool;
        }

        /// <summary>
        /// 删除折点
        /// </summary>
        private void EditorDeletePoint_Click(object sender, EventArgs e)
        {
            EditorAddPoint.Checked = false;
            EditorDeletePoint.Checked = false;
            ICommand pEditor = new EditorDeletePoint(pEngineEditor);
            pEditor.OnCreate(MapControl.Object);
            MapControl.CurrentTool = pEditor as ITool;

        }

        /// <summary>
        /// 工具条关闭并保存编辑
        /// </summary>
        private void buttonClose_Click(object sender, EventArgs e)
        {
            pEngineEditor.StopOperation(null);
            pEngineEditor.StopEditing(true);
            this.Close();
        }

        /// <summary>
        /// 根据几何类型更新工具可用性
        /// </summary>
        private void UpdataEnabled()
        {
            IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
            IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;

            if (pFeatureClass.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint)
            {
                pEnabled();
                EditorPoint.Enabled = true;
                EditorPoint.Checked = true;
                EditorBreak.Enabled = true;
            }
            if (pFeatureClass.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline)
            {
                pEnabled();
                EditorLine.Enabled = true;
                EditorLine.Checked = true;
                EditorArc.Enabled = true;
                EditorTrace.Enabled = true;
                EditorBreak.Enabled = true;
            }
            if (pFeatureClass.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon)
            {
                pEnabled();
                EditorPolygon.Enabled = true;
                EditorPolygon.Checked = true;
                EditorArc.Enabled = true;
                EditorTrace.Enabled = true;
                EditorBreak.Enabled = true;
            }
        }

        /// <summary>
        /// 全部不可用
        /// </summary>
        private void pEnabled()
        {
            EditorPoint.Enabled = false;
            EditorLine.Enabled = false;
            EditorPolygon.Enabled = false;
            EditorArc.Enabled = false;
            EditorTrace.Enabled = false;
            EditorBreak.Enabled = false;
            EditorAddPoint.Enabled = false;
            EditorDeletePoint.Enabled = false;
        }

        /// <summary>
        /// 取消选择
        /// </summary>
        private void CancelCheck()
        {
            EditorSelect.Checked = false;
            EditorPoint.Checked = false;
            EditorLine.Checked = false;
            EditorPolygon.Checked = false;
            EditorArc.Checked = false;
            EditorTrace.Checked = false;
            EditorBreak.Checked = false;
            EditorAddPoint.Checked = false;
            EditorDeletePoint.Checked = false;
            EditorAddPoint.Enabled = false;
            EditorDeletePoint.Enabled = false;
        }

        /// <summary>
        /// 窗体拖动事件
        /// </summary>
        private void panelTitle_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                x = e.X;
                y = e.Y;
            }
        }

        private void panelTitle_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                this.Location = new System.Drawing.Point(this.Location.X + (e.X - x), this.Location.Y + (e.Y - y));
            }
        }

    }
}

  • 0
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

王八八。

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值