Bend.Settings.CheckForUpdates_Click C# (CSharp) Method

CheckForUpdates_Click() private method

private CheckForUpdates_Click ( object sender, RoutedEventArgs e ) : void
sender object
e System.Windows.RoutedEventArgs
return void
        private void CheckForUpdates_Click(object sender, RoutedEventArgs e)
        {
            UpdateCheckInfo info = null;

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;

                try
                {
                    info = ad.CheckForDetailedUpdate();

                }
                catch (DeploymentDownloadException dde)
                {
                    StyledMessageBox.Show("UPDATE", "The new version of the application cannot be downloaded at this time.\nPlease check your network connection, or try again later. Error: " + dde.Message, true);
                    return;
                }
                catch (InvalidDeploymentException ide)
                {
                    StyledMessageBox.Show("UPDATE", "Cannot check for a new version of the application. The ClickOnce deployment is corrupt. Please redeploy the application and try again. Error: " + ide.Message, true);
                    return;
                }
                catch (InvalidOperationException ioe)
                {
                    StyledMessageBox.Show("UPDATE", "This application cannot be updated. It is likely not a ClickOnce application. Error: " + ioe.Message, true);
                    return;
                }

                if (info.UpdateAvailable)
                {
                    Boolean doUpdate = true;

                    if (!info.IsUpdateRequired)
                    {
                        if (!StyledMessageBox.Show("UPDATE", "An update is available. Choose OK to start update.", true))
                        {
                            doUpdate = false;
                        }
                    }
                    else
                    {
                        // Display a message that the app MUST reboot. Display the minimum required version.
                        StyledMessageBox.Show("UPDATE", "This application has detected a mandatory update from your current " +
                            "version to version " + info.MinimumRequiredVersion.ToString() + ". The application will now install the update.", true);
                    }

                    if (doUpdate)
                    {
                        try
                        {
                            ad.Update();
                            StyledMessageBox.Show("UPDATE", "The application has been upgraded, please save your work and restart application.", true);
                        }
                        catch (DeploymentDownloadException dde)
                        {
                            StyledMessageBox.Show("UPDATE", "Cannot install the latest version of the application.\nPlease check your network connection, or try again later. Error: " + dde, true);
                            return;
                        }
                    }
                }
                else
                {
                    StyledMessageBox.Show("UPDATE", "You already have the latest version of this application.", true);
                }
            }
        }