misc
This commit is contained in:
@@ -37,9 +37,7 @@ namespace mpvnet
|
||||
|
||||
public static Extension Extension { get; set; }
|
||||
|
||||
public static bool IsDarkMode {
|
||||
get => (DarkMode == "system" && Sys.IsDarkTheme) || DarkMode == "always";
|
||||
}
|
||||
public static bool IsDarkMode => (DarkMode == "system" && Sys.IsDarkTheme) || DarkMode == "always";
|
||||
|
||||
static AppSettings _Settings;
|
||||
|
||||
@@ -143,13 +141,22 @@ namespace mpvnet
|
||||
else
|
||||
{
|
||||
if (obj is Exception e)
|
||||
Msg.ShowException(e);
|
||||
InvokeOnMainThread(() => Msg.ShowException(e));
|
||||
else
|
||||
Msg.ShowError(obj.ToString());
|
||||
InvokeOnMainThread(() => Msg.ShowError(obj.ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
public static void InvokeOnMainThread(Action action) => MainForm.Instance.BeginInvoke(action);
|
||||
public static void InvokeOnMainThread(Action action)
|
||||
{
|
||||
if (action == null)
|
||||
return;
|
||||
|
||||
if (MainForm.Instance == null)
|
||||
action.Invoke();
|
||||
else
|
||||
MainForm.Instance.BeginInvoke(action);
|
||||
}
|
||||
|
||||
public static void ShowInfo(string msg)
|
||||
{
|
||||
|
||||
@@ -153,33 +153,14 @@ namespace mpvnet
|
||||
SetPropertyBool("keep-open", true);
|
||||
SetPropertyBool("keep-open-pause", false);
|
||||
|
||||
SetInputBindingProperties();
|
||||
|
||||
ProcessCommandLine(true);
|
||||
mpv_error err = mpv_initialize(Handle);
|
||||
|
||||
if (err < 0)
|
||||
throw new Exception("mpv_initialize error" + BR2 + GetError(err) + BR);
|
||||
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
if (GetPropertyString("property-list").Contains("input-builtin-bindings"))
|
||||
{
|
||||
SetPropertyBool("input-default-bindings", true);
|
||||
SetPropertyBool("input-builtin-bindings", false);
|
||||
}
|
||||
else
|
||||
SetPropertyBool("input-default-bindings", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetPropertyBool("input-default-bindings", true);
|
||||
|
||||
try {
|
||||
SetPropertyBool("input-builtin-bindings", false, true);
|
||||
} catch {
|
||||
SetPropertyBool("input-default-bindings", false);
|
||||
}
|
||||
}
|
||||
|
||||
ObservePropertyInt("video-rotate", value => {
|
||||
VideoRotate = value;
|
||||
UpdateVideoSize("dwidth", "dheight");
|
||||
@@ -189,6 +170,49 @@ namespace mpvnet
|
||||
InvokeAsync(InitializedAsync);
|
||||
}
|
||||
|
||||
void SetInputBindingProperties()
|
||||
{
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
if (GetPropertyString("property-list").Contains("input-builtin-bindings"))
|
||||
throw new Exception();
|
||||
else
|
||||
SetPropertyBool("input-default-bindings", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetPropertyBool("input-default-bindings", true);
|
||||
|
||||
try
|
||||
{
|
||||
SetPropertyBool("input-builtin-bindings", false, true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
SetPropertyBool("input-default-bindings", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ApplyCompatibilityFixex()
|
||||
{
|
||||
if (!App.Settings.InputDefaultBindingsFixApplied)
|
||||
{
|
||||
if (File.Exists(ConfPath))
|
||||
{
|
||||
string content = File.ReadAllText(ConfPath);
|
||||
|
||||
if (content.Contains("input-default-bindings = no"))
|
||||
File.WriteAllText(ConfPath, content.Replace("input-default-bindings = no", ""));
|
||||
|
||||
if (content.Contains("input-default-bindings=no"))
|
||||
File.WriteAllText(ConfPath, content.Replace("input-default-bindings=no", ""));
|
||||
}
|
||||
|
||||
App.Settings.InputDefaultBindingsFixApplied = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void ProcessProperty(string name, string value)
|
||||
{
|
||||
switch (name)
|
||||
@@ -266,6 +290,8 @@ namespace mpvnet
|
||||
get {
|
||||
if (_Conf == null)
|
||||
{
|
||||
ApplyCompatibilityFixex();
|
||||
|
||||
_Conf = new Dictionary<string, string>();
|
||||
|
||||
if (File.Exists(ConfPath))
|
||||
@@ -1092,8 +1118,7 @@ namespace mpvnet
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (!App.IsTerminalAttached)
|
||||
Msg.ShowException(e);
|
||||
App.ShowException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1356,15 +1381,9 @@ namespace mpvnet
|
||||
return id;
|
||||
}
|
||||
|
||||
public void RaiseScaleWindow(float value)
|
||||
{
|
||||
ScaleWindow(value);
|
||||
}
|
||||
public void RaiseScaleWindow(float value) => ScaleWindow(value);
|
||||
|
||||
public void RaiseWindowScale(float value)
|
||||
{
|
||||
WindowScale(value);
|
||||
}
|
||||
public void RaiseWindowScale(float value) => WindowScale(value);
|
||||
|
||||
void ReadMetaData()
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace mpvnet
|
||||
[Serializable()]
|
||||
public class AppSettings
|
||||
{
|
||||
public bool InputDefaultBindingsFixApplied;
|
||||
public int LastUpdateCheck;
|
||||
public int Volume = 70;
|
||||
public List<string> RecentFiles = new List<string>();
|
||||
@@ -27,9 +28,7 @@ namespace mpvnet
|
||||
|
||||
class SettingsManager
|
||||
{
|
||||
public static string SettingsFile {
|
||||
get => Core.ConfigFolder + "settings.xml";
|
||||
}
|
||||
public static string SettingsFile => Core.ConfigFolder + "settings.xml";
|
||||
|
||||
public static AppSettings Load()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user