예제 #1
0
 public void CheckForUpdateOnStartup(IApplicationUpdateService service, ApplicationUpdatePresenterFactory presenterFactory)
 {
     if (Preferences.Get <bool>(Preference.StartupCheckForUpdate))
     {
         CheckForUpdateInternal(service, presenterFactory);
     }
 }
예제 #2
0
        private void CheckForUpdate(IApplicationUpdateService service, ApplicationUpdatePresenterFactory presenterFactory)
        {
            var result = CheckForUpdateInternal(service, presenterFactory);

            if (result.HasValue && !result.Value)
            {
                string text = $"{Core.Application.NameAndVersion} is already up-to-date.";
                MessageBox.ShowInformation(Form, text, Core.Application.NameAndVersion);
            }
        }
예제 #3
0
        private bool?CheckForUpdateInternal(IApplicationUpdateService service, ApplicationUpdatePresenterFactory presenterFactory)
        {
            if (!Monitor.TryEnter(_checkForUpdateLock))
            {
                return(null);
            }
            try
            {
                var uri    = new Uri(Properties.Settings.Default.UpdateUrl);
                var update = service.GetApplicationUpdate(uri);

                if (update is null)
                {
                    return(false);
                }
                if (!update.VersionIsGreaterThan(Core.Application.VersionNumber))
                {
                    return(false);
                }

                _applicationUpdateModel = new ApplicationUpdateModel(update);
                using (var presenter = presenterFactory.Create(_applicationUpdateModel))
                {
                    if (presenter.ShowDialog(Form) == DialogResult.OK)
                    {
                        if (_applicationUpdateModel.SelectedUpdateFileIsReadyToBeExecuted)
                        {
                            string text = String.Format(CultureInfo.CurrentCulture,
                                                        "{0} will install the new version when you exit the application.", Core.Application.Name);
                            MessageBox.ShowInformation(Form, text, Core.Application.NameAndVersion);
                        }
                    }
                }
                return(true);
            }
            finally
            {
                Monitor.Exit(_checkForUpdateLock);
            }
        }
예제 #4
0
 public void CheckForUpdateClick(IApplicationUpdateService service, ApplicationUpdatePresenterFactory presenterFactory)
 {
     CheckForUpdate(service, presenterFactory);
 }