Ejemplo n.º 1
0
 public static MessageBoxResult Show(string text, string title, MessageDialogButton button,
                                     ShowMessageCallbacks doNotAskAgainLoadSave, Window owner = null)
 {
     return(ShowMessageInner(text, title, button, doNotAskAgainLoadSave, owner));
 }
Ejemplo n.º 2
0
        private static MessageBoxResult ShowMessageInner(string text, string title, MessageDialogButton button,
                                                         ShowMessageCallbacks doNotAskAgainLoadSave, Window owner = null)
        {
            var value = doNotAskAgainLoadSave?.Item1?.Invoke();

            if (value != null)
            {
                return(value.Value);
            }

            FrameworkElement content = new SelectableBbCodeBlock {
                Text   = text,
                Margin = new Thickness(0, 0, 0, 8)
            };

            CheckBox doNotAskAgainCheckbox;

            if (doNotAskAgainLoadSave != null)
            {
                doNotAskAgainCheckbox = new CheckBox {
                    Content = new Label {
                        Content = "Don’t ask again"
                    }
                };

                content = new SpacingStackPanel {
                    Spacing  = 8,
                    Children =
                    {
                        content,
                        doNotAskAgainCheckbox
                    }
                };
            }
            else
            {
                doNotAskAgainCheckbox = null;
            }

            var dlg = new ModernDialog {
                Title   = title,
                Content = new ScrollViewer {
                    Content   = content,
                    MaxWidth  = 640,
                    MaxHeight = 520,
                    VerticalScrollBarVisibility   = ScrollBarVisibility.Auto,
                    HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled
                },
                MinHeight = 0,
                MinWidth  = 0,
                MaxHeight = 640,
                MaxWidth  = 800
            };

            if (owner != null)
            {
                dlg.Owner = owner;
            }

            dlg.Buttons = button.GetButtons(dlg);
            dlg.ShowDialog();

            if (doNotAskAgainCheckbox != null)
            {
                doNotAskAgainLoadSave.Item2.Invoke(doNotAskAgainCheckbox.IsChecked == true ?
                                                   dlg.MessageBoxResult : (MessageBoxResult?)null);
            }

            return(dlg.MessageBoxResult);
        }