Exemple #1
0
        public static void Show(NonfatalErrorEntry entry)
        {
            var text = (entry.Exception == null
                    ? $"{entry.DisplayName.TrimEnd('.')}." : $"{entry.DisplayName.TrimEnd('.')}:\n\n[b][mono]{entry.Exception.Message}[/mono][/b]") +
                       (entry.Commentary == null ? "" : $"\n\n[i]{entry.Commentary}[/i]");
            var dlg = new ModernDialog {
                Title   = UiStrings.Common_Oops,
                Content = new ScrollViewer {
                    Content = new SelectableBbCodeBlock {
                        BbCode = text, Margin = new Thickness(0, 0, 0, 8)
                    },
                    VerticalScrollBarVisibility   = ScrollBarVisibility.Auto,
                    HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled
                },
                MinHeight = 0,
                MinWidth  = 0,
                MaxHeight = 480,
                MaxWidth  = 640
            };

            dlg.Buttons = entry.Solutions.Select(x => dlg.CreateFixItButton(x, entry)).Where(x => x != null).Union(new[] { dlg.OkButton });
            dlg.Show();

            entry.Unseen = false;
        }
Exemple #2
0
        public static void Show(NonfatalErrorEntry entry)
        {
            var text = (entry.Exception == null
                    ? $"{entry.DisplayName.TrimEnd('.')}."
                    : $"{entry.DisplayName.TrimEnd('.')}{ColonConverter.Colon}\n\n[b][mono]{entry.Exception.Message}[/mono][/b]") +
                       (entry.Commentary == null ? "" : $"\n\n[i]{entry.Commentary}[/i]");
            var dlg = new ModernDialog {
                Title   = CustomErrorTitle ?? UiStrings.Common_Oops,
                Content = new ScrollViewer {
                    Content = new SelectableBbCodeBlock {
                        Text = text, Margin = new Thickness(0, 0, 0, 8)
                    },
                    VerticalScrollBarVisibility   = ScrollBarVisibility.Auto,
                    HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled
                },
                MinHeight = 0,
                MinWidth  = 0,
                MaxHeight = 480,
                MaxWidth  = 640,
                Owner     = null
            };

            var fixButtons = entry.Solutions.Select(x => dlg.CreateFixItButton(x, entry)).Where(x => x != null).ToList();

            if (fixButtons.Count > 0)
            {
                fixButtons[0].IsDefault = true;

                var closeButton = dlg.CloseButton;
                closeButton.IsDefault = false;
                dlg.Buttons           = fixButtons.Concat(new[] { dlg.CloseButton });
            }
            else
            {
                dlg.Buttons = new[] { dlg.OkButton };
            }
            dlg.Show();

            entry.Unseen = false;
        }
Exemple #3
0
        public static Button CreateFixItButton([NotNull] this ModernDialog dlg, [CanBeNull] NonfatalErrorSolution solution, NonfatalErrorEntry entry = null)
        {
            if (dlg == null)
            {
                throw new ArgumentNullException(nameof(dlg));
            }
            if (solution == null)
            {
                return(null);
            }

            return(new Button {
                Content = GetFixButtonContent(solution),
                Command = solution,
                CommandParameter = null,
                IsDefault = false,
                IsCancel = false,
                MinHeight = 21,
                MinWidth = 65,
                Margin = new Thickness(4, 0, 0, 0)
            });
        }
Exemple #4
0
 public static Button CreateFixItButton([NotNull] this ModernDialog dlg, [CanBeNull] NonfatalErrorSolution solution, NonfatalErrorEntry entry = null)
 {
     if (dlg == null)
     {
         throw new ArgumentNullException(nameof(dlg));
     }
     return(solution == null ? null : dlg.CreateCloseDialogButton(solution.DisplayName, false, false, MessageBoxResult.OK, solution));
 }