From d8f916aa03f5ea5640398579d999bff9e044e7e7 Mon Sep 17 00:00:00 2001 From: Taiizor <41683699+Taiizor@users.noreply.github.com> Date: Thu, 26 Oct 2023 16:27:32 +0300 Subject: [PATCH] #44 Bug Fixes --- .../View/Application.xaml.cs | 4 +- .../View/Gif.xaml.cs | 5 +- .../View/Url.xaml.cs | 5 +- .../View/Video.xaml.cs | 5 +- .../View/Web.xaml.cs | 5 +- .../View/YouTube.xaml.cs | 5 +- .../View/Video.xaml.cs | 5 +- .../View/Video.xaml.cs | 5 +- .../View/Gif.xaml.cs | 5 +- .../View/Gif.xaml.cs | 5 +- .../View/Url.xaml.cs | 5 +- .../View/Video.xaml.cs | 5 +- .../View/Web.xaml.cs | 5 +- .../View/YouTube.xaml.cs | 5 +- .../Sucrose.Shared.Engine/Event/Handler.cs | 61 ++++++++++++++----- 15 files changed, 101 insertions(+), 29 deletions(-) diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.Aurora/View/Application.xaml.cs b/src/Shared/Engine/Sucrose.Shared.Engine.Aurora/View/Application.xaml.cs index 1c7d14fe0..236371340 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine.Aurora/View/Application.xaml.cs +++ b/src/Shared/Engine/Sucrose.Shared.Engine.Aurora/View/Application.xaml.cs @@ -1,4 +1,5 @@ -using System.Diagnostics; +using Microsoft.Win32; +using System.Diagnostics; using System.IO; using System.Windows; using SMC = Sucrose.Memory.Constant; @@ -53,6 +54,7 @@ public Application(string Application, string Arguments) SSEEH.ApplicationLoaded(SSEAMI.ApplicationProcess); SSEEH.ApplicationRendered(SSEAMI.ApplicationProcess); + SystemEvents.DisplaySettingsChanged += (s, e) => SSEEH.DisplaySettingsChanged(SSEAMI.ApplicationProcess, SSEAMI.ApplicationHandle); SSEAHA.SetVolume(SSEHD.GetVolume()); } diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Gif.xaml.cs b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Gif.xaml.cs index e610c1352..9ec928fa3 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Gif.xaml.cs +++ b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Gif.xaml.cs @@ -1,4 +1,5 @@ -using System.Windows; +using Microsoft.Win32; +using System.Windows; using SSECSEG = Sucrose.Shared.Engine.CefSharp.Event.Gif; using SSECSHCCM = Sucrose.Shared.Engine.CefSharp.Handler.CustomContextMenu; using SSECSHG = Sucrose.Shared.Engine.CefSharp.Helper.Gif; @@ -19,6 +20,8 @@ public Gif(string Gif) { InitializeComponent(); + SystemEvents.DisplaySettingsChanged += (s, e) => SSEEH.DisplaySettingsChanged(this); + ContentRendered += (s, e) => SSEEH.ContentRendered(this); SSECSMI.CefEngine.MenuHandler = new SSECSHCCM(); diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Url.xaml.cs b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Url.xaml.cs index 11d9cb883..0a147960a 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Url.xaml.cs +++ b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Url.xaml.cs @@ -1,4 +1,5 @@ -using System.Windows; +using Microsoft.Win32; +using System.Windows; using SSECSEU = Sucrose.Shared.Engine.CefSharp.Event.Url; using SSECSHCCM = Sucrose.Shared.Engine.CefSharp.Handler.CustomContextMenu; using SSECSHU = Sucrose.Shared.Engine.CefSharp.Helper.Url; @@ -19,6 +20,8 @@ public Url(string Url) { InitializeComponent(); + SystemEvents.DisplaySettingsChanged += (s, e) => SSEEH.DisplaySettingsChanged(this); + ContentRendered += (s, e) => SSEEH.ContentRendered(this); SSECSMI.CefEngine.MenuHandler = new SSECSHCCM(); diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Video.xaml.cs b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Video.xaml.cs index 7a2d0e601..c9722dcfb 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Video.xaml.cs +++ b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Video.xaml.cs @@ -1,4 +1,5 @@ -using System.Windows; +using Microsoft.Win32; +using System.Windows; using SSECSEV = Sucrose.Shared.Engine.CefSharp.Event.Video; using SSECSHCCM = Sucrose.Shared.Engine.CefSharp.Handler.CustomContextMenu; using SSECSHV = Sucrose.Shared.Engine.CefSharp.Helper.Video; @@ -20,6 +21,8 @@ public Video(string Video) { InitializeComponent(); + SystemEvents.DisplaySettingsChanged += (s, e) => SSEEH.DisplaySettingsChanged(this); + ContentRendered += (s, e) => SSEEH.ContentRendered(this); SSECSMI.CefEngine.MenuHandler = new SSECSHCCM(); diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Web.xaml.cs b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Web.xaml.cs index 3762caf5d..b1d490081 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Web.xaml.cs +++ b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/Web.xaml.cs @@ -1,4 +1,5 @@ -using System.Windows; +using Microsoft.Win32; +using System.Windows; using SSECSEW = Sucrose.Shared.Engine.CefSharp.Event.Web; using SSECSHCCM = Sucrose.Shared.Engine.CefSharp.Handler.CustomContextMenu; using SSECSHW = Sucrose.Shared.Engine.CefSharp.Helper.Web; @@ -19,6 +20,8 @@ public Web(string Web) { InitializeComponent(); + SystemEvents.DisplaySettingsChanged += (s, e) => SSEEH.DisplaySettingsChanged(this); + ContentRendered += (s, e) => SSEEH.ContentRendered(this); SSECSMI.CefEngine.MenuHandler = new SSECSHCCM(); diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/YouTube.xaml.cs b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/YouTube.xaml.cs index 4af8283a7..fc5bde510 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/YouTube.xaml.cs +++ b/src/Shared/Engine/Sucrose.Shared.Engine.CefSharp/View/YouTube.xaml.cs @@ -1,4 +1,5 @@ -using System.Windows; +using Microsoft.Win32; +using System.Windows; using SSECSEYT = Sucrose.Shared.Engine.CefSharp.Event.YouTube; using SSECSHCCM = Sucrose.Shared.Engine.CefSharp.Handler.CustomContextMenu; using SSECSHYT = Sucrose.Shared.Engine.CefSharp.Helper.YouTube; @@ -19,6 +20,8 @@ public YouTube(string YouTube) { InitializeComponent(); + SystemEvents.DisplaySettingsChanged += (s, e) => SSEEH.DisplaySettingsChanged(this); + ContentRendered += (s, e) => SSEEH.ContentRendered(this); SSECSMI.CefEngine.MenuHandler = new SSECSHCCM(); diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.MpvPlayer/View/Video.xaml.cs b/src/Shared/Engine/Sucrose.Shared.Engine.MpvPlayer/View/Video.xaml.cs index 540d93549..33df949c3 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine.MpvPlayer/View/Video.xaml.cs +++ b/src/Shared/Engine/Sucrose.Shared.Engine.MpvPlayer/View/Video.xaml.cs @@ -1,4 +1,5 @@ -using System.Windows; +using Microsoft.Win32; +using System.Windows; using System.Windows.Media; using SSEEH = Sucrose.Shared.Engine.Event.Handler; using SSEHD = Sucrose.Shared.Engine.Helper.Data; @@ -19,6 +20,8 @@ public Video(string Video) { InitializeComponent(); + SystemEvents.DisplaySettingsChanged += (s, e) => SSEEH.DisplaySettingsChanged(this); + SSEMPMI.Source = SSEHS.GetSource(Video).ToString(); ContentRendered += (s, e) => SSEEH.ContentRendered(this); diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.Nebula/View/Video.xaml.cs b/src/Shared/Engine/Sucrose.Shared.Engine.Nebula/View/Video.xaml.cs index 049326e32..f11b24604 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine.Nebula/View/Video.xaml.cs +++ b/src/Shared/Engine/Sucrose.Shared.Engine.Nebula/View/Video.xaml.cs @@ -1,4 +1,5 @@ -using System.Windows; +using Microsoft.Win32; +using System.Windows; using System.Windows.Media; using SSEEH = Sucrose.Shared.Engine.Event.Handler; using SSEHD = Sucrose.Shared.Engine.Helper.Data; @@ -20,6 +21,8 @@ public Video(string Video) { InitializeComponent(); + SystemEvents.DisplaySettingsChanged += (s, e) => SSEEH.DisplaySettingsChanged(this); + ContentRendered += (s, e) => SSEEH.ContentRendered(this); Content = SSENMI.MediaEngine; diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.Vexana/View/Gif.xaml.cs b/src/Shared/Engine/Sucrose.Shared.Engine.Vexana/View/Gif.xaml.cs index a088fe5ef..b0732cb3b 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine.Vexana/View/Gif.xaml.cs +++ b/src/Shared/Engine/Sucrose.Shared.Engine.Vexana/View/Gif.xaml.cs @@ -1,4 +1,5 @@ -using System.Windows; +using Microsoft.Win32; +using System.Windows; using System.Windows.Media; using SSEEH = Sucrose.Shared.Engine.Event.Handler; using SSEHD = Sucrose.Shared.Engine.Helper.Data; @@ -21,6 +22,8 @@ public Gif(string Gif) { InitializeComponent(); + SystemEvents.DisplaySettingsChanged += (s, e) => SSEEH.DisplaySettingsChanged(this); + ContentRendered += (s, e) => SSEEH.ContentRendered(this); Content = SSEVMI.ImageEngine; diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.WebView/View/Gif.xaml.cs b/src/Shared/Engine/Sucrose.Shared.Engine.WebView/View/Gif.xaml.cs index 894c687b9..61153ba24 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine.WebView/View/Gif.xaml.cs +++ b/src/Shared/Engine/Sucrose.Shared.Engine.WebView/View/Gif.xaml.cs @@ -1,4 +1,5 @@ -using System.Windows; +using Microsoft.Win32; +using System.Windows; using SSEEH = Sucrose.Shared.Engine.Event.Handler; using SSEHD = Sucrose.Shared.Engine.Helper.Data; using SSEHR = Sucrose.Shared.Engine.Helper.Run; @@ -18,6 +19,8 @@ public Gif(string Gif) { InitializeComponent(); + SystemEvents.DisplaySettingsChanged += (s, e) => SSEEH.DisplaySettingsChanged(this); + ContentRendered += (s, e) => SSEEH.ContentRendered(this); Content = SSEWVMI.WebEngine; diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.WebView/View/Url.xaml.cs b/src/Shared/Engine/Sucrose.Shared.Engine.WebView/View/Url.xaml.cs index aeb3fe2aa..f3842062b 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine.WebView/View/Url.xaml.cs +++ b/src/Shared/Engine/Sucrose.Shared.Engine.WebView/View/Url.xaml.cs @@ -1,4 +1,5 @@ -using System.Windows; +using Microsoft.Win32; +using System.Windows; using SSEEH = Sucrose.Shared.Engine.Event.Handler; using SSEHD = Sucrose.Shared.Engine.Helper.Data; using SSEHR = Sucrose.Shared.Engine.Helper.Run; @@ -18,6 +19,8 @@ public Url(string Url) { InitializeComponent(); + SystemEvents.DisplaySettingsChanged += (s, e) => SSEEH.DisplaySettingsChanged(this); + ContentRendered += (s, e) => SSEEH.ContentRendered(this); Content = SSEWVMI.WebEngine; diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.WebView/View/Video.xaml.cs b/src/Shared/Engine/Sucrose.Shared.Engine.WebView/View/Video.xaml.cs index 8917f57c7..a7c5391d8 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine.WebView/View/Video.xaml.cs +++ b/src/Shared/Engine/Sucrose.Shared.Engine.WebView/View/Video.xaml.cs @@ -1,4 +1,5 @@ -using System.Windows; +using Microsoft.Win32; +using System.Windows; using SSEEH = Sucrose.Shared.Engine.Event.Handler; using SSEHD = Sucrose.Shared.Engine.Helper.Data; using SSEHR = Sucrose.Shared.Engine.Helper.Run; @@ -18,6 +19,8 @@ public Video(string Video) { InitializeComponent(); + SystemEvents.DisplaySettingsChanged += (s, e) => SSEEH.DisplaySettingsChanged(this); + ContentRendered += (s, e) => SSEEH.ContentRendered(this); Content = SSEWVMI.WebEngine; diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.WebView/View/Web.xaml.cs b/src/Shared/Engine/Sucrose.Shared.Engine.WebView/View/Web.xaml.cs index 55815992f..e94616397 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine.WebView/View/Web.xaml.cs +++ b/src/Shared/Engine/Sucrose.Shared.Engine.WebView/View/Web.xaml.cs @@ -1,4 +1,5 @@ -using System.Windows; +using Microsoft.Win32; +using System.Windows; using SSEEH = Sucrose.Shared.Engine.Event.Handler; using SSEHD = Sucrose.Shared.Engine.Helper.Data; using SSEHR = Sucrose.Shared.Engine.Helper.Run; @@ -18,6 +19,8 @@ public Web(string Web) { InitializeComponent(); + SystemEvents.DisplaySettingsChanged += (s, e) => SSEEH.DisplaySettingsChanged(this); + ContentRendered += (s, e) => SSEEH.ContentRendered(this); Content = SSEWVMI.WebEngine; diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.WebView/View/YouTube.xaml.cs b/src/Shared/Engine/Sucrose.Shared.Engine.WebView/View/YouTube.xaml.cs index 8cc359145..ea31a4f5e 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine.WebView/View/YouTube.xaml.cs +++ b/src/Shared/Engine/Sucrose.Shared.Engine.WebView/View/YouTube.xaml.cs @@ -1,4 +1,5 @@ -using System.Windows; +using Microsoft.Win32; +using System.Windows; using SSEEH = Sucrose.Shared.Engine.Event.Handler; using SSEHD = Sucrose.Shared.Engine.Helper.Data; using SSEHR = Sucrose.Shared.Engine.Helper.Run; @@ -18,6 +19,8 @@ public YouTube(string YouTube) { InitializeComponent(); + SystemEvents.DisplaySettingsChanged += (s, e) => SSEEH.DisplaySettingsChanged(this); + ContentRendered += (s, e) => SSEEH.ContentRendered(this); Content = SSEWVMI.WebEngine; diff --git a/src/Shared/Engine/Sucrose.Shared.Engine/Event/Handler.cs b/src/Shared/Engine/Sucrose.Shared.Engine/Event/Handler.cs index 3dd51a053..e7d596690 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine/Event/Handler.cs +++ b/src/Shared/Engine/Sucrose.Shared.Engine/Event/Handler.cs @@ -7,6 +7,7 @@ using SWHWI = Skylark.Wing.Helper.WindowInterop; using SWHWO = Skylark.Wing.Helper.WindowOperations; using SWNM = Skylark.Wing.Native.Methods; +using SWUS = Skylark.Wing.Utility.Screene; namespace Sucrose.Shared.Engine.Event { @@ -24,21 +25,6 @@ public static void WindowLoaded(Window Window) Window.ShowInTaskbar = false; } - public static void ApplicationLoaded(Process Process) - { - IntPtr Handle = SWHPI.MainWindowHandle(Process); - - //ShowInTaskbar = false : causing issue with Windows10-Windows11 Taskview. - SWHWO.RemoveWindowFromTaskbar(Handle); - - SWNM.ShowWindow(Handle, (int)SWNM.SHOWWINDOW.SW_HIDE); - - int currentStyle = SWNM.GetWindowLong(Handle, (int)SWNM.GWL.GWL_STYLE); - SWNM.SetWindowLong(Handle, (int)SWNM.GWL.GWL_STYLE, currentStyle & ~((int)SWNM.WindowStyles.WS_CAPTION | (int)SWNM.WindowStyles.WS_THICKFRAME | (int)SWNM.WindowStyles.WS_MINIMIZE | (int)SWNM.WindowStyles.WS_MAXIMIZE | (int)SWNM.WindowStyles.WS_SYSMENU | (int)SWNM.WindowStyles.WS_DLGFRAME | (int)SWNM.WindowStyles.WS_BORDER | (int)SWNM.WindowStyles.WS_EX_CLIENTEDGE)); - - SWHWO.BorderlessWinStyle(Handle); - } - public static void ContentRendered(Window Window) { switch (SSEHD.GetDisplayType()) @@ -55,6 +41,21 @@ public static void ContentRendered(Window Window) } } + public static void ApplicationLoaded(Process Process) + { + IntPtr Handle = SWHPI.MainWindowHandle(Process); + + //ShowInTaskbar = false : causing issue with Windows10-Windows11 Taskview. + SWHWO.RemoveWindowFromTaskbar(Handle); + + SWNM.ShowWindow(Handle, (int)SWNM.SHOWWINDOW.SW_HIDE); + + int currentStyle = SWNM.GetWindowLong(Handle, (int)SWNM.GWL.GWL_STYLE); + SWNM.SetWindowLong(Handle, (int)SWNM.GWL.GWL_STYLE, currentStyle & ~((int)SWNM.WindowStyles.WS_CAPTION | (int)SWNM.WindowStyles.WS_THICKFRAME | (int)SWNM.WindowStyles.WS_MINIMIZE | (int)SWNM.WindowStyles.WS_MAXIMIZE | (int)SWNM.WindowStyles.WS_SYSMENU | (int)SWNM.WindowStyles.WS_DLGFRAME | (int)SWNM.WindowStyles.WS_BORDER | (int)SWNM.WindowStyles.WS_EX_CLIENTEDGE)); + + SWHWO.BorderlessWinStyle(Handle); + } + public static void ApplicationRendered(Process Process) { switch (SSEHD.GetDisplayType()) @@ -72,5 +73,35 @@ public static void ApplicationRendered(Process Process) SWNM.ShowWindow(SWHPI.MainWindowHandle(Process), (int)SWNM.SHOWWINDOW.SW_SHOW); } + + public static async void DisplaySettingsChanged(Window Window) + { + Window.Hide(); + + await Task.Delay(1000); + + SWUS.Initialize(); + + await Task.Delay(500); + + ContentRendered(Window); + + Window.Show(); + } + + public static async void DisplaySettingsChanged(Process Process, IntPtr Handle) + { + SWNM.ShowWindow(Handle, (int)SWNM.SHOWWINDOW.SW_HIDE); + + await Task.Delay(1000); + + SWUS.Initialize(); + + await Task.Delay(500); + + ApplicationRendered(Process); + + SWNM.ShowWindow(Handle, (int)SWNM.SHOWWINDOW.SW_SHOW); + } } } \ No newline at end of file