Example #1
0
 void quit_Click(object sender, RoutedEventArgs e)
 {
     _result = ExceptionBoxResult.Quit;
     Close();
 }
Example #2
0
 void continue_Click(object sender, RoutedEventArgs e)
 {
     _result = ExceptionBoxResult.Continue;
     Close();
 }
Example #3
0
 void cancel_Click(object sender, RoutedEventArgs e)
 {
     _result = ExceptionBoxResult.Cancel;
     Close();
 }
Example #4
0
        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);
        }
Example #5
0
 void ok_Click(object sender, RoutedEventArgs e)
 {
     _result = ExceptionBoxResult.OK;
     Close();
 }
Example #6
0
 void quit_Click(object sender, RoutedEventArgs e)
 {
     _result = ExceptionBoxResult.Quit;
     Close();
 }
Example #7
0
 void ok_Click(object sender, RoutedEventArgs e)
 {
     _result = ExceptionBoxResult.OK;
     Close();
 }
Example #8
0
 void continue_Click(object sender, RoutedEventArgs e)
 {
     _result = ExceptionBoxResult.Continue;
     Close();
 }
Example #9
0
 void cancel_Click(object sender, RoutedEventArgs e)
 {
     _result = ExceptionBoxResult.Cancel;
     Close();
 }
Example #10
0
        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;
        }