Пример #1
0
        private bool OfferNewVersion()
        {
            if (NewVersionAvailable)
            {
                NewVersionDialog dlg = new NewVersionDialog();
                dlg.Owner = MainWindow.Window;
                dlg.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                dlg.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
                dlg.DownloadUrl         = NewVersionDownloadUrl;
                dlg.CheckForNewVersionCheckbox.IsChecked = ViewModel.CheckForNewerVersion;
                dlg.CurrentVersion.Text = "Current version: " + CurrentVersion;
                dlg.LatestVersion.Text  = "Latest version: " + NewVersionNumber + " - " + NewVersionReleaseName;

                switch (NewVersionRecommended)
                {
                default:
                case "0":
                    dlg.Recommended.Text = "This update is optional.";
                    break;

                case "1":
                    dlg.Recommended.Text = "This update is recommended.";
                    break;

                case "2":
                    dlg.Recommended.Text = "This update is strongly recommended.";
                    break;
                }

                bool performedAction = dlg.ShowDialog().Value;
                ViewModel.CheckForNewerVersion = dlg.CheckForNewVersionCheckbox.IsChecked.Value;

                if (performedAction)
                {
                    // Download or No Thanks

                    ViewModel.LastVersionOffered = NewVersionNumber;
                    return(true);
                }
                else
                {
                    // Ask me Later or Close

                    if (dlg.CheckForNewVersionCheckbox.IsChecked.Value)
                    {
                        ViewModel.AutoSaveConfiguration = false;
                        ViewModel.CheckForNewerVersion  = true;
                        ViewModel.LastVersionOffered    = string.Empty;
                        ViewModel.SaveConfiguration();
                        ViewModel.AutoSaveConfiguration = true;
                    }
                }
            }

            return(false);
        }
Пример #2
0
    private void CreateNewVersionAvailableDialog(Dictionary <string, string> remoteVersionProperties)
    {
        VisualElement dialogRootVisualElement = newVersionDialogUxml.CloneTree();

        dialogRootVisualElement.AddToClassList("overlay");
        NewVersionDialog newVersionDialog = new NewVersionDialog(dialogRootVisualElement, uiDoc.rootVisualElement, remoteVersionProperties);

        injector.WithRootVisualElement(dialogRootVisualElement).Inject(newVersionDialog);
        dialogWasShown = true;
    }
Пример #3
0
        private static void GetCurrentVersionFromServerCompleted(object sender, GetCurrentVersionCompletedEventArgs e)
        {
            try
            {
                var currentVersion = new Version(e.Result.CurrentVersion);
                if (currentVersion > new Version(Application.ProductVersion))
                {
                    // there is a new version
                    // display message?
                    if (!ApplicationSettings.DontRemindAboutVersions.Contains(currentVersion.ToString()))
                    {
                        var message = string.Format(Strings.NewVersionAvailable, currentVersion) + "\r\n\r\n";
                        if (e.Result.Features != null && e.Result.Features.Length > 0)
                        {
                            message += Strings.NewVersionFeatures;
                            foreach (var feature in e.Result.Features)
                            {
                                var tagsStripped = Regex.Replace(feature, "<.*?>", string.Empty);
                                message += "\r\n" + "* " + HttpUtility.UrlDecode(tagsStripped);
                            }
                        }

                        using (var dlg = new NewVersionDialog()
                        {
                            Message = message,
                            DownloadUrl = e.Result.DownloadUrl
                        })
                        {
                            dlg.ShowDialog();
                            if (dlg.DontRemindMe)
                            {
                                ApplicationSettings.DontRemindAboutVersions.Add(currentVersion.ToString());
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                // probably no connection to Internet
            }
        }
Пример #4
0
        private void ShowNewerVersionDialog(List <HalanVersionInfo> inf)
        {
            NewVersionDialog dlg = new NewVersionDialog(inf);

            dlg.ShowDialog();
        }