From d27778775daf57bac90f6b8fc9b33f0ef03195ac Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Sat, 13 Jul 2019 16:35:42 +0200 Subject: [PATCH] few layout problems were fixed, autosize for instance did not work --- Changelog.md | 10 ++++++--- mpv.net/Properties/AssemblyInfo.cs | 4 ++-- mpv.net/Resources/mpvConfToml.txt | 2 +- mpv.net/WinForms/MainForm.Designer.cs | 2 +- mpv.net/WinForms/MainForm.cs | 28 +++++++++++++++-------- mpv.net/mpv/mp.cs | 32 ++++++++++++++++++--------- 6 files changed, 51 insertions(+), 27 deletions(-) diff --git a/Changelog.md b/Changelog.md index d5c9642..c4bc45c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,7 @@ +### 4.7.1 + +- few layout problems were fixed, autosize for instance did not work + ### 4.7 - remember-height was replaced with start-size, when start-size is set @@ -7,14 +11,14 @@ - on exit the window location can be saved with remember-position - in the learn window of the input editor underscores were stripped because they have a special meaning in WPF labels -- keys/input not working for MBTN_LEFT_DBL, MBTN_BACK, MBTN_FORWARD +- fix for keys/input not working for MBTN_LEFT_DBL, MBTN_BACK, MBTN_FORWARD - in the learn window of the input editor support was added for mouse left, mouse left double, mouse mid, mouse forward, mouse back -- libmpv updated to shinchiro 2019-07-07 +- libmpv was updated to shinchiro 2019-07-07 - when border is none it wasn't possible to minimize the window from the task bar because this is the WinForms default behavier. This was fixed by calling Spy++ to the rescue and adding WS_MINIMIZEBOX - in CreateParams + in CreateParams ### 4.6 diff --git a/mpv.net/Properties/AssemblyInfo.cs b/mpv.net/Properties/AssemblyInfo.cs index cf29616..ebf74ca 100644 --- a/mpv.net/Properties/AssemblyInfo.cs +++ b/mpv.net/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("4.7.0.0")] -[assembly: AssemblyFileVersion("4.7.0.0")] +[assembly: AssemblyVersion("4.7.1.0")] +[assembly: AssemblyFileVersion("4.7.1.0")] diff --git a/mpv.net/Resources/mpvConfToml.txt b/mpv.net/Resources/mpvConfToml.txt index 9b9f41a..16c80f9 100644 --- a/mpv.net/Resources/mpvConfToml.txt +++ b/mpv.net/Resources/mpvConfToml.txt @@ -274,7 +274,7 @@ options = [{ name = "yes", help = "Don't terminate if the current file is the [[settings]] name = "loop-file" filter = "Playback" -help = "Loop a single file N times. inf means forever, no means normal playback.\n\nThe difference to loop-playlist is that this doesn't loop the playlist, just the file itself. If the playlist contains only a single file, the difference between the two option is that this option performs a seek on loop, instead of reloading the file. loop is an alias for this option." +help = " Loop a single file N times. inf means forever, no means normal playback.\n\nThe difference to loop-playlist is that this doesn't loop the playlist, just the file itself. If the playlist contains only a single file, the difference between the two option is that this option performs a seek on loop, instead of reloading the file. loop is an alias for this option." [[settings]] name = "save-position-on-quit" diff --git a/mpv.net/WinForms/MainForm.Designer.cs b/mpv.net/WinForms/MainForm.Designer.cs index f9e682e..f954462 100644 --- a/mpv.net/WinForms/MainForm.Designer.cs +++ b/mpv.net/WinForms/MainForm.Designer.cs @@ -45,7 +45,7 @@ this.AutoScaleDimensions = new System.Drawing.SizeF(288F, 288F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.BackColor = System.Drawing.Color.Black; - this.ClientSize = new System.Drawing.Size(1777, 1109); + this.ClientSize = new System.Drawing.Size(348, 0); this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); diff --git a/mpv.net/WinForms/MainForm.cs b/mpv.net/WinForms/MainForm.cs index 01cc7d5..5975740 100644 --- a/mpv.net/WinForms/MainForm.cs +++ b/mpv.net/WinForms/MainForm.cs @@ -221,6 +221,8 @@ namespace mpvnet return null; } + bool WasInitialSizeSet; + void SetFormPosAndSize() { if (mp.Fullscreen) @@ -229,23 +231,31 @@ namespace mpvnet return; } - Size size = mp.VideoSize; Screen screen = Screen.FromControl(this); - int fixedHeight = Convert.ToInt32(screen.Bounds.Height * mp.Autofit); + int autoFitHeight = Convert.ToInt32(screen.Bounds.Height * mp.Autofit); - if (size.Height == 0 || size.Width == 0 || size.Width / (float)size.Height < 1.3) - { - size.Height = fixedHeight; - size.Width = (int)(fixedHeight * 1.7); - } + if (mp.VideoSize.Height == 0 || mp.VideoSize.Width == 0 || + mp.VideoSize.Width / (float)mp.VideoSize.Height < 1.3) + + mp.VideoSize = new Size((int)(autoFitHeight * 1.7), autoFitHeight); + + Size size = mp.VideoSize; int height = size.Height; if (App.RememberHeight) - height = ClientSize.Height; + { + if (WasInitialSizeSet) + height = ClientSize.Height; + else + { + height = autoFitHeight; + WasInitialSizeSet = true; + } + } if (height > screen.Bounds.Height * 0.9) - height = fixedHeight; + height = autoFitHeight; int width = Convert.ToInt32(height * size.Width / (double)size.Height); Point middlePos = new Point(Left + Width / 2, Top + Height / 2); diff --git a/mpv.net/mpv/mp.cs b/mpv.net/mpv/mp.cs index cb7aba9..d8937f4 100644 --- a/mpv.net/mpv/mp.cs +++ b/mpv.net/mpv/mp.cs @@ -79,6 +79,8 @@ namespace mpvnet public static float Autofit { get; set; } = 0.5f; + static string LastPlaybackRestartFile; + public static void Init() { LoadLibrary("mpv-1.dll"); @@ -211,7 +213,7 @@ namespace mpvnet if (WindowHandle == IntPtr.Zero) WindowHandle = FindWindowEx(MainForm.Hwnd, IntPtr.Zero, "mpv", null); - //System.Diagnostics.Debug.WriteLine(evt.event_id.ToString()); + // System.Diagnostics.Debug.WriteLine(evt.event_id.ToString()); try { @@ -309,17 +311,21 @@ namespace mpvnet break; case mpv_event_id.MPV_EVENT_PLAYBACK_RESTART: PlaybackRestart?.Invoke(); - Size vidSize = new Size(get_property_int("dwidth"), get_property_int("dheight")); - - if (VideoSize != vidSize && vidSize != Size.Empty) + string path = get_property_string("path"); + if (LastPlaybackRestartFile != path) { - VideoSize = vidSize; - VideoSizeChanged?.Invoke(); + Size vidSize = new Size(get_property_int("dwidth"), get_property_int("dheight")); + if (vidSize.Width == 0 || vidSize.Height == 0) + vidSize = new Size(1, 1); + if (VideoSize != vidSize) + { + VideoSize = vidSize; + VideoSizeChanged?.Invoke(); + } + VideoSizeAutoResetEvent.Set(); + Task.Run(new Action(() => ReadMetaData())); + LastPlaybackRestartFile = path; } - - VideoSizeAutoResetEvent.Set(); - - Task.Run(new Action(() => ReadMetaData())); break; case mpv_event_id.MPV_EVENT_CHAPTER_CHANGE: ChapterChange?.Invoke(); @@ -516,7 +522,11 @@ namespace mpvnet Load(files.ToArray(), App.ProcessInstance != "queue", Control.ModifierKeys.HasFlag(Keys.Control)); - if (files.Count == 0) VideoSizeAutoResetEvent.Set(); + if (files.Count == 0) + { + VideoSizeAutoResetEvent.Set(); + VideoSizeChanged?.Invoke(); + } foreach (string i in args) {