5.4.9.5 Beta

This commit is contained in:
Frank Skare
2021-08-25 14:12:45 +02:00
parent d3baa47f93
commit 007fbf8be5
13 changed files with 41 additions and 86 deletions

View File

@@ -150,32 +150,26 @@ namespace mpvnet
public static void InvokeOnMainThread(Action action) => MainForm.Instance.BeginInvoke(action);
public static void ShowInfo(string title, string msg = null)
public static void ShowInfo(string msg)
{
if (IsTerminalAttached)
{
if (title != null)
Terminal.Write(title);
if (msg != null)
Terminal.Write(msg);
}
else
InvokeOnMainThread(() => Msg.ShowInfo(title, msg));
InvokeOnMainThread(() => Msg.ShowInfo(msg));
}
public static void ShowError(string title, string msg = null)
public static void ShowError(string msg)
{
if (IsTerminalAttached)
{
if (title != null)
Terminal.WriteError(title);
if (msg != null)
Terminal.WriteError(msg);
}
else
InvokeOnMainThread(() => Msg.ShowError(title, msg));
InvokeOnMainThread(() => Msg.ShowError(msg));
}
static void Core_Initialized()

View File

@@ -121,7 +121,7 @@ namespace mpvnet
ProcessHelp.ShellExecute(Core.ConfigFolder + "history.txt");
else
{
if (Msg.ShowQuestion("Create history.txt file in config folder?",
if (Msg.ShowQuestion("Create history.txt file in config folder?" + BR2 +
"mpv.net will write the date, time and filename of opened files to it.") == MessageBoxResult.OK)
File.WriteAllText(Core.ConfigFolder + "history.txt", "");
@@ -220,7 +220,7 @@ namespace mpvnet
if (string.IsNullOrEmpty(clipboard) || (!clipboard.Contains("://") && !File.Exists(clipboard)) ||
clipboard.Contains("\n"))
{
App.ShowError("No URL found", "The clipboard does not contain a valid URL or file.");
App.ShowError("No URL found, the clipboard does not contain a valid URL or file.");
return;
}
@@ -432,7 +432,7 @@ namespace mpvnet
if (propValue.ContainsEx("${"))
propValue += BR2 + Core.Expand(propValue);
App.ShowInfo(prop + ": " +propValue);
App.ShowInfo(prop + ": " + propValue);
}
};

View File

@@ -1163,7 +1163,7 @@ namespace mpvnet
{
System.Windows.MessageBoxResult result =
Msg.ShowQuestion("Click Yes for Blu-ray and No for DVD.",
null, System.Windows.MessageBoxButton.YesNoCancel);
System.Windows.MessageBoxButton.YesNoCancel);
switch (result)
{

View File

@@ -14,6 +14,7 @@ using WpfControls = System.Windows.Controls;
using static mpvnet.Native;
using static mpvnet.Global;
using MsgBoxEx;
namespace mpvnet
{
@@ -1000,6 +1001,9 @@ namespace mpvnet
WPF.Init();
App.UpdateWpfColors();
MessageBoxEx.MessageForeground = Theme.Current.GetBrush("heading");
MessageBoxEx.MessageBackground = Theme.Current.GetBrush("background");
MessageBoxEx.ButtonBackground = Theme.Current.GetBrush("highlight");
ContextMenu = new WpfControls.ContextMenu();
ContextMenu.Closed += ContextMenu_Closed;
BuildMenu();

View File

@@ -12,39 +12,40 @@ public class Msg
{
private static readonly string WindowTitle = WinForms.Application.ProductName;
public static void ShowInfo(object title, object content = null)
public static void ShowInfo(object title)
{
Show(title, content, MessageBoxImage.Information);
Show(title, MessageBoxImage.Information);
}
public static void ShowError(object title, object content = null)
public static void ShowError(object title)
{
Show(title, content, MessageBoxImage.Error);
Show(title, MessageBoxImage.Error);
}
public static void ShowWarning(object title, object content = null)
public static void ShowWarning(object title)
{
Show(title, content, MessageBoxImage.Warning);
Show(title, MessageBoxImage.Warning);
}
public static MessageBoxResult ShowQuestion(object title, object content = null,
public static MessageBoxResult ShowQuestion(object title,
MessageBoxButton buttons = MessageBoxButton.OKCancel)
{
return Show(title, content, MessageBoxImage.Question, buttons);
return Show(title, MessageBoxImage.Question, buttons);
}
public static void ShowException(Exception exception)
{
Show(exception, null, MessageBoxImage.Error);
Show(exception.Message, MessageBoxImage.Error, MessageBoxButton.OK, exception.ToString());
}
public static MessageBoxResult Show(
object title,
object content,
MessageBoxImage img,
MessageBoxButton buttons = MessageBoxButton.OK)
MessageBoxButton buttons = MessageBoxButton.OK,
string details = null)
{
string msg = (title?.ToString().TrimEx() + BR2 + content?.ToString().TrimEx()).Trim();
string msg = title?.ToString().TrimEx();
MessageBoxEx.DetailsText = details;
return MessageBoxEx.OpenMessageBox(null, msg, WindowTitle, buttons, img);
}
}

View File

@@ -156,7 +156,7 @@ namespace mpvnet
break;
default:
App.ShowError("Invalid Type", "Valid types are: bool or boolean, string, int or integer, float or double, nil or none or native");
App.ShowError("Invalid Type, valid types are: bool or boolean, string, int or integer, float or double, nil or none or native");
break;
}
}