After using the config editor it's no longer necessary to restart mpv.net.

This commit is contained in:
Frank Skare
2021-05-28 11:38:36 +02:00
parent 45a2b7f976
commit 765854cd10
36 changed files with 570 additions and 395 deletions

View File

@@ -26,7 +26,6 @@ namespace mpvnet
public static bool AutoLoadFolder { get; set; } = true;
public static bool Queue { get; set; }
public static bool UpdateCheck { get; set; }
public static bool GlobalMediaKeys { get; set; }
public static int StartThreshold { get; set; } = 1500;
public static int RecentCount { get; set; } = 15;
@@ -52,8 +51,8 @@ namespace mpvnet
public static void Init()
{
string dummy = Core.ConfigFolder;
var dummy2 = Core.Conf;
var useless1 = Core.ConfigFolder;
var useless2 = Core.Conf;
foreach (var i in Conf)
ProcessProperty(i.Key, i.Value, true);
@@ -79,6 +78,14 @@ namespace mpvnet
}
}
InitTheme();
Core.Shutdown += Shutdown;
Core.Initialized += Initialized;
}
public static void InitTheme()
{
string themeContent = null;
if (File.Exists(Core.ConfigFolder + "theme.conf"))
@@ -89,8 +96,11 @@ namespace mpvnet
Properties.Resources.theme,
IsDarkMode ? DarkTheme : LightTheme);
Core.Shutdown += Shutdown;
Core.Initialized += Initialized;
ToolStripRendererEx.ForegroundColor = Theme.Current.GetWinFormsColor("menu-foreground");
ToolStripRendererEx.BackgroundColor = Theme.Current.GetWinFormsColor("menu-background");
ToolStripRendererEx.SelectionColor = Theme.Current.GetWinFormsColor("menu-highlight");
ToolStripRendererEx.BorderColor = Theme.Current.GetWinFormsColor("menu-border");
ToolStripRendererEx.CheckedColor = Theme.Current.GetWinFormsColor("menu-checked");
}
public static void RunTask(Action action)

View File

@@ -10,6 +10,8 @@ using System.Text;
using Microsoft.CSharp;
using static mpvnet.Global;
namespace mpvnet
{
class CSharpScriptHost
@@ -66,7 +68,7 @@ namespace mpvnet
i.Line + "\n" + "Error Number: " + i.ErrorNumber + "\n" + i.ErrorText);
if (errors.Count() > 0)
Terminal.WriteError(string.Join("\n\n", errors), Path.GetFileName(file));
Terminal.WriteError(string.Join(BR2, errors), Path.GetFileName(file));
}
static string GetMD5(string code)

View File

@@ -144,12 +144,12 @@ namespace mpvnet
mpv_error err = mpv_initialize(Handle);
if (err < 0)
throw new Exception("mpv_initialize error\n\n" + GetError(err));
throw new Exception("mpv_initialize error" + BR2 + GetError(err) + BR);
err = mpv_observe_property(Handle, 0, "video-rotate", mpv_format.MPV_FORMAT_INT64);
if (err < 0)
throw new Exception("mpv_observe_property video-rotate error\n\n" + GetError(err));
throw new Exception("mpv_observe_property video-rotate error" + BR2 + GetError(err) + BR);
Initialized?.Invoke();
InvokeAsync(InitializedAsync);
@@ -929,7 +929,7 @@ namespace mpvnet
Terminal.WriteError(msg);
Terminal.WriteError(GetError(err));
throw new Exception(string.Join(BR2, messages) + BR2 + GetError(err));
throw new Exception(string.Join(BR2, messages) + BR2 + GetError(err) + BR);
}
}

View File

@@ -33,10 +33,10 @@ namespace mpvnet
if (knownExtensions.Contains(Path.GetFileName(extDir)))
catalog.Catalogs.Add(new DirectoryCatalog(extDir, Path.GetFileName(extDir) + ".dll"));
else
Terminal.WriteError("Failed to load extension:\n\n" + extDir +
"\n\nOnly extensions that ship with mpv.net are allowed in <startup>\\extensions" +
"\n\nUser extensions have to use <config folder>\\extensions" +
"\n\nNever copy or install a new mpv.net version over a old mpv.net version.");
Terminal.WriteError("Failed to load extension:" + BR2 + extDir +
BR2 + "Only extensions that ship with mpv.net are allowed in <startup>\\extensions" +
BR2 + "User extensions have to use <config folder>\\extensions" +
BR2 + "Never copy or install a new mpv.net version over a old mpv.net version.");
}
}

View File

@@ -2,6 +2,8 @@
using System;
using System.Windows.Forms;
using static mpvnet.Global;
public class Msg
{
public static void ShowInfo(object title, object content = null)
@@ -33,7 +35,7 @@ public class Msg
public static DialogResult Show(object title, object content, MessageBoxIcon icon,
MessageBoxButtons buttons = MessageBoxButtons.OK)
{
string msg = (title?.ToString().TrimEx() + "\n\n" + content?.ToString().TrimEx()).Trim();
string msg = (title?.ToString().TrimEx() + BR2 + content?.ToString().TrimEx()).Trim();
return MessageBox.Show(msg, Application.ProductName, buttons, icon);
}
}

View File

@@ -14,10 +14,10 @@ namespace mpvnet
public static Theme Current { get; set; }
public static Brush Foreground { get; set; }
public static Brush Foreground2 { get; set; }
public static Brush Background { get; set; }
public static Brush Heading { get; set; }
public Brush Foreground { get; set; }
public Brush Foreground2 { get; set; }
public Brush Background { get; set; }
public Brush Heading { get; set; }
public System.Drawing.Color GetWinFormsColor(string key)
{
@@ -31,6 +31,8 @@ namespace mpvnet
public static void Init(string customContent, string defaultContent, string activeTheme)
{
Current = null;
DefaultThemes = Load(defaultContent);
CustomThemes = Load(customContent);
@@ -65,10 +67,10 @@ namespace mpvnet
if (Current == null)
Current = DefaultThemes[0];
Foreground = Current.GetBrush("foreground");
Foreground2 = Current.GetBrush("foreground2");
Background = Current.GetBrush("background");
Heading = Current.GetBrush("heading");
Current.Foreground = Current.GetBrush("foreground");
Current.Foreground2 = Current.GetBrush("foreground2");
Current.Background = Current.GetBrush("background");
Current.Heading = Current.GetBrush("heading");
}
static List<Theme> Load(string content)