void quit_Click(object sender, RoutedEventArgs e) { _result = ExceptionBoxResult.Quit; Close(); }
void continue_Click(object sender, RoutedEventArgs e) { _result = ExceptionBoxResult.Continue; Close(); }
void cancel_Click(object sender, RoutedEventArgs e) { _result = ExceptionBoxResult.Cancel; Close(); }
public ExceptionBoxResult ShowDialog(params ExceptionBoxButtons[] buttons) { // CoCEd thread : http://fenoxo.com/forum/index.php?/topic/57-coced-a-save-editor/ (old: http://forum.fenoxo.com/thread-6324.html) // CoCEd tracker : https://github.com/tmedwards/CoCEd/issues if (App.Current.MainWindow != this) { Owner = App.Current.MainWindow; WindowStartupLocation = WindowStartupLocation.CenterOwner; } else { WindowStartupLocation = WindowStartupLocation.CenterScreen; } text.Text = Message; if (IsWarning) { image.Source = Imaging.CreateBitmapSourceFromHIcon(System.Drawing.SystemIcons.Warning.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); } else { image.Source = Imaging.CreateBitmapSourceFromHIcon(System.Drawing.SystemIcons.Error.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); } // This isn't currently tied to ExceptionMessage because there are some instances where exceptions are shown // that probably are not very report worthy... decisions, decisions if (ShowReportInstructions) { reportingGrid.Visibility = Visibility.Visible; } else { reportingGrid.Visibility = Visibility.Collapsed; } if (String.IsNullOrEmpty(Path)) { folderGrid.Visibility = Visibility.Collapsed; } else if (!String.IsNullOrEmpty(Path)) { folderText.Text = Path; } if (String.IsNullOrEmpty(ExceptionMessage)) { exceptionGrid.Visibility = Visibility.Collapsed; } else { exceptionText.Text = ExceptionMessage; } if (!String.IsNullOrEmpty(ExceptionMessage) || !IsWarning || ShowReportInstructions) { linkBar.Visibility = Visibility.Visible; } else { linkBar.Visibility = Visibility.Collapsed; } Button lastButton = null; foreach (var choice in buttons) { lastButton = new Button(); lastButton.Content = choice.ToString(); switch (choice) { case ExceptionBoxButtons.Quit: lastButton.Click += quit_Click; _result = ExceptionBoxResult.Quit; break; case ExceptionBoxButtons.Cancel: lastButton.Click += cancel_Click; _result = ExceptionBoxResult.Cancel; break; case ExceptionBoxButtons.Continue: lastButton.Click += continue_Click; _result = ExceptionBoxResult.Continue; break; case ExceptionBoxButtons.OK: lastButton.Click += ok_Click; _result = ExceptionBoxResult.OK; break; default: throw new NotImplementedException(); } buttonStack.Children.Add(lastButton); } lastButton.IsDefault = true; base.ShowDialog(); return(_result); }
void ok_Click(object sender, RoutedEventArgs e) { _result = ExceptionBoxResult.OK; Close(); }
public ExceptionBoxResult ShowDialog(params ExceptionBoxButtons[] buttons) { // CoCEd thread : http://fenoxo.com/forum/index.php?/topic/57-coced-a-save-editor/ (old: http://forum.fenoxo.com/thread-6324.html) // CoCEd tracker : https://github.com/tmedwards/CoCEd/issues if (App.Current.MainWindow != this) { Owner = App.Current.MainWindow; WindowStartupLocation = WindowStartupLocation.CenterOwner; } else { WindowStartupLocation = WindowStartupLocation.CenterScreen; } text.Text = Message; if (IsWarning) image.Source = Imaging.CreateBitmapSourceFromHIcon(System.Drawing.SystemIcons.Warning.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); else image.Source = Imaging.CreateBitmapSourceFromHIcon(System.Drawing.SystemIcons.Error.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); // This isn't currently tied to ExceptionMessage because there are some instances where exceptions are shown // that probably are not very report worthy... decisions, decisions if (ShowReportInstructions) reportingGrid.Visibility = Visibility.Visible; else reportingGrid.Visibility = Visibility.Collapsed; if (String.IsNullOrEmpty(Path)) folderGrid.Visibility = Visibility.Collapsed; else if (!String.IsNullOrEmpty(Path)) folderText.Text = Path; if (String.IsNullOrEmpty(ExceptionMessage)) exceptionGrid.Visibility = Visibility.Collapsed; else exceptionText.Text = ExceptionMessage; if (!String.IsNullOrEmpty(ExceptionMessage) || !IsWarning || ShowReportInstructions) linkBar.Visibility = Visibility.Visible; else linkBar.Visibility = Visibility.Collapsed; Button lastButton = null; foreach (var choice in buttons) { lastButton = new Button(); lastButton.Content = choice.ToString(); switch (choice) { case ExceptionBoxButtons.Quit: lastButton.Click += quit_Click; _result = ExceptionBoxResult.Quit; break; case ExceptionBoxButtons.Cancel: lastButton.Click += cancel_Click; _result = ExceptionBoxResult.Cancel; break; case ExceptionBoxButtons.Continue: lastButton.Click += continue_Click; _result = ExceptionBoxResult.Continue; break; case ExceptionBoxButtons.OK: lastButton.Click += ok_Click; _result = ExceptionBoxResult.OK; break; default: throw new NotImplementedException(); } buttonStack.Children.Add(lastButton); } lastButton.IsDefault = true; base.ShowDialog(); return _result; }