예제 #1
0
파일: Msg.cs 프로젝트: sorajate/mpvnet
    public static MessageBoxResult Show(
        object msg,
        MessageBoxImage img,
        MessageBoxButton buttons = MessageBoxButton.OK,
        string details           = null)
    {
        MessageBoxResult fn()
        {
            MessageBoxEx.DetailsText = details;
            return(MessageBoxEx.OpenMessageBox((msg ?? "").ToString().Trim(),
                                               WinForms.Application.ProductName, buttons, img));
        }

        ApartmentState state = Thread.CurrentThread.GetApartmentState();

        if (state == ApartmentState.STA)
        {
            return(fn());
        }
        else
        {
            return(Application.Current.Dispatcher.Invoke(fn));
        }
    }