using System; using ESRI.ArcGIS.Controls; using KGIS.Framework.Platform; using KGIS.Framework.Utils; using KGIS.Framework.Utils.Interface; namespace Kingo.Plugin.EngineEditor.Commands.Tools { /// /// 描述:自定义新增节点命令(用于节点编辑功能) /// 创建人:李进营 /// 创建时间:2018-09-13 /// public class CustomVertexInsertCommandChinese : ControlsEditingVertexInsertCommandClass { protected string m_caption; protected bool IsChecked = false; private IEngineEditor m_engineEditor; //ControlsEditingVertexInsertCommand insertVertexCmd = new ControlsEditingVertexInsertCommandClass(); public CustomVertexInsertCommandChinese() { m_caption = "插入折点"; } public override int Bitmap { get { return base.Bitmap; } } public override string Caption { get { return m_caption; } } public override string Category { get { return base.Category; } } public override bool Checked { get { return IsChecked; } } public override bool Enabled { get { if (m_engineEditor.CurrentTask != null && m_engineEditor.CurrentTask.UniqueName == "ControlToolsEditing_ModifyFeatureTask") { return true; } else { return false; } } } public override int HelpContextID { get { return base.HelpContextID; } } public override string HelpFile { get { return base.HelpFile; } } public override string Message { get { return base.Message; } } public override string Name { get { return base.Name; } } public override string Tooltip { get { return base.Tooltip; } } public override void OnCreate(object hook) { base.OnCreate(hook); if (m_engineEditor == null) { m_engineEditor = new EngineEditorClass(); } Platform.Instance.NotifyMsgEven2 += NotifyMsg_NotifyMsgEven; } bool isActive = false; void NotifyMsg_NotifyMsgEven(NotifyMsgPackage obj) { if (obj.MsgType == "ResultEditVertexCommand") { isActive = obj.Content is CustomVertexInsertCommandChinese; IsChecked = isActive; } } public override void OnClick() { try { //修改人:李进营 修改时间:2018-09-13 判断当前命令是否有效,防止出现内存受保护的异常 if (!isActive) { isActive = true; IsChecked = true; Platform.Instance.SendMsg(new NotifyMsgPackage() { MsgType = "EditVertexCommand", Content = this }); //base.OnClick(); } else { isActive = false; IsChecked = false; Platform.Instance.SendMsg(new NotifyMsgPackage() { MsgType = "ExitVertexCommand", Content = this }); } } catch (Exception ex) { LogAPI.Debug("插入节点:" + ex); } } } }