From 722e06a02bc15556ecb4f735c15cc33c8bf170bf Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Mon, 13 Apr 2020 03:42:36 +0200 Subject: [PATCH] window-maximized support added --- Changelog.md | 11 +++++++++-- mpv.net/Misc/App.cs | 2 -- mpv.net/Resources/editor.toml.txt | 6 +++--- mpv.net/WinForms/MainForm.cs | 21 ++++++++++++++++++++- mpv.net/mpv/mp.cs | 12 ++++++++---- 5 files changed, 40 insertions(+), 12 deletions(-) diff --git a/Changelog.md b/Changelog.md index 1b6eb6d..24544fc 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,7 +1,14 @@ -### 5.4.4.3 +5.4.4.3 +======= + +new +--- +- update MediaInfo 20.03 +- mpv property window-maximized support added, cycling it from input.conf + might not be 100% reliable, it's likely a bug in the mpv client API and + will be further investigated soon -- update: MediaInfo 20.03 ### 5.4.4.2 diff --git a/mpv.net/Misc/App.cs b/mpv.net/Misc/App.cs index af9ae53..896bcc8 100644 --- a/mpv.net/Misc/App.cs +++ b/mpv.net/Misc/App.cs @@ -30,7 +30,6 @@ namespace mpvnet public static bool RememberHeight { get; set; } = true; public static bool RememberPosition { get; set; } - public static bool Maximized { get; set; } public static bool DebugMode { get; set; } public static bool IsStartedFromTerminal { get; } = Environment.GetEnvironmentVariable("_started_from_console") == "yes"; public static bool RememberVolume { get; set; } = true; @@ -171,7 +170,6 @@ namespace mpvnet switch (name) { case "remember-position": RememberPosition = value == "yes"; return true; - case "maximized": Maximized = value == "yes"; return true; case "debug-mode": DebugMode = value == "yes"; return true; case "remember-volume": RememberVolume = value == "yes"; return true; case "queue": Queue = value == "yes"; return true; diff --git a/mpv.net/Resources/editor.toml.txt b/mpv.net/Resources/editor.toml.txt index 479d55a..53ccec2 100644 --- a/mpv.net/Resources/editor.toml.txt +++ b/mpv.net/Resources/editor.toml.txt @@ -359,11 +359,11 @@ options = [{ name = "yes" }, { name = "no" }] [[settings]] -name = "maximized" -file = "mpvnet" +name = "window-maximized" +file = "mpv" default = "no" filter = "Screen" -help = "Start with a maximized window. (mpv.net specific setting)" +help = "Start with a maximized window." options = [{ name = "yes" }, { name = "no" }] diff --git a/mpv.net/WinForms/MainForm.cs b/mpv.net/WinForms/MainForm.cs index 3a12d1a..42818b1 100644 --- a/mpv.net/WinForms/MainForm.cs +++ b/mpv.net/WinForms/MainForm.cs @@ -53,13 +53,16 @@ namespace mpvnet mp.Idle += Idle; mp.Seek += () => UpdateProgressBar(); + mp.observe_property_bool("window-maximized", PropChangeWindowMaximized); mp.observe_property_bool("pause", PropChangePause); mp.observe_property_bool("fullscreen", PropChangeFullscreen); mp.observe_property_bool("ontop", PropChangeOnTop); mp.observe_property_bool("border", PropChangeBorder); + mp.observe_property_string("sid", PropChangeSid); mp.observe_property_string("aid", PropChangeAid); mp.observe_property_string("vid", PropChangeVid); + mp.observe_property_int("edition", PropChangeEdition); mp.observe_property_double("window-scale", PropChangeWindowScale); @@ -102,7 +105,7 @@ namespace mpvnet Top = posY - Height / 2; } - if (App.Maximized) + if (mp.WindowMaximized) { SetFormPosAndSize(1, true); WindowState = FormWindowState.Maximized; @@ -601,6 +604,22 @@ namespace mpvnet } } + void PropChangeWindowMaximized(bool enabled) + { + //TODO: this might not be reliable + if (!WasShown) + return; + + mp.WindowMaximized = enabled; + + Invoke(new Action(() => { + if (mp.WindowMaximized && WindowState != FormWindowState.Maximized) + WindowState = FormWindowState.Maximized; + else if (!mp.WindowMaximized && WindowState == FormWindowState.Maximized) + WindowState = FormWindowState.Normal; + })); + } + void PropChangeBorder(bool enabled) { mp.Border = enabled; diff --git a/mpv.net/mpv/mp.cs b/mpv.net/mpv/mp.cs index 9c7e9a9..1dcacbb 100644 --- a/mpv.net/mpv/mp.cs +++ b/mpv.net/mpv/mp.cs @@ -59,10 +59,11 @@ namespace mpvnet public static event Action Initialized; - public static List>> BoolPropChangeActions { get; set; } = new List>>(); - public static List>> IntPropChangeActions { get; set; } = new List>>(); + public static List>> BoolPropChangeActions { get; set; } = new List>>(); + public static List>> IntPropChangeActions { get; set; } = new List>>(); public static List>> DoublePropChangeActions { get; set; } = new List>>(); public static List>> StringPropChangeActions { get; set; } = new List>>(); + public static List MediaTracks { get; set; } = new List(); public static List> Chapters { get; set; } = new List>(); public static IntPtr Handle { get; set; } @@ -80,11 +81,12 @@ namespace mpvnet public static string Vid { get; set; } = ""; public static string GPUAPI { get; set; } = "auto"; + public static bool Border { get; set; } = true; + public static bool Fullscreen { get; set; } public static bool IsLogoVisible { set; get; } public static bool IsQuitNeeded { set; get; } = true; - public static bool Fullscreen { get; set; } - public static bool Border { get; set; } = true; public static bool TaskbarProgress { get; set; } = true; + public static bool WindowMaximized { get; set; } public static int Screen { get; set; } = -1; public static int Edition { get; set; } @@ -150,6 +152,7 @@ namespace mpvnet case "fs": case "fullscreen": Fullscreen = value == "yes"; break; case "border": Border = value == "yes"; break; + case "window-maximized": WindowMaximized = value == "yes"; break; case "taskbar-progress": TaskbarProgress = value == "yes"; break; case "screen": Screen = Convert.ToInt32(value); break; case "gpu-api": GPUAPI = value; break; @@ -251,6 +254,7 @@ namespace mpvnet foreach (var i in _Conf) ProcessProperty(i.Key, i.Value); } + return _Conf; } }