Example #1
0
        private async void Button_CheckUpdate_Click(object sender, RoutedEventArgs e)
        {
            var res = ServiceConnection.GetUpdate();

            Button_CheckUpdate.IsEnabled = false;
            Button_CheckUpdate.Content   = "正在检测更新...";
            if (await res == "Error")
            {
                Button_CheckUpdate.IsEnabled = true;
                Button_CheckUpdate.Content   = "加载出错";
            }
            else if (await res == "Latest")
            {
                Button_CheckUpdate.Content = "最新版本";
            }
            else
            {
                if (browser == null)
                {
                    browser = new CefSharp.Wpf.ChromiumWebBrowser();
                    Grid_Web.Children.Add(browser);
                }
                browser.Address = await res;
                Button_CheckUpdate.IsEnabled = true;
                Button_CheckUpdate.Content   = "检测更新";
            }
        }
        public MainWindow()
        {
            Task <string> update = null;
            string        result;

            if (GlobalSettings.AutoCheckUpdate)
            {
                update = ServiceConnection.GetUpdate();
            }
            InitializeComponent();
            if (Environment.GetCommandLineArgs().Length == 2 && Environment.GetCommandLineArgs()[1] == "--autorun")
            {
                string s = GlobalSettings.AutoRunItem;
                if (s != null && s.Contains('|'))
                {
                    var ss = s.Split('|');
                    if (Package.PackageManager.packages.ContainsKey(ss[0]))
                    {
                        var found = from e in Package.PackageManager.packages[ss[0]].StartupInfos
                                    where e.name == ss[1]
                                    select e;
                        if (found.Any())
                        {
                            new BasicWindow(found.First()).Show();
                            if (update != null)
                            {
                                result = update.Result;
                                if (result != "Latest" && result != "Error")
                                {
                                    MessageBox.Show("检测到更新, 请打开主软件->设置界面查看", "HuiDesktop");
                                }
                            }
                        }
                    }
                }
                Close();
                return;
            }
            var info = new List <Package.StartupInfo>();

            RefreshList();
            Task.Factory.StartNew(() =>
            {
                result = update.Result;
                if (result != "Latest" && result != "Error")
                {
                    MessageBox.Show("检测到更新, 请打开主软件->设置界面查看", "HuiDesktop");
                }
            });
        }