using ESRI.ArcGIS.Controls;
using KGIS.Framework.Commands;
using KGIS.Framework.Utils;
using KGIS.Framework.Utils.Helper;
using Kingo.Plugin.BGSetting.Views;
using System;
namespace Kingo.Plugin.BGSetting.Commands
{
    /// 
    /// 系统设置-功能点
    /// 
    public class CmdSystemSetting : BaseMenuCommand
    {
        /// 
        /// 编辑器
        /// 
        private EngineEditorClass pEditor = null;
        private IHookHelper hookHelper = null;
        public override void OnClick()
        {
            try
            {
                if (pEditor == null)
                    pEditor = new EngineEditorClass();
                if (pEditor.EditState != esriEngineEditState.esriEngineStateNotEditing)
                {
                    MessageHelper.ShowTips("请先关闭编辑!");
                    return;
                }
                UCOpenSystemSet systemSet = new UCOpenSystemSet
                {
                    WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen
                };
                systemSet.ShowInMainWindow(true); 
            }
            catch (Exception ex)
            {
                MessageHelper.ShowTips("系统设置初始化页面失败:" + ex.Message);
                LogAPI.Debug(ex);
            }
        }
        public override void OnCreate(object Hook)
        {
            if (hookHelper == null)
                hookHelper = new HookHelperClass();
            hookHelper.Hook = Hook;
        }
        public override bool Enabled
        {
            get
            {
                //验证是否打开工程
                object ProInfo = KGIS.Framework.Maps.MapsManager.Instance.MapService.GetProjectInfo();
                if (ProInfo == null)
                    return false;
                else
                    return true;
            }
        }
    }
}