private void CommonDialog_Click(object sender, RoutedEventArgs e)
        {
            var dlg = new ModernDialog
            {
                Title = "Common dialog",
                Content = new LoremIpsum()
            };
            dlg.Buttons = new Button[] { dlg.OkButton, dlg.CancelButton };
            dlg.ShowDialog();

            this.dialogResult.Text = dlg.DialogResult.HasValue ? dlg.DialogResult.ToString() : "<null>";
            this.dialogMessageBoxResult.Text = dlg.MessageBoxResult.ToString();
        }
Example #2
0
 private static IEnumerable<Button> GetButtons(ModernDialog owner, MessageBoxButton button)
 {
     if (button == MessageBoxButton.OK)
     {
         yield return owner.OkButton;
     }
     else if (button == MessageBoxButton.OKCancel)
     {
         yield return owner.OkButton;
         yield return owner.CancelButton;
     }
     else if (button == MessageBoxButton.YesNo)
     {
         yield return owner.YesButton;
         yield return owner.NoButton;
     }
     else if (button == MessageBoxButton.YesNoCancel)
     {
         yield return owner.YesButton;
         yield return owner.NoButton;
         yield return owner.CancelButton;
     }
 }
Example #3
0
        /// <summary>
        /// Displays a messagebox.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="title">The title.</param>
        /// <param name="button">The button.</param>
        /// <param name="owner">The window owning the messagebox. The messagebox will be located at the center of the owner.</param>
        /// <returns></returns>
        public static MessageBoxResult ShowMessage(string text, string title, MessageBoxButton button, Window owner = null)
        {
            var dlg = new ModernDialog
            {
                Title = title,
                Content = new BBCodeBlock { BBCode = text, Margin = new Thickness(0, 0, 0, 8) },
                MinHeight = 0,
                MinWidth = 0,
                MaxHeight = 480,
                MaxWidth = 640,
            };
            if (owner != null)
            {
                dlg.Owner = owner;
            }

            dlg.Buttons = GetButtons(dlg, button);
            dlg.ShowDialog();
            return dlg.m_messageBoxResult;
        }