public static MessageBoxResult Show(string message, string title, string details, MessageBoxButton buttonOption, MessageBoxImage image)
        {
            MessageBoxResult result = MessageBoxResult.None;

            if (title == null)
            {
                // No title was supplied build one for them
                title = GetProductName();
            }

            UiDispatcher.BeginInvoke(new Action(() =>
            {
                MessageBoxEx mb          = new MessageBoxEx();
                mb.MaxWidth              = (SystemParameters.PrimaryScreenWidth * 2) / 3;
                mb.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                mb.SizeToContent         = SizeToContent.WidthAndHeight;
                mb.Title              = title;
                mb.Message            = message;
                mb.Buttons            = buttonOption;
                mb.Details            = details;
                mb.MessageImageSource = image;

                mb.DisplayWindow();
                result = mb.Result;
            }));
            return(result);
        }
 /// <summary>
 /// The owner of the event uses this method to raise the event to the registered event handlers.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 public void RaiseEvent(object sender, T args)
 {
     object[] array = new object[] { sender, args };
     foreach (Delegate d in this.list)
     {
         try
         {
             if (d.Target is DependencyObject)
             {
                 UiDispatcher.BeginInvoke(d, array);
             }
             else
             {
                 Invoke(d, array);
             }
         }
         catch (System.Reflection.TargetInvocationException e)
         {
             if (e.InnerException != null)
             {
                 throw e.InnerException;
             }
             throw;
         }
     }
 }
Beispiel #3
0
            private void OnDelayTimerTick(object state)
            {
                uint   endTime = NativeMethods.TickCount;
                uint   diff    = startTime - endTime;
                Action a       = this.delayedAction;

                StopDelayTimer();

                if (a != null)
                {
                    UiDispatcher.BeginInvoke(new Action(() =>
                    {
                        try
                        {
                            a();
                        }
                        catch (Exception ex)
                        {
                            Debug.WriteLine("OnDelayTimerTick caught unhandled exception: " + ex.ToString());
                        }
                    }));
                }
            }