Пример #1
0
        private void updateCheck_CheckComplete(string val, bool error)
        {
            // if there is no error and new version is available, display message
            if (!error && !string.IsNullOrEmpty(val))
            {
                string message = "There is a newer version of this program available." + Environment.NewLine +
                                 string.Format("Your version is {0}.".Localize(), m_updateCheck.AppVersion) +
                                 Environment.NewLine +
                                 string.Format("The most recent version is {0}.".Localize(), m_updateCheck.ServerVersion) +
                                 Environment.NewLine +
                                 Environment.NewLine +
                                 "Would you like to download the latest version?".Localize();

                var dialog = new MessageBoxDialog("Update".Localize(), message, System.Windows.MessageBoxButton.YesNo,
                                                  System.Windows.MessageBoxImage.Information);

                if (dialog.ShowDialog() == true)
                {
                    // open SourceForge page in web browser
                    try
                    {
                        var p = new Process();
                        p.StartInfo.FileName = val;
                        p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
                        p.Start();
                        p.Dispose();

                    }
                    catch (Exception e)
                    {
                        WpfMessageBox.Show(
                            "Cannot open url:".Localize() + val + ".\n" +
                            "Error".Localize() + ":" + e.Message,
                            "Error".Localize(),
                            System.Windows.MessageBoxButton.OK,
                            System.Windows.MessageBoxImage.Error);
                    }
                }
            }
            else if (m_notifyUserIfNoUpdate)
            {
                if (error)
                {
                    WpfMessageBox.Show(val, "Error".Localize(), System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning);
                }
                else
                {
                    WpfMessageBox.Show("This software is up to date.".Localize(), "Updater".Localize(),
                                    System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
                }
            }
        }
Пример #2
0
 private static MessageBoxResult ShowDefault(Window owner, string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon)
 {
     var dlg = new MessageBoxDialog(caption, messageBoxText, button, icon);
     dlg.Owner = owner;
     dlg.ShowDialog();
     return dlg.MessageBoxResult;
 }