using ESRI.ArcGIS.Controls; using KGIS.Framework.Commands; using KGIS.Framework.Maps; using KGIS.Framework.Utils; using KGIS.Framework.Utils.Helper; using KGIS.Framework.Utils.Interface; using Kingo.Plugin.DataLoad.View; using Kingo.PluginServiceInterface; using System; namespace Kingo.Plugin.DataLoad.Commands { public class CmdLoadBaseData : BaseMenuCommand { private IHookHelper m_hookHelper = null; public override void OnCreate(object hook) { if (m_hookHelper == null) { m_hookHelper = new HookHelperClass(); } m_hookHelper.Hook = hook; } public override void OnClick() { IEngineEditor pEditor = new EngineEditorClass(); if (pEditor.EditState == esriEngineEditState.esriEngineStateEditing) { MessageHelper.ShowTips("请先关闭编辑!"); return; } try { FrmLoadBaseData frmLoadBaseData = new FrmLoadBaseData(m_hookHelper) { WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen }; frmLoadBaseData.ShowInMainWindow(true); } catch (Exception ex) { LogAPI.Debug("在初始化 基础数据加载 命令时异常,异常信息如下:"); LogAPI.Debug(ex); LogAPI.Debug("在初始化 基础数据加载 命令时异常信息结束"); m_hookHelper = null; } } private void Main_Closed(object sender, EventArgs e) { NotifyMsgPackage msg = new NotifyMsgPackage { MsgType = "OpenPrj" }; SetNotifyMsg(msg); } public event Action NotifyMsgEven; public void SetNotifyMsg(NotifyMsgPackage msg) { try { NotifyMsgEven?.Invoke(msg); } catch (Exception ex) { MessageHelper.ShowError(ex.Message); } } public override bool Enabled { get { return JudgeIsHaveTargetPath(); } } private bool JudgeIsHaveTargetPath() { try { if (!(MapsManager.Instance.MapService.GetProjectInfo() is ProjectInfo prj)) return false; return true; } catch (Exception ex) { LogAPI.Debug("判定 基础数据加载 按钮是否有效时失败,异常原因: " + ex + " ; "); return false; } } } }