using MultiLayout;
using MultiLayout.UiModule;
using System.Diagnostics;
using System.IO;
using System.Windows;
using System.Windows.Media;
using Unity;


namespace FLY.Thick.Base.UI.CustomMenu
{
    public class UpdateMenu : IMenu
    {
        public string Title { get; private set; }

        public Brush Brush { get; set; }




        IUnityContainer container;
        public UpdateMenu(IUnityContainer container)
        {
            this.container = container;
            string title = (string)Application.Current.TryFindResource("str.CustomMenu.Update");
            Title = title;
        }

        public void OnClick()
        {
            //path = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
            //path = Path.GetDirectoryName(path);

            string path = System.AppDomain.CurrentDomain.BaseDirectory;

            string exePath = Path.Combine(path, @"update\Update.exe");
            if (!File.Exists(exePath))
            {
                MessageBox.Show($"不能找到{exePath}", " 异常", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            Process startProc = new Process();
            startProc.StartInfo.FileName = exePath;  //就是你要打开的文件的详细路径
            startProc.StartInfo.UseShellExecute = true;

            startProc.StartInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(exePath); //就是如APGIS.Tools.exe 执行文件是在那个文件夹下。
            startProc.Start();
        }
    }
}
