Ejemplo n.º 1
0
        /// <summary>
        ///   Handles the <see cref="UpdateManager.VersionCheckSuccessful" /> event of a <see cref="UpdateManager" /> instance and
        ///   manages the dialog handling.
        /// </summary>
        /// <commondoc select='All/Methods/EventHandlers[@Params="Object,+EventArgs"]/*' />
        private void UpdateManager_VersionCheckSuccessful(object sender, VersionCheckSuccessfulEventArgs e)
        {
            UpdateManager updateManager = (UpdateManager)sender;

            if (!e.IsUpdate)
            {
                DialogManager.ShowUpdate_NoUpdateAvailable(this.MainWindow);
                return;
            }

            string resultKey = DialogManager.ShowUpdate_Available(this.MainWindow, this.Environment.AppVersion.ToString(), e.Version.ToString(), e.CriticalMessage, e.InfoMessage);

            switch (resultKey)
            {
            case "Install":
                Window updateDownloadingWindow = DialogManager.ShowUpdate_Downloading(this.MainWindow);
                // Check if the cancel button was pressed.
                updateDownloadingWindow.Closed += delegate {
                    if (UpdateManager.IsDownloadingUpdate)
                    {
                        updateManager.AbortDownloadUpdate();
                    }
                };
                updateManager.DownloadUpdateError      += delegate { updateDownloadingWindow.Close(); };
                updateManager.DownloadUpdateSuccessful += delegate { updateDownloadingWindow.Close(); };

                updateManager.BeginDownloadUpdate();
                break;

            case "OpenWebsite":
                Process.Start(AppEnvironment.WebsiteUrl);
                break;
            }
        }