using MultiLayout.UiModule;
using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Navigation;
using FLY.Thick.Base.UI;
using Unity;
using MultiLayout;
using System.Diagnostics;
using System.IO;

namespace FLY.Thick.Base.UI.CustomMenu
{
    public class UpdateMenu : IMenu
    {
        public string Title => "升级检测";

        public Brush Brush { get; set; }




        IUnityContainer container;
        public UpdateMenu(IUnityContainer container)
        {
            this.container = container;

        }

        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)) {
                FLY.ControlLibrary.MyMessageBox.Show($"不能找到{exePath}");
                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();
        }
    }
}