From 1c23c10c8151fcc0f50d2d4bd0e93ceb02f65b8f Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Wed, 23 Jun 2021 06:02:02 +0200 Subject: [PATCH] #268 Fix exception using named pipes --- docs/Changelog.md | 6 ++++-- docs/Manual.md | 3 ++- src/Misc/Commands.cs | 2 +- src/Misc/CorePlayer.cs | 4 +++- src/Misc/Misc.cs | 1 - src/Misc/Theme.cs | 8 ++++++-- src/Misc/UpdateCheck.cs | 6 +++--- src/WPF/CommandPaletteControl.xaml | 5 +++-- src/WinForms/MainForm.cs | 8 +++++--- 9 files changed, 27 insertions(+), 16 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index 4f831d4..2577b9c 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -2,10 +2,12 @@ 5.4.9.1 (2021-0?-??) ==================== +- Fix exception using named pipes. +- The mpv window property keepaspect-window was implemented. - Everything search removed to keep the core player lightweight, it might come back as user script or extension. -- Fancy new command palette implementation, it's now integrated into the main window. -- Playlist is now shown with the new command palette and not using the OSD. +- The command palette is integrated into the main window. +- Playlist is shown with the command palette and not using the OSD. - New media info command: `Ctrl+m script-message mpv.net show-media-info #menu: View > Show Media Info` - Context menu font render quality fix. - Context menu and `cycle-audio` command supports external audio and subtitle tracks. diff --git a/docs/Manual.md b/docs/Manual.md index 5223491..7e23a60 100644 --- a/docs/Manual.md +++ b/docs/Manual.md @@ -575,10 +575,11 @@ The documentation of mpvs window features can be found here: https://mpv.io/manual/master/#window -mpv.net has currently implemented the following window features: +mpv.net has currently implemented the following window properties: - [border](https://mpv.io/manual/master/#options-border) - [fullscreen](https://mpv.io/manual/master/#options-fullscreen) +- [keepaspect-window](https://mpv.io/manual/master/#options-keepaspect-window) - [ontop](https://mpv.io/manual/master/#options-ontop) - [screen](https://mpv.io/manual/master/#options-screen) - [title](https://mpv.io/manual/master/#options-title) diff --git a/src/Misc/Commands.cs b/src/Misc/Commands.cs index 9604ba1..2d44343 100644 --- a/src/Misc/Commands.cs +++ b/src/Misc/Commands.cs @@ -364,7 +364,7 @@ namespace mpvnet { string path = Core.GetPropertyString("path"); - if (File.Exists(path)) + if (File.Exists(path) && !path.Contains(@"\\.\pipe\")) { using (MediaInfo mediaInfo = new MediaInfo(path)) { diff --git a/src/Misc/CorePlayer.cs b/src/Misc/CorePlayer.cs index 0afbfd9..f8fdc63 100644 --- a/src/Misc/CorePlayer.cs +++ b/src/Misc/CorePlayer.cs @@ -103,6 +103,7 @@ namespace mpvnet public bool Fullscreen { get; set; } public bool IsLogoVisible { set; get; } = true; public bool IsQuitNeeded { set; get; } = true; + public bool KeepaspectWindow { get; set; } public bool TaskbarProgress { get; set; } = true; public bool WasInitialSizeSet; public bool WindowMaximized { get; set; } @@ -174,6 +175,7 @@ namespace mpvnet case "fs": case "fullscreen": Fullscreen = value == "yes"; break; case "border": Border = value == "yes"; break; + case "keepaspect-window": KeepaspectWindow = value == "yes"; break; case "window-maximized": WindowMaximized = value == "yes"; break; case "window-minimized": WindowMinimized = value == "yes"; break; case "taskbar-progress": TaskbarProgress = value == "yes"; break; @@ -1336,7 +1338,7 @@ namespace mpvnet } } } - else if (File.Exists(path)) + else if (File.Exists(path) && !path.Contains(@"\\.\pipe\")) { using (MediaInfo mi = new MediaInfo(path)) { diff --git a/src/Misc/Misc.cs b/src/Misc/Misc.cs index 79f87fa..97a84d8 100644 --- a/src/Misc/Misc.cs +++ b/src/Misc/Misc.cs @@ -242,7 +242,6 @@ namespace mpvnet public static IEnumerable GetItems() { - var aaa = CommandItem.Items.ToArray(); return CommandItem.Items .Where(i => i.Command != "") .Select(i => new CommandPaletteItem() { diff --git a/src/Misc/Theme.cs b/src/Misc/Theme.cs index d261eff..3a6138e 100644 --- a/src/Misc/Theme.cs +++ b/src/Misc/Theme.cs @@ -14,10 +14,12 @@ namespace mpvnet public static Theme Current { get; set; } + public Brush Background { get; set; } public Brush Foreground { get; set; } public Brush Foreground2 { get; set; } - public Brush Background { get; set; } public Brush Heading { get; set; } + public Brush MenuBackground { get; set; } + public Brush MenuHighlight { get; set; } public System.Drawing.Color GetWinFormsColor(string key) { @@ -67,10 +69,12 @@ namespace mpvnet if (Current == null) Current = DefaultThemes[0]; + Current.Background = Current.GetBrush("background"); Current.Foreground = Current.GetBrush("foreground"); Current.Foreground2 = Current.GetBrush("foreground2"); - Current.Background = Current.GetBrush("background"); Current.Heading = Current.GetBrush("heading"); + Current.MenuBackground = Current.GetBrush("menu-background"); + Current.MenuHighlight = Current.GetBrush("menu-highlight"); } static List Load(string content) diff --git a/src/Misc/UpdateCheck.cs b/src/Misc/UpdateCheck.cs index 2fa0bd5..7c2c598 100644 --- a/src/Misc/UpdateCheck.cs +++ b/src/Misc/UpdateCheck.cs @@ -34,7 +34,7 @@ namespace mpvnet if (!match.Success) { - App.ShowError("Update check is currently not available."); + App.InvokeOnMainThread(() => App.ShowError("Update check is currently not available.")); return; } @@ -44,7 +44,7 @@ namespace mpvnet if (onlineVersion <= currentVersion) { if (showUpToDateMessage) - Msg.ShowInfo($"{Application.ProductName} is up to date."); + App.InvokeOnMainThread(() => Msg.ShowInfo($"{Application.ProductName} is up to date.")); return; } @@ -60,7 +60,7 @@ namespace mpvnet proc.StartInfo.UseShellExecute = true; proc.StartInfo.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); proc.StartInfo.FileName = "powershell.exe"; - proc.StartInfo.Arguments = $"-NoExit -ExecutionPolicy Bypass -File \"{Folder.Startup + "Setup\\update.ps1"}\" \"{url}\" \"{Folder.Startup.TrimEnd(Path.DirectorySeparatorChar)}\""; + proc.StartInfo.Arguments = $"-NoExit -NoProfile -ExecutionPolicy Bypass -File \"{Folder.Startup + "Setup\\update.ps1"}\" \"{url}\" \"{Folder.Startup.TrimEnd(Path.DirectorySeparatorChar)}\""; if (Folder.Startup.Contains("Program Files")) proc.StartInfo.Verb = "runas"; diff --git a/src/WPF/CommandPaletteControl.xaml b/src/WPF/CommandPaletteControl.xaml index 433aa84..6b27904 100644 --- a/src/WPF/CommandPaletteControl.xaml +++ b/src/WPF/CommandPaletteControl.xaml @@ -11,7 +11,7 @@ Loaded="OnLoaded" Background="{Binding Theme.Background}" > - + @@ -37,7 +37,8 @@ Background="{Binding Theme.Background}" BorderThickness="0" MaxHeight="202" - SizeChanged="MainListView_SizeChanged" MouseUp="MainListView_MouseUp" + SizeChanged="MainListView_SizeChanged" + MouseUp="MainListView_MouseUp" > diff --git a/src/WinForms/MainForm.cs b/src/WinForms/MainForm.cs index 22d4fa6..b202f01 100644 --- a/src/WinForms/MainForm.cs +++ b/src/WinForms/MainForm.cs @@ -53,10 +53,11 @@ namespace mpvnet Core.observe_property("window-maximized", PropChangeWindowMaximized); Core.observe_property("window-minimized", PropChangeWindowMinimized); - Core.observe_property_bool("pause", PropChangePause); - Core.observe_property_bool("fullscreen", PropChangeFullscreen); - Core.observe_property_bool("ontop", PropChangeOnTop); Core.observe_property_bool("border", PropChangeBorder); + Core.observe_property_bool("fullscreen", PropChangeFullscreen); + Core.observe_property_bool("keepaspect-window", value => Core.KeepaspectWindow = value); + Core.observe_property_bool("ontop", PropChangeOnTop); + Core.observe_property_bool("pause", PropChangePause); Core.observe_property_string("sid", PropChangeSid); Core.observe_property_string("aid", PropChangeAid); @@ -751,6 +752,7 @@ namespace mpvnet } break; case 0x0214: // WM_SIZING + if (Core.KeepaspectWindow) { RECT rc = Marshal.PtrToStructure(m.LParam); RECT r = rc;