Example #1
0
        public DialogResult ShowDialog(Control parent)
        {
            using (var visualStyles = new EnableThemingInScope(ApplicationHandler.EnableVisualStyles))
            {
                var parentWindow = parent?.ParentWindow;
                if (parentWindow?.HasFocus == false)
                {
                    parentWindow.Focus();
                }

                var element = parent == null ? null : parent.GetContainerControl();
                var window  = element == null ? null : element.GetVisualParent <sw.Window>();
                sw.MessageBoxResult result;
                var buttons       = Convert(Buttons);
                var defaultButton = Convert(DefaultButton, Buttons);
                var icon          = Convert(Type);
                var caption       = Caption ?? parentWindow?.Title;
                if (window != null)
                {
                    result = WpfMessageBox.Show(window, Text, caption, buttons, icon, defaultButton);
                }
                else
                {
                    result = WpfMessageBox.Show(Text, caption, buttons, icon, defaultButton);
                }
                WpfFrameworkElementHelper.ShouldCaptureMouse = false;
                return(Convert(result));
            }
        }
Example #2
0
 public DialogResult ShowDialog(Control parent)
 {
     using (var visualStyles = new EnableThemingInScope(ApplicationHandler.EnableVisualStyles))
     {
         var element = parent == null ? null : parent.GetContainerControl();
         var window  = element == null ? null : element.GetVisualParent <sw.Window>();
         sw.MessageBoxResult result;
         var buttons       = Convert(Buttons);
         var defaultButton = Convert(DefaultButton, Buttons);
         var icon          = Convert(Type);
         var caption       = Caption ?? ((parent != null && parent.ParentWindow != null) ? parent.ParentWindow.Title : null);
         if (window != null)
         {
             result = WpfMessageBox.Show(window, Text, caption, buttons, icon, defaultButton);
         }
         else
         {
             result = WpfMessageBox.Show(Text, caption, buttons, icon, defaultButton);
         }
         return(Convert(result));
     }
 }