Exemplo n.º 1
0
        private async void CheckUpdate_OnClick(object sender, RoutedEventArgs e)
        {
            CheckUpdateButton.IsEnabled = false;
            CheckupdateRing.Visibility  = Visibility.Visible;

            try
            {
                var updateInfo = await OnlineUpdateManager.GetUpdateInfoAsync();

                if (updateInfo == null)
                {
                    UpdateStatusBlock.Text = "已经是最新版本,无需更新。";
                }
                else
                {
                    if (App.CurrentApp.NewUpdateInfo == null || App.CurrentApp.NewUpdateInfo.NewVersion != updateInfo.NewVersion)
                    {
                        App.CurrentApp.NewUpdateInfo = updateInfo;
                        ShowUpdateInfo(updateInfo);
                    }
                }
            }
            catch
            {
                MessageBox.Show("检查更新时出现错误,请稍候重试。");
            }
            finally
            {
                CheckupdateRing.Visibility  = Visibility.Collapsed;
                CheckUpdateButton.IsEnabled = true;
            }
        }
Exemplo n.º 2
0
        private async void Download_OnClick(object sender, RoutedEventArgs e)
        {
            if (App.CurrentApp.NewUpdateInfo == null)
            {
                return;
            }

            CheckUpdateButton.IsEnabled = false;
            DownloadButton.IsEnabled    = false;
            DownloadProgress.Visibility = Visibility.Visible;
            try
            {
                await OnlineUpdateManager.SetupUpdateAsync(App.CurrentApp.NewUpdateInfo, new Progress <DownloadProgress>(d =>
                {
                    Dispatcher.InvokeAsync(() => DownloadProgress.Value = d.CompletedPercentage,
                                           DispatcherPriority.Normal);
                    UpdateStatusBlock.Text = d.Status;
                }));

                UpdateStatusBlock.Text = "准备就绪,下次启动时将会自动更新。";
            }
            catch
            {
                UpdateStatusBlock.Text   = "准备更新过程中发生错误,请重试。";
                DownloadButton.IsEnabled = true;
            }
            finally
            {
                CheckUpdateButton.IsEnabled = true;
            }
        }
Exemplo n.º 3
0
        protected override void OnContentRendered(EventArgs e)
        {
            base.OnContentRendered(e);
            var checkUpdateTask = OnlineUpdateManager.GetUpdateInfoAsync();

            checkUpdateTask.ContinueWith(t =>
            {
                var updateInfo = t.Result;
                if (updateInfo == null)
                {
                    return;
                }
                if (App.CurrentApp.NewUpdateInfo == null || App.CurrentApp.NewUpdateInfo.NewVersion != t.Result.NewVersion)
                {
                    App.CurrentApp.NewUpdateInfo = updateInfo;
                    Dispatcher.InvokeAsync(() => ShowUpdateInfo(updateInfo));
                }
            });
        }
Exemplo n.º 4
0
 private static string GetVersionInfo()
 {
     return(OnlineUpdateManager.GetCurrentVersion().ToString());
 }