Example #1
0
        protected override void Execute(CodeActivityContext context)
        {
            string caption = this.Caption.Get(context) ?? string.Empty;
            string text    = this.Text.Get(context) ?? string.Empty;

            System.Windows.MessageBoxButton  buttons = this.Buttons.Get(context);
            System.Windows.MessageBoxImage   icon    = this.Icon.Get(context);
            System.Windows.MessageBoxOptions options = this.Options.Get(context);

            Result.Set(context, System.Windows.MessageBox.Show(text, caption, buttons, icon, System.Windows.MessageBoxResult.None, options));
        }
Example #2
0
 public static MessageBoxResult Show(Window owner, string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult, System.Windows.MessageBoxOptions options)
 {
     Initialize_(owner);
     return(System.Windows.MessageBox.Show(owner, messageBoxText, caption, button, icon, defaultResult, options));
 }
Example #3
0
 public static System.Windows.MessageBoxResult Show(System.Windows.Window owner, string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon, System.Windows.MessageBoxResult defaultResult, System.Windows.MessageBoxOptions options)
 {
     return(System.Windows.MessageBox.Show(owner: owner, messageBoxText: messageBoxText, caption: caption, button: button, icon: icon, defaultResult: defaultResult, options: options | System.Windows.MessageBoxOptions.RightAlign | System.Windows.MessageBoxOptions.RtlReading));
 }
        ShowDialog()
        {
            UInt32 result = NativeMethods.PD_RESULT_CANCEL;

            //
            // Get the process main window handle
            //
            IntPtr owner = IntPtr.Zero;

            if ((System.Windows.Application.Current != null) &&
                (System.Windows.Application.Current.MainWindow != null))
            {
                System.Windows.Interop.WindowInteropHelper helper =
                    new System.Windows.Interop.WindowInteropHelper(System.Windows.Application.Current.MainWindow);
                owner = helper.CriticalHandle;
            }

            try
            {
                if (this._printQueue == null || this._printTicket == null)
                {
                    // Normally printDlgEx.SyncToStruct() probes the printer if both the print queue and print
                    // ticket are not null.
                    // If either is null we probe the printer ourselves
                    // If we dont end users will get notified that printing is disabled *after*
                    // the print dialog has been displayed.

                    ProbeForPrintingSupport();
                }

                //
                // Create a PrintDlgEx instance to invoke the Win32 Print Dialog
                //
                using (PrintDlgExMarshaler printDlgEx = new PrintDlgExMarshaler(owner, this))
                {
                    printDlgEx.SyncToStruct();

                    //
                    // Display the Win32 print dialog
                    //
                    Int32 hr = UnsafeNativeMethods.PrintDlgEx(printDlgEx.UnmanagedPrintDlgEx);
                    if (hr == MS.Win32.NativeMethods.S_OK)
                    {
                        result = printDlgEx.SyncFromStruct();
                    }
                }
            }
            //
            // NOTE:
            // This code was previously catch(PrintingNotSupportedException), but that created a circular dependency
            // between ReachFramework.dll and PresentationFramework.dll. Instead, we now catch Exception, check its full type name
            // and rethrow if it doesn't match. Not perfect, but better than having a circular dependency.
            //
            catch (Exception e)
            {
                if (String.Equals(e.GetType().FullName, "System.Printing.PrintingNotSupportedException", StringComparison.Ordinal))
                {
                    string message = System.Windows.SR.Get(System.Windows.SRID.PrintDialogInstallPrintSupportMessageBox);
                    string caption = System.Windows.SR.Get(System.Windows.SRID.PrintDialogInstallPrintSupportCaption);

                    bool isRtlCaption = caption != null && caption.Length > 0 && caption[0] == RightToLeftMark;
                    System.Windows.MessageBoxOptions mbOptions = isRtlCaption ? System.Windows.MessageBoxOptions.RtlReading : System.Windows.MessageBoxOptions.None;

                    int type =
                        (int)System.Windows.MessageBoxButton.OK
                        | (int)System.Windows.MessageBoxImage.Information
                        | (int)mbOptions;

                    if (owner == IntPtr.Zero)
                    {
                        owner = MS.Win32.UnsafeNativeMethods.GetActiveWindow();
                    }

                    if (0 != MS.Win32.UnsafeNativeMethods.MessageBox(new HandleRef(null, owner), message, caption, type))
                    {
                        result = NativeMethods.PD_RESULT_CANCEL;
                    }
                }
                else
                {
                    // Not a PrintingNotSupportedException, rethrow
                    throw;
                }
            }

            return(result);
        }