年度变更建库软件5.0版本
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.6 KiB

6 months ago
using ESRI.ArcGIS.Controls;
using KGIS.Framework.Commands;
using KGIS.Framework.Platform;
using KGIS.Framework.Utils;
using KGIS.Framework.Utils.Helper;
using KGIS.Framework.Views;
using Kingo.PluginServiceInterface;
using System;
using UIShell.OSGi;
namespace Kingo.Plugin.MapView.Commands
{
/// <summary>
/// 关闭工程
/// </summary>
public class CmdCloseProject : BaseMenuCommand
{
/// <summary>
/// 编辑器
/// </summary>
private IEngineEditor m_Editor;
public object CmdParameter { get; set; }
public IHookHelper m_hookHelper { get; set; }
private IViewManager m_ViewManager;
public override void OnClick()
{
try
{
if (MessageHelper.ShowYesNoAndTips("是否要关闭当前工程?") == System.Windows.Forms.DialogResult.No)
{
return;
}
if (m_Editor.EditState != esriEngineEditState.esriEngineStateNotEditing)
{
MessageHelper.ShowTips("当前工程正处于编辑状态,关闭之前请先结束编辑!");
return;
}
if (Platform.Instance.SystemType == SystemTypeEnum.BGFWCG)
{
IUcMulitMapControlHelper ucMulitMapControlHelper = BundleRuntime.Instance.GetFirstOrDefaultService<IUcMulitMapControlHelper>();
if (ucMulitMapControlHelper != null)
{
ucMulitMapControlHelper.ClearData();
}
IUcZYQMagrHelper ucZYQMagrHelper = BundleRuntime.Instance.GetFirstOrDefaultService<IUcZYQMagrHelper>();
if (ucZYQMagrHelper != null)
{
ucZYQMagrHelper.ClearData();
}
}
KGIS.Framework.Maps.MapsManager.Instance.MapService.CloseProject();
Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "RefreshLayer" });
//关闭前关闭所有的未关闭的窗体
//m_ViewManager = Platform.Instance.ViewManager;
//m_ViewManager.CloseAllDocument();
//m_ViewManager.CloseAllPanel();
}
catch (Exception ex)
{
LogAPI.Debug("关闭工程时发生异常,异常信息如下:");
LogAPI.Debug(ex);
LogAPI.Debug("异常信息结束");
}
}
public override void OnCreate(object Hook)
{
try
{
if (m_hookHelper == null)
{
m_hookHelper = new HookHelper
{
Hook = Hook
};
}
if (m_Editor == null)
m_Editor = new EngineEditorClass();
}
catch (Exception ex)
{
LogAPI.Debug("初始化 关闭工程命令 时异常,异常信息如下:");
LogAPI.Debug(ex);
LogAPI.Debug("初始化 关闭工程命令 时异常信息结束");
}
}
public override bool Enabled
{
get
{
//验证是否打开工程
object ProInfo = KGIS.Framework.Maps.MapsManager.Instance.MapService.GetProjectInfo();
if (ProInfo == null)
return false;
else
return true;
}
}
}
}