Interaction logic for StyledMessageBox.xaml
Inheritance: System.Windows.Window
Exemplo n.º 1
0
        public static bool Show(string title, string message, bool onDarkBackground = false)
        {
            StyledMessageBox messageBox = new StyledMessageBox();
            messageBox.Title = title;
            messageBox.Message = message;
            messageBox.Owner = Application.Current.MainWindow;
            if (onDarkBackground)
            {
                messageBox.ShadowBorder.Color = Colors.WhiteSmoke;
                messageBox.ShadowBorder.Opacity = 0.58;
            }
            messageBox.ShowDialog();

            return messageBox.OkButtonClicked;
        }
Exemplo n.º 2
0
        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);
                }
            }
        }