Esempio n. 1
0
        void DownloadLauncherUpdate(out bool updateInstallPending)
        {
            UpdateDownloadWindow theWindow = new UpdateDownloadWindow(VersionCheck.LauncherPatchUrl, VersionCheck.LauncherPatchHash);

            theWindow.Owner = this;
            theWindow.ShowDialog();

            if (theWindow.UpdateFinished)
            {
                SelfUpdater.ExecuteInstall();
                updateInstallPending = true;
            }
            else
            {
                updateInstallPending = false;
            }
        }
Esempio n. 2
0
        public static void LaunchNewUpdateForm(Object sender, UpdateEventArgs eventArgs)
        {
            string caption = TranslationHelper.TranslatorInstance.GetFormattedTranslation("UpdateManager", "PDFCreatorUpdate",
                                                                                          "PDFCreator Update");
            string message = TranslationHelper.TranslatorInstance.GetFormattedTranslation("UpdateManager", "NewUpdateMessage",
                                                                                          "The new version [{0}] is available.\r\nWould you like to download the new version?", OnlineVersion.Version);

            var response = MessageWindow.ShowTopMost(message, caption, MessageWindowButtons.YesLaterNo, MessageWindowIcon.PDFCreator);

            if (response == MessageWindowResponse.Yes)
            {
                if (EditionFactory.Instance.Edition.AutomaticUpdate)
                {
                    try
                    {
                        bool done = false;

                        while (!done)
                        {
                            var  downloadWindow = new UpdateDownloadWindow(OnlineVersion.DownloadUrl);
                            bool?result         = TopMostHelper.ShowDialogTopMost(downloadWindow, true);

                            if (result != true)
                            {
                                done = true;
                                continue;
                            }

                            if (FileUtil.Instance.VerifyMd5(downloadWindow.DownloadedFile, OnlineVersion.FileHash))
                            {
                                done = true;
                                ThreadManager.Instance.UpdateAfterShutdownAction = () => Process.Start(downloadWindow.DownloadedFile);
                                continue;
                            }

                            message = TranslationHelper.TranslatorInstance.GetFormattedTranslation("UpdateManager", "DownloadHashErrorMessage",
                                                                                                   "The MD5 hash of the downloaded file does not match the expected hash. It is possible that the file has been damaged during the download. Do you want to retry the download?", OnlineVersion.Version);
                            var res = MessageWindow.ShowTopMost(message, caption, MessageWindowButtons.YesNo, MessageWindowIcon.Warning);

                            if (res != MessageWindowResponse.No)
                            {
                                continue;
                            }

                            ThreadManager.Instance.UpdateAfterShutdownAction = () => Process.Start(downloadWindow.DownloadedFile);
                            done = true;
                        }
                    }
                    catch (Exception)
                    {
                        message = TranslationHelper.TranslatorInstance.GetFormattedTranslation("UpdateManager", "DownloadErrorMessage",
                                                                                               "There was a problem during the download. Do you want to download the update from the website instead?", OnlineVersion.Version);
                        var res = MessageWindow.ShowTopMost(message, caption, MessageWindowButtons.YesNo, MessageWindowIcon.PDFCreator);

                        if (res == MessageWindowResponse.Yes)
                        {
                            Process.Start(OnlineVersion.DownloadUrl);
                        }
                    }
                }
                else
                {
                    Process.Start(Urls.PdfCreatorDownloadUrl);
                }
            }

            if (response != MessageWindowResponse.Later)
            {
                eventArgs.SkipVersion = true;
            }
        }