Пример #1
0
        private async void CheckUpdates_Click(object sender, RoutedEventArgs e)
        {
            InstallUpdateButton.IsEnabled = false;
            UpdateInfo.Content            = "Checking for updates...";
            _updateInfo = await _sparkle.CheckForUpdatesQuietly();

            // use _sparkle.CheckForUpdatesQuietly() if you don't want the user to know you are checking for updates!
            // if you use CheckForUpdatesAtUserRequest() and are using a UI, then handling things yourself is rather silly
            // as it will show a UI for everything
            if (_updateInfo != null)
            {
                switch (_updateInfo.Status)
                {
                case Enums.UpdateStatus.UpdateAvailable:
                    UpdateInfo.Content             = "There's an update available!";
                    DownloadUpdateButton.IsEnabled = true;
                    break;

                case Enums.UpdateStatus.UpdateNotAvailable:
                    UpdateInfo.Content             = "There's no update available :(";
                    DownloadUpdateButton.IsEnabled = false;
                    break;

                case Enums.UpdateStatus.UserSkipped:
                    UpdateInfo.Content             = "The user skipped this update!";
                    DownloadUpdateButton.IsEnabled = false;
                    break;

                case Enums.UpdateStatus.CouldNotDetermine:
                    UpdateInfo.Content             = "We couldn't tell if there was an update...";
                    DownloadUpdateButton.IsEnabled = false;
                    break;
                }
            }
        }
        public async void CheckForUpdatesSilently()
        {
            _sparkle.UIFactory = null;
            _updateInfo        = await _sparkle.CheckForUpdatesQuietly();

            if (_updateInfo != null)
            {
                UpdateProgressFinishedEventArgs eventArgs = new UpdateProgressFinishedEventArgs();
                switch (_updateInfo.Status)
                {
                case NetSparkleUpdater.Enums.UpdateStatus.UpdateAvailable:
                    eventArgs.appUpdateCheckStatus = AppUpdateCheckStatus.UpdateAvailable;
                    break;

                case NetSparkleUpdater.Enums.UpdateStatus.UpdateNotAvailable:
                    eventArgs.appUpdateCheckStatus = AppUpdateCheckStatus.NoUpdate;
                    break;

                case NetSparkleUpdater.Enums.UpdateStatus.UserSkipped:
                    eventArgs.appUpdateCheckStatus = AppUpdateCheckStatus.UserSkip;
                    break;

                case NetSparkleUpdater.Enums.UpdateStatus.CouldNotDetermine:
                    eventArgs.appUpdateCheckStatus = AppUpdateCheckStatus.CouldNotDetermine;
                    break;
                }

                OnUpdateCheckFinished(eventArgs);
            }
        }
Пример #3
0
        private void CheckForUpdates(object sender, ElapsedEventArgs elapsedEventArgs)
        {
            Task.Run(async() =>
            {
                var _updateInfo = await _sparkle.CheckForUpdatesQuietly();
                Log.Information($"Update info is {_updateInfo.Status}");
                if (_updateInfo.Status == UpdateStatus.UpdateAvailable)
                {
                    try
                    {
                        LastUpdate        = _updateInfo.Updates.Last();
                        ctx.HasUpdates    = true;
                        ctx.UpdateVersion = LastUpdate.Version;
                        await _sparkle.InitAndBeginDownload(LastUpdate);

                        if (MacUpdater == null)
                        {
                            MacUpdater = new MacUpdater
                            {
                                SignatureVerifier = _sparkle.SignatureVerifier,
                                UpdateDownloader  = _sparkle.UpdateDownloader
                            };
                        }
                    }
                    catch (Exception e)
                    {
                        Log.Error(e.ToString());
                    }
                }
            });
        }
Пример #4
0
        public async Task SilentCheck()
        {
            var result = await _sparkle.CheckForUpdatesQuietly();

            if (result?.Status == UpdateStatus.UpdateAvailable)
            {
                MainWindow.Instance.UpdatePage.SetUpdate(result.Updates, true);
            }
        }
Пример #5
0
        private async void AppBackgroundCheckButton_Click(object sender, EventArgs e)
        {
            // Manually check for updates, this will not show a ui
            var result = await _sparkleUpdateDetector.CheckForUpdatesQuietly();

            if (result.Status == UpdateStatus.UpdateAvailable)
            {
                // if update(s) are found, then we have to trigger the UI to show it gracefully
                _sparkleUpdateDetector.ShowUpdateNeededUI();
            }
        }