using ESRI.ArcGIS.Controls; using KGIS.Framework.Commands; using KGIS.Framework.Maps; using KGIS.Framework.Utils; using KGIS.Framework.Utils.Helper; using Kingo.Plugin.CZC_IDG.View; using Kingo.PluginServiceInterface; using System; namespace Kingo.Plugin.CZC_IDG.Commands { /// /// 城镇村变更 /// public class CmdCZC_IDG : BaseMenuCommand { private EngineEditorClass pEditor = null; private IHookHelper hookHelper = null; private FrmCZCBG view = null; public override void OnCreate(object hook) { if (hookHelper == null) { hookHelper = new HookHelperClass(); } hookHelper.Hook = hook; pEditor = new EngineEditorClass(); } public override void OnClick() { try { ProjectInfo ProInfo = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo; if (ProInfo == null) { MessageHelper.Show("请先打开工程"); return; } EngineEditorClass engineEditorClass = new EngineEditorClass(); if (engineEditorClass.EditState != esriEngineEditState.esriEngineStateNotEditing) { MessageHelper.ShowTips("当前工程正处于编辑状态,请先结束编辑!"); return; } if (view == null) { view = new FrmCZCBG(); view.Closed += (sender, e) => { view = null; }; } if (view != null) { view.ShowInMainWindow(true); } } catch (Exception ex) { MessageHelper.ShowTips("城镇村变更初始化失败:" + ex.Message); LogAPI.Debug("城镇村变更初始化失败:" + ex.Message); } } public override bool Enabled { get { return JudgeIsHaveTargetPath(); } } private bool JudgeIsHaveTargetPath() { try { ProjectInfo prj = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo; if (prj == null) { return false; } return !string.IsNullOrWhiteSpace(prj.ZLDatabase) && pEditor.EditState == esriEngineEditState.esriEngineStateNotEditing; } catch (Exception ex) { LogAPI.Debug("判定 城镇村范围变更 按钮是否有效时失败,异常原因: " + ex + " ; "); return false; } } } }