msgbox fix

This commit is contained in:
Frank Skare
2021-08-26 12:51:20 +02:00
parent 007fbf8be5
commit 57e60287ff

View File

@@ -1,17 +1,12 @@

using System;
using System.Threading;
using System.Windows;
using WinForms = System.Windows.Forms;
using static mpvnet.Global;
using MsgBoxEx;
public class Msg
{
private static readonly string WindowTitle = WinForms.Application.ProductName;
public static void ShowInfo(object title)
{
Show(title, MessageBoxImage.Information);
@@ -43,9 +38,20 @@ public class Msg
MessageBoxImage img,
MessageBoxButton buttons = MessageBoxButton.OK,
string details = null)
{
MessageBoxResult fn()
{
string msg = title?.ToString().TrimEx();
MessageBoxEx.DetailsText = details;
return MessageBoxEx.OpenMessageBox(null, msg, WindowTitle, buttons, img);
string windowTitle = System.Windows.Forms.Application.ProductName;
return MessageBoxEx.OpenMessageBox(null, msg, windowTitle, buttons, img);
}
ApartmentState state = Thread.CurrentThread.GetApartmentState();
if (state == ApartmentState.STA)
return fn();
else
return Application.Current.Dispatcher.Invoke(fn);
}
}