diff --git a/Changelog.md b/Changelog.md index f6ce4e3..4d547bc 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,7 @@ +### + +- fix: window restore was broken + ### 5.4.2.1 Beta - pressing shift key suppresses auto-load-folder diff --git a/LICENSE.txt b/LICENSE.txt index 66221ca..f1ca7dd 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,21 +1,24 @@ + MIT License -Copyright (c) 2017-2019 Frank Skare (stax76) +Copyright 2002-2017 Frank Skare (stax76) -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and ssociated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and ssociated documentation +files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of the Software, +and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH -THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR +THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/mpv.net/Misc/Misc.cs b/mpv.net/Misc/Misc.cs index ba5cc29..e876d92 100644 --- a/mpv.net/Misc/Misc.cs +++ b/mpv.net/Misc/Misc.cs @@ -20,7 +20,10 @@ namespace mpvnet public static bool IsDarkTheme { get { object value = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "AppsUseLightTheme", 1); - if (value is null) value = 1; + + if (value is null) + value = 1; + return (int)value == 0; } } @@ -62,43 +65,52 @@ namespace mpvnet { Types = types; - RegHelp.SetObject($"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\{ExeFilename}", null, ExePath); - RegHelp.SetObject($"HKCR\\Applications\\{ExeFilename}", "FriendlyAppName", "mpv.net media player"); - RegHelp.SetObject($"HKCR\\Applications\\{ExeFilename}\\shell\\open\\command", null, $"\"{ExePath}\" \"%1\""); + RegHelp.SetObject(@"HKCU\Software\Microsoft\Windows\CurrentVersion\App Paths\" + ExeFilename, null, ExePath); + RegHelp.SetObject(@"HKCR\Applications\" + ExeFilename, "FriendlyAppName", "mpv.net media player"); + RegHelp.SetObject($@"HKCR\Applications\{ExeFilename}\shell\open\command", null, $"\"{ExePath}\" \"%1\""); RegHelp.SetObject(@"HKLM\SOFTWARE\Clients\Media\mpv.net\Capabilities", "ApplicationDescription", "mpv.net media player"); RegHelp.SetObject(@"HKLM\SOFTWARE\Clients\Media\mpv.net\Capabilities", "ApplicationName", "mpv.net"); - RegHelp.SetObject($"HKCR\\SystemFileAssociations\\video\\OpenWithList\\{ExeFilename}", null, ""); - RegHelp.SetObject($"HKCR\\SystemFileAssociations\\audio\\OpenWithList\\{ExeFilename}", null, ""); + RegHelp.SetObject(@"HKCR\SystemFileAssociations\video\OpenWithList\" + ExeFilename, null, ""); + RegHelp.SetObject(@"HKCR\SystemFileAssociations\audio\OpenWithList\" + ExeFilename, null, ""); RegHelp.SetObject(@"HKLM\SOFTWARE\RegisteredApplications", "mpv.net", @"SOFTWARE\Clients\Media\mpv.net\Capabilities"); foreach (string ext in Types) { - RegHelp.SetObject($"HKCR\\Applications\\{ExeFilename}\\SupportedTypes", "." + ext, ""); - RegHelp.SetObject($"HKCR\\" + "." + ext, null, ExeFilenameNoExt + "." + ext); - RegHelp.SetObject($"HKCR\\" + "." + ext + "\\OpenWithProgIDs", ExeFilenameNoExt + "." + ext, ""); - if (App.VideoTypes.Contains(ext)) RegHelp.SetObject($"HKCR\\" + "." + ext, "PerceivedType", "video"); - if (App.AudioTypes.Contains(ext)) RegHelp.SetObject($"HKCR\\" + "." + ext, "PerceivedType", "audio"); - if (App.ImageTypes.Contains(ext)) RegHelp.SetObject($"HKCR\\" + "." + ext, "PerceivedType", "image"); - RegHelp.SetObject($"HKCR\\" + ExeFilenameNoExt + "." + ext + "\\shell\\open", null, "Play with " + Application.ProductName); - RegHelp.SetObject($"HKCR\\" + ExeFilenameNoExt + "." + ext + "\\shell\\open\\command", null, $"\"{ExePath}\" \"%1\""); + RegHelp.SetObject($@"HKCR\Applications\{ExeFilename}\SupportedTypes", "." + ext, ""); + RegHelp.SetObject($@"HKCR\" + "." + ext, null, ExeFilenameNoExt + "." + ext); + RegHelp.SetObject($@"HKCR\" + "." + ext + @"\OpenWithProgIDs", ExeFilenameNoExt + "." + ext, ""); + + if (App.VideoTypes.Contains(ext)) + RegHelp.SetObject(@"HKCR\" + "." + ext, "PerceivedType", "video"); + + if (App.AudioTypes.Contains(ext)) + RegHelp.SetObject(@"HKCR\" + "." + ext, "PerceivedType", "audio"); + + if (App.ImageTypes.Contains(ext)) + RegHelp.SetObject(@"HKCR\" + "." + ext, "PerceivedType", "image"); + + RegHelp.SetObject($@"HKCR\" + ExeFilenameNoExt + "." + ext + @"\shell\open", null, "Play with " + Application.ProductName); + RegHelp.SetObject($@"HKCR\" + ExeFilenameNoExt + "." + ext + @"\shell\open\command", null, $"\"{ExePath}\" \"%1\""); RegHelp.SetObject(@"HKLM\SOFTWARE\Clients\Media\mpv.net\Capabilities\FileAssociations", "." + ext, ExeFilenameNoExt + "." + ext); } } public static void Unregister() { - RegHelp.RemoveKey($"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\{ExeFilename}"); - RegHelp.RemoveKey($"HKCR\\Applications\\{ExeFilename}"); - RegHelp.RemoveKey($"HKLM\\SOFTWARE\\Clients\\Media\\mpv.net"); - RegHelp.RemoveKey($"HKCR\\SystemFileAssociations\\video\\OpenWithList\\{ExeFilename}"); - RegHelp.RemoveKey($"HKCR\\SystemFileAssociations\\audio\\OpenWithList\\{ExeFilename}"); + RegHelp.RemoveKey($@"HKCU\Software\Microsoft\Windows\CurrentVersion\App Paths\" + ExeFilename); + RegHelp.RemoveKey($@"HKCR\Applications\" + ExeFilename); + RegHelp.RemoveKey($@"HKLM\SOFTWARE\Clients\Media\mpv.net"); + RegHelp.RemoveKey($@"HKCR\SystemFileAssociations\video\OpenWithList\" + ExeFilename); + RegHelp.RemoveKey($@"HKCR\SystemFileAssociations\audio\OpenWithList\" + ExeFilename); RegHelp.RemoveValue(@"HKLM\SOFTWARE\RegisteredApplications", "mpv.net"); foreach (string id in Registry.ClassesRoot.GetSubKeyNames()) { - if (id.StartsWith(ExeFilenameNoExt + ".")) Registry.ClassesRoot.DeleteSubKeyTree(id); - RegHelp.RemoveValue($"HKCR\\Software\\Classes\\" + id + "\\OpenWithProgIDs", ExeFilenameNoExt + id); - RegHelp.RemoveValue($"HKLM\\Software\\Classes\\" + id + "\\OpenWithProgIDs", ExeFilenameNoExt + id); + if (id.StartsWith(ExeFilenameNoExt + ".")) + Registry.ClassesRoot.DeleteSubKeyTree(id); + + RegHelp.RemoveValue($@"HKCR\Software\Classes\{id}\OpenWithProgIDs", ExeFilenameNoExt + id); + RegHelp.RemoveValue($@"HKLM\Software\Classes\{id}\OpenWithProgIDs", ExeFilenameNoExt + id); } } } @@ -107,46 +119,43 @@ namespace mpvnet { public static void SetObject(string path, string name, object value) { - using (RegistryKey rk = GetRootKey(path).CreateSubKey(path.Substring(5), RegistryKeyPermissionCheck.ReadWriteSubTree)) - rk.SetValue(name, value); + using (RegistryKey regKey = GetRootKey(path).CreateSubKey(path.Substring(5), RegistryKeyPermissionCheck.ReadWriteSubTree)) + regKey.SetValue(name, value); } public static string GetString(string path, string name, string defaultValue = "") { - object val = GetObject(path, name, defaultValue); - if (val == null || !(val is string)) return ""; - return val.ToString(); + object value = GetObject(path, name, defaultValue); + return !(value is string) ? defaultValue : value.ToString(); } public static int GetInt(string path, string name, int defaultValue = 0) { - object val = GetObject(path, name, defaultValue); - if (val == null || !(val is int)) return 0; - return (int)val; + object value = GetObject(path, name, defaultValue); + return !(value is int) ? defaultValue : (int)value; } public static object GetObject(string path, string name, object defaultValue = null) { - using (RegistryKey rk = GetRootKey(path).OpenSubKey(path.Substring(5))) - if (rk != null) - return rk.GetValue(name, defaultValue); - else - return null; + using (RegistryKey regKey = GetRootKey(path).OpenSubKey(path.Substring(5))) + return regKey == null ? null : regKey.GetValue(name, defaultValue); } public static void RemoveKey(string path) { - try { + try + { GetRootKey(path).DeleteSubKeyTree(path.Substring(5), false); } catch { } } public static void RemoveValue(string path, string name) { - try { - using (RegistryKey rk = GetRootKey(path).OpenSubKey(path.Substring(5), true)) - if (!(rk is null)) - rk.DeleteValue(name, false); + try + { + using (RegistryKey regKey = GetRootKey(path).OpenSubKey(path.Substring(5), true)) + if (regKey != null) + regKey.DeleteValue(name, false); } catch {} } diff --git a/mpv.net/Native/MediaInfo.cs b/mpv.net/Native/MediaInfo.cs index 834ca65..41bdee8 100644 --- a/mpv.net/Native/MediaInfo.cs +++ b/mpv.net/Native/MediaInfo.cs @@ -56,9 +56,6 @@ public class MediaInfo : IDisposable ~MediaInfo() { Dispose(); } - [DllImport("kernel32.dll")] - public static extern IntPtr LoadLibrary(string path); - [DllImport("MediaInfo.dll")] static extern IntPtr MediaInfo_New(); diff --git a/mpv.net/Properties/AssemblyInfo.cs b/mpv.net/Properties/AssemblyInfo.cs index f1a6977..b532256 100644 --- a/mpv.net/Properties/AssemblyInfo.cs +++ b/mpv.net/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Frank Skare (stax76)")] [assembly: AssemblyProduct("mpv.net")] -[assembly: AssemblyCopyright("Copyright © 2017-2019 Frank Skare (stax76)")] +[assembly: AssemblyCopyright("Copyright 2017-2019 Frank Skare (stax76)")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -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("5.4.2.1")] -[assembly: AssemblyFileVersion("5.4.2.1")] +[assembly: AssemblyVersion("5.4.2.2")] +[assembly: AssemblyFileVersion("5.4.2.2")] diff --git a/mpv.net/Controls/SearchTextBoxUserControl.xaml b/mpv.net/WPF/SearchTextBoxUserControl.xaml similarity index 100% rename from mpv.net/Controls/SearchTextBoxUserControl.xaml rename to mpv.net/WPF/SearchTextBoxUserControl.xaml diff --git a/mpv.net/Controls/SearchTextBoxUserControl.xaml.cs b/mpv.net/WPF/SearchTextBoxUserControl.xaml.cs similarity index 100% rename from mpv.net/Controls/SearchTextBoxUserControl.xaml.cs rename to mpv.net/WPF/SearchTextBoxUserControl.xaml.cs diff --git a/mpv.net/WPF/WPF.cs b/mpv.net/WPF/WPF.cs index dca20d9..293ba79 100644 --- a/mpv.net/WPF/WPF.cs +++ b/mpv.net/WPF/WPF.cs @@ -1,5 +1,4 @@ using System; -using System.Globalization; using System.Windows; using System.Windows.Media; diff --git a/mpv.net/WinForms/MainForm.cs b/mpv.net/WinForms/MainForm.cs index 96e4d70..8c64139 100644 --- a/mpv.net/WinForms/MainForm.cs +++ b/mpv.net/WinForms/MainForm.cs @@ -97,7 +97,10 @@ namespace mpvnet } if (App.Maximized) + { + SetFormPosAndSize(1, true); WindowState = FormWindowState.Maximized; + } } catch (Exception ex) { @@ -247,17 +250,20 @@ namespace mpvnet bool WasInitialSizeSet; - void SetFormPosAndSize(double scale = 1) + void SetFormPosAndSize(double scale = 1, bool force = false) { - if (WindowState == FormWindowState.Maximized) - return; - - if (mp.Fullscreen) + if (!force) { - CycleFullscreen(true); - return; - } + if (WindowState == FormWindowState.Maximized) + return; + if (mp.Fullscreen) + { + CycleFullscreen(true); + return; + } + } + Screen screen = Screen.FromControl(this); int autoFitHeight = Convert.ToInt32(screen.WorkingArea.Height * mp.Autofit); @@ -481,13 +487,6 @@ namespace mpvnet var r2 = Marshal.PtrToStructure(m.LParam); Native.SetWindowPos(Handle, IntPtr.Zero, r2.Left, r2.Top, r2.Width, r2.Height, 0); break; - case 0x112: // WM_SYSCOMMAND - if (m.WParam.ToInt32() == 0xf120) // SC_RESTORE - { - CycleFullscreen(true); - CycleFullscreen(false); - } - break; case 0x0214: // WM_SIZING var rc = Marshal.PtrToStructure(m.LParam); var r = rc; diff --git a/mpv.net/mpv.net.csproj b/mpv.net/mpv.net.csproj index cab5bc0..dacae27 100644 --- a/mpv.net/mpv.net.csproj +++ b/mpv.net/mpv.net.csproj @@ -116,7 +116,7 @@ - + MSBuild:Compile Designer @@ -140,7 +140,7 @@ Designer MSBuild:Compile - + SearchTextBoxUserControl.xaml