From 8debcc171c513b83c3eb117335fa802d4c5664cf Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Wed, 21 Aug 2019 16:52:09 +0200 Subject: [PATCH] added new setting to start with maximized window --- Changelog.md | 3 +-- README.md | 2 +- mpv.net/Misc/App.cs | 2 ++ mpv.net/Resources/mpvNetConfToml.txt | 8 ++++++++ mpv.net/WinForms/MainForm.cs | 9 +++++++-- mpv.net/mpv/mp.cs | 13 ++++--------- 6 files changed, 23 insertions(+), 14 deletions(-) diff --git a/Changelog.md b/Changelog.md index f1e3e0f..0001e2b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,7 +1,6 @@ ### -- osc=yes and input-media-keys=yes was enforced, - now it can be disabled in mpv.conf +- added new setting to start with maximized window ### 5.3 diff --git a/README.md b/README.md index 368e93e..249dab4 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ Table of contents - Screenshot feature with many options - File history feature to log time and filename - A-B loop feature -- watch later feature to save the position +- Watch later feature to save the position - [Manual](#manual) ### Screenshots diff --git a/mpv.net/Misc/App.cs b/mpv.net/Misc/App.cs index 7261ddb..afdc97f 100644 --- a/mpv.net/Misc/App.cs +++ b/mpv.net/Misc/App.cs @@ -23,6 +23,7 @@ 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; @@ -106,6 +107,7 @@ namespace mpvnet switch (name) { case "remember-position": RememberPosition = value == "yes"; return true; + case "maximized": Maximized = value == "yes"; return true; case "start-size": RememberHeight = value == "previous"; return true; case "process-instance": ProcessInstance = value; return true; case "dark-mode": DarkMode = value; return true; diff --git a/mpv.net/Resources/mpvNetConfToml.txt b/mpv.net/Resources/mpvNetConfToml.txt index 8796012..66e49b1 100644 --- a/mpv.net/Resources/mpvNetConfToml.txt +++ b/mpv.net/Resources/mpvNetConfToml.txt @@ -45,6 +45,14 @@ help = "Save the window position on exit. (mpv.net specific setting)" options = [{ name = "yes" }, { name = "no" }] +[[settings]] +name = "maximized" +default = "no" +filter = "Screen" +help = "Start with a maximized window. (mpv.net specific setting)" +options = [{ name = "yes" }, + { name = "no" }] + [[settings]] name = "remember-volume" default = "yes" diff --git a/mpv.net/WinForms/MainForm.cs b/mpv.net/WinForms/MainForm.cs index 781525e..aea2983 100644 --- a/mpv.net/WinForms/MainForm.cs +++ b/mpv.net/WinForms/MainForm.cs @@ -83,6 +83,8 @@ namespace mpvnet Left = posX - Width / 2; Top = posY - Height / 2; } + + if (App.Maximized) WindowState = FormWindowState.Maximized; } catch (Exception ex) { @@ -104,7 +106,7 @@ namespace mpvnet void ContextMenu_Opened(object sender, EventArgs e) => CursorHelp.Show(); - bool IsFullscreen => WindowState == FormWindowState.Maximized; + bool IsFullscreen => WindowState == FormWindowState.Maximized && FormBorderStyle == FormBorderStyle.None; bool IsMouseInOSC() => PointToClient(Control.MousePosition).Y > ClientSize.Height * 0.9; @@ -228,6 +230,9 @@ namespace mpvnet void SetFormPosAndSize() { + if (WindowState == FormWindowState.Maximized) + return; + if (mp.Fullscreen) { CycleFullscreen(true); @@ -320,7 +325,7 @@ namespace mpvnet } else { - if (WindowState == FormWindowState.Maximized) + if (WindowState == FormWindowState.Maximized && FormBorderStyle == FormBorderStyle.None) { WindowState = FormWindowState.Normal; diff --git a/mpv.net/mpv/mp.cs b/mpv.net/mpv/mp.cs index 83adf57..0426170 100644 --- a/mpv.net/mpv/mp.cs +++ b/mpv.net/mpv/mp.cs @@ -103,10 +103,8 @@ namespace mpvnet } set_property_string("wid", MainForm.Hwnd.ToString()); - - if (!Conf.Keys.Contains("osc")) set_property_string("osc", "yes"); - if (!Conf.Keys.Contains("input-media-keys")) set_property_string("input-media-keys", "yes"); - + set_property_string("osc", "yes"); + set_property_string("input-media-keys", "yes"); set_property_string("force-window", "yes"); set_property_string("config-dir", ConfigFolder); set_property_string("config", "yes"); @@ -418,11 +416,8 @@ namespace mpvnet static void HideLogo() { - if (IsLogoVisible) - { - commandv("overlay-remove", "0"); - IsLogoVisible = false; - } + command("overlay-remove 0"); + IsLogoVisible = false; } static List PythonEventObjects = new List();