From 87e3d9ca3ef02d04937566e16ffe761b0db0e6e8 Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Mon, 17 Jun 2019 21:35:14 +0200 Subject: [PATCH] - --- Changelog.md | 6 +++++- mpv.net/Misc/Misc.cs | 12 ++++++++---- mpv.net/Misc/Program.cs | 8 ++------ mpv.net/Native/Native.cs | 3 +++ mpv.net/Properties/AssemblyInfo.cs | 4 ++-- mpv.net/WinForms/MainForm.cs | 17 ++++++----------- mpv.net/mpv/mp.cs | 11 +++++++++-- 7 files changed, 35 insertions(+), 26 deletions(-) diff --git a/Changelog.md b/Changelog.md index a862c97..c36ed66 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,4 +1,8 @@ -### 4.2 Letting Go +### 4.3 + +- there was new bug in file association feature + +### 4.2 - the help and layout in the config editor was improved - clipboard monitoring for URLs can be disabled in the settings diff --git a/mpv.net/Misc/Misc.cs b/mpv.net/Misc/Misc.cs index 6ee0a48..96fce6c 100644 --- a/mpv.net/Misc/Misc.cs +++ b/mpv.net/Misc/Misc.cs @@ -212,14 +212,18 @@ namespace mpvnet public static void RemoveKey(string path) { - GetRootKey(path).DeleteSubKeyTree(path.Substring(5), false); + try { + GetRootKey(path).DeleteSubKeyTree(path.Substring(5), false); + } catch { } } public static void RemoveValue(string path, string name) { - using (RegistryKey rk = GetRootKey(path).OpenSubKey(path.Substring(5), true)) - if (!(rk is null)) - rk.DeleteValue(name, false); + try { + using (RegistryKey rk = GetRootKey(path).OpenSubKey(path.Substring(5), true)) + if (!(rk is null)) + rk.DeleteValue(name, false); + } catch {} } static RegistryKey GetRootKey(string path) diff --git a/mpv.net/Misc/Program.cs b/mpv.net/Misc/Program.cs index d2911f6..d3983d8 100644 --- a/mpv.net/Misc/Program.cs +++ b/mpv.net/Misc/Program.cs @@ -13,8 +13,6 @@ namespace mpvnet [STAThread] static void Main() { - Mutex mutex = new Mutex(true, "mpvnetProcessInstance", out bool isFirst); - try { string[] args = Environment.GetCommandLineArgs().Skip(1).ToArray(); @@ -27,6 +25,7 @@ namespace mpvnet return; } + Mutex mutex = new Mutex(true, "mpvnetProcessInstance", out bool isFirst); App.Init(); if ((App.ProcessInstance == "single" || App.ProcessInstance == "queue") && !isFirst) @@ -56,15 +55,12 @@ namespace mpvnet Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); + mutex.Dispose(); } catch (Exception ex) { Msg.ShowException(ex); } - finally - { - mutex.Dispose(); - } } } } \ No newline at end of file diff --git a/mpv.net/Native/Native.cs b/mpv.net/Native/Native.cs index 4939619..a6e04af 100644 --- a/mpv.net/Native/Native.cs +++ b/mpv.net/Native/Native.cs @@ -27,6 +27,9 @@ namespace mpvnet [DllImport("user32.dll", SetLastError = true)] public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags); + [DllImport("user32.dll")] + public static extern bool EnableWindow(IntPtr hWnd, bool bEnable); + [DllImport("user32.dll", EntryPoint = "GetWindowLong")] private static extern IntPtr GetWindowLong32(IntPtr hWnd, int nIndex); diff --git a/mpv.net/Properties/AssemblyInfo.cs b/mpv.net/Properties/AssemblyInfo.cs index 7905058..79b243c 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.2.0.0")] -[assembly: AssemblyFileVersion("4.2.0.0")] +[assembly: AssemblyVersion("4.3.0.0")] +[assembly: AssemblyFileVersion("4.3.0.0")] diff --git a/mpv.net/WinForms/MainForm.cs b/mpv.net/WinForms/MainForm.cs index 5fef005..0e0f688 100644 --- a/mpv.net/WinForms/MainForm.cs +++ b/mpv.net/WinForms/MainForm.cs @@ -343,6 +343,11 @@ namespace mpvnet if (mp.WindowHandle != IntPtr.Zero) Native.SendMessage(mp.WindowHandle, m.Msg, m.WParam, m.LParam); break; + case 0x0200: // WM_MOUSEMOVE + Point pos = PointToClient(Cursor.Position); + mp.command_string($"mouse {pos.X} {pos.Y}"); + if (CursorHelp.IsPosDifferent(LastCursorPosChanged)) CursorHelp.Show(); + break; case 0x319: // WM_APPCOMMAND if (mp.WindowHandle != IntPtr.Zero) Native.PostMessage(mp.WindowHandle, m.Msg, m.WParam, m.LParam); @@ -389,8 +394,7 @@ namespace mpvnet break; case "queue": foreach (string file in files) - if (File.Exists(file)) - mp.commandv("loadfile", file, "append"); + mp.commandv("loadfile", file, "append"); break; } } @@ -436,15 +440,6 @@ namespace mpvnet mp.commandv("quit"); } - protected override void OnMouseMove(MouseEventArgs e) - { - base.OnMouseMove(e); - mp.command_string($"mouse {e.X} {e.Y}"); - - if (CursorHelp.IsPosDifferent(LastCursorPosChanged)) - CursorHelp.Show(); - } - bool IsMouseInOSC() => PointToClient(Control.MousePosition).Y > ClientSize.Height * 0.9; void Timer_Tick(object sender, EventArgs e) diff --git a/mpv.net/mpv/mp.cs b/mpv.net/mpv/mp.cs index db2680b..f9828ee 100644 --- a/mpv.net/mpv/mp.cs +++ b/mpv.net/mpv/mp.cs @@ -193,7 +193,10 @@ namespace mpvnet mpv_event evt = (mpv_event)Marshal.PtrToStructure(ptr, typeof(mpv_event)); if (WindowHandle == IntPtr.Zero) + { WindowHandle = FindWindowEx(MainForm.Hwnd, IntPtr.Zero, "mpv", null); + //Native.EnableWindow(WindowHandle, true); + } //Debug.WriteLine(evt.event_id.ToString()); @@ -563,9 +566,12 @@ namespace mpvnet HideLogo(); List fileList = files.ToList(); - foreach (string file in files) { + foreach (string file in files) + { string ext = Path.GetExtension(file).TrimStart('.').ToLower(); - if (App.SubtitleTypes.Contains(ext)) { + + if (App.SubtitleTypes.Contains(ext)) + { mp.commandv("sub-add", file); fileList.Remove(file); } @@ -573,6 +579,7 @@ namespace mpvnet if (fileList.Count == 0) return; files = fileList.ToArray(); + int count = mp.get_property_int("playlist-count"); foreach (string file in files)