From bdac2b72dc28837d10a92cc164f83925ff5b1ed1 Mon Sep 17 00:00:00 2001 From: Taiizor <41683699+Taiizor@users.noreply.github.com> Date: Sun, 1 Dec 2024 03:21:02 +0300 Subject: [PATCH] Major Changes --- src/Live/Sucrose.Live.Aurora/App.xaml.cs | 3 ++ src/Live/Sucrose.Live.CefSharp/App.xaml.cs | 3 ++ src/Live/Sucrose.Live.MpvPlayer/App.xaml.cs | 3 ++ src/Live/Sucrose.Live.Nebula/App.xaml.cs | 3 ++ src/Live/Sucrose.Live.Vexana/App.xaml.cs | 3 ++ src/Live/Sucrose.Live.WebView/App.xaml.cs | 3 ++ src/Live/Sucrose.Live.Xavier/App.xaml.cs | 3 ++ .../Sucrose.Shared.Engine/Helper/Awakening.cs | 41 +++++++++++++++++++ .../Sucrose.Shared.Engine.projitems | 1 + 9 files changed, 63 insertions(+) create mode 100644 src/Shared/Engine/Sucrose.Shared.Engine/Helper/Awakening.cs diff --git a/src/Live/Sucrose.Live.Aurora/App.xaml.cs b/src/Live/Sucrose.Live.Aurora/App.xaml.cs index 8e485ad3e..7dc5776e4 100644 --- a/src/Live/Sucrose.Live.Aurora/App.xaml.cs +++ b/src/Live/Sucrose.Live.Aurora/App.xaml.cs @@ -14,6 +14,7 @@ using SRHR = Sucrose.Resources.Helper.Resources; using SSDEWT = Sucrose.Shared.Dependency.Enum.WallpaperType; using SSEAVA = Sucrose.Shared.Engine.Aurora.View.Application; +using SSEHA = Sucrose.Shared.Engine.Helper.Awakening; using SSEHC = Sucrose.Shared.Engine.Helper.Cycyling; using SSEHR = Sucrose.Shared.Engine.Helper.Run; using SSEMI = Sucrose.Shared.Engine.Manage.Internal; @@ -153,6 +154,8 @@ protected void Configure() { SSSHS.Apply(); + SSEHA.Start(); + SSEHC.Start(); SSEMI.Host = $"{Path.Combine(SSEMI.LibraryLocation, SSEMI.LibrarySelected)}/"; diff --git a/src/Live/Sucrose.Live.CefSharp/App.xaml.cs b/src/Live/Sucrose.Live.CefSharp/App.xaml.cs index fb778ca64..a6d605916 100644 --- a/src/Live/Sucrose.Live.CefSharp/App.xaml.cs +++ b/src/Live/Sucrose.Live.CefSharp/App.xaml.cs @@ -39,6 +39,7 @@ using SSECSVW = Sucrose.Shared.Engine.CefSharp.View.Web; using SSECSVYT = Sucrose.Shared.Engine.CefSharp.View.YouTube; using SSEELHS = Sucrose.Shared.Engine.Extension.LocalHttpServer; +using SSEHA = Sucrose.Shared.Engine.Helper.Awakening; using SSEHC = Sucrose.Shared.Engine.Helper.Cycyling; using SSEHP = Sucrose.Shared.Engine.Helper.Properties; using SSEHR = Sucrose.Shared.Engine.Helper.Run; @@ -412,6 +413,8 @@ protected void Configure() { SSSHS.Apply(); + SSEHA.Start(); + SSEHC.Start(); if (SSEMI.Info.Type is SSDEWT.Gif or SSDEWT.Video or SSDEWT.YouTube) diff --git a/src/Live/Sucrose.Live.MpvPlayer/App.xaml.cs b/src/Live/Sucrose.Live.MpvPlayer/App.xaml.cs index ad23c7bbf..b365253be 100644 --- a/src/Live/Sucrose.Live.MpvPlayer/App.xaml.cs +++ b/src/Live/Sucrose.Live.MpvPlayer/App.xaml.cs @@ -19,6 +19,7 @@ using SRHR = Sucrose.Resources.Helper.Resources; using SSDEWT = Sucrose.Shared.Dependency.Enum.WallpaperType; using SSDMMG = Sucrose.Shared.Dependency.Manage.Manager.General; +using SSEHA = Sucrose.Shared.Engine.Helper.Awakening; using SSEHC = Sucrose.Shared.Engine.Helper.Cycyling; using SSEHR = Sucrose.Shared.Engine.Helper.Run; using SSEMI = Sucrose.Shared.Engine.Manage.Internal; @@ -201,6 +202,8 @@ protected void Configure() { SSSHS.Apply(); + SSEHA.Start(); + SSEHC.Start(); SSEMPHC.Start(); diff --git a/src/Live/Sucrose.Live.Nebula/App.xaml.cs b/src/Live/Sucrose.Live.Nebula/App.xaml.cs index 39cf63578..afa4a39b7 100644 --- a/src/Live/Sucrose.Live.Nebula/App.xaml.cs +++ b/src/Live/Sucrose.Live.Nebula/App.xaml.cs @@ -13,6 +13,7 @@ using SMMRM = Sucrose.Memory.Manage.Readonly.Mutex; using SRHR = Sucrose.Resources.Helper.Resources; using SSDEWT = Sucrose.Shared.Dependency.Enum.WallpaperType; +using SSEHA = Sucrose.Shared.Engine.Helper.Awakening; using SSEHC = Sucrose.Shared.Engine.Helper.Cycyling; using SSEHR = Sucrose.Shared.Engine.Helper.Run; using SSEMI = Sucrose.Shared.Engine.Manage.Internal; @@ -150,6 +151,8 @@ protected void Configure() { SSSHS.Apply(); + SSEHA.Start(); + SSEHC.Start(); SSEMI.Host = $"{Path.Combine(SSEMI.LibraryLocation, SSEMI.LibrarySelected)}/"; diff --git a/src/Live/Sucrose.Live.Vexana/App.xaml.cs b/src/Live/Sucrose.Live.Vexana/App.xaml.cs index 73c74309c..7db161467 100644 --- a/src/Live/Sucrose.Live.Vexana/App.xaml.cs +++ b/src/Live/Sucrose.Live.Vexana/App.xaml.cs @@ -13,6 +13,7 @@ using SMMRM = Sucrose.Memory.Manage.Readonly.Mutex; using SRHR = Sucrose.Resources.Helper.Resources; using SSDEWT = Sucrose.Shared.Dependency.Enum.WallpaperType; +using SSEHA = Sucrose.Shared.Engine.Helper.Awakening; using SSEHC = Sucrose.Shared.Engine.Helper.Cycyling; using SSEHR = Sucrose.Shared.Engine.Helper.Run; using SSEMI = Sucrose.Shared.Engine.Manage.Internal; @@ -150,6 +151,8 @@ protected void Configure() { SSSHS.Apply(); + SSEHA.Start(); + SSEHC.Start(); SSEMI.Host = $"{Path.Combine(SSEMI.LibraryLocation, SSEMI.LibrarySelected)}/"; diff --git a/src/Live/Sucrose.Live.WebView/App.xaml.cs b/src/Live/Sucrose.Live.WebView/App.xaml.cs index e84ce2a01..a9511c089 100644 --- a/src/Live/Sucrose.Live.WebView/App.xaml.cs +++ b/src/Live/Sucrose.Live.WebView/App.xaml.cs @@ -29,6 +29,7 @@ using SSDEPT = Sucrose.Shared.Dependency.Enum.PropertiesType; using SSDEWT = Sucrose.Shared.Dependency.Enum.WallpaperType; using SSDMMG = Sucrose.Shared.Dependency.Manage.Manager.General; +using SSEHA = Sucrose.Shared.Engine.Helper.Awakening; using SSEHC = Sucrose.Shared.Engine.Helper.Cycyling; using SSEHP = Sucrose.Shared.Engine.Helper.Properties; using SSEHR = Sucrose.Shared.Engine.Helper.Run; @@ -344,6 +345,8 @@ protected void Configure() { SSSHS.Apply(); + SSEHA.Start(); + SSEHC.Start(); if (SSEMI.Info.Type is SSDEWT.Gif or SSDEWT.Video or SSDEWT.YouTube) diff --git a/src/Live/Sucrose.Live.Xavier/App.xaml.cs b/src/Live/Sucrose.Live.Xavier/App.xaml.cs index ddbab12b6..e1016c69a 100644 --- a/src/Live/Sucrose.Live.Xavier/App.xaml.cs +++ b/src/Live/Sucrose.Live.Xavier/App.xaml.cs @@ -13,6 +13,7 @@ using SMMRM = Sucrose.Memory.Manage.Readonly.Mutex; using SRHR = Sucrose.Resources.Helper.Resources; using SSDEWT = Sucrose.Shared.Dependency.Enum.WallpaperType; +using SSEHA = Sucrose.Shared.Engine.Helper.Awakening; using SSEHC = Sucrose.Shared.Engine.Helper.Cycyling; using SSEHR = Sucrose.Shared.Engine.Helper.Run; using SSEMI = Sucrose.Shared.Engine.Manage.Internal; @@ -150,6 +151,8 @@ protected void Configure() { SSSHS.Apply(); + SSEHA.Start(); + SSEHC.Start(); SSEMI.Host = $"{Path.Combine(SSEMI.LibraryLocation, SSEMI.LibrarySelected)}/"; diff --git a/src/Shared/Engine/Sucrose.Shared.Engine/Helper/Awakening.cs b/src/Shared/Engine/Sucrose.Shared.Engine/Helper/Awakening.cs new file mode 100644 index 000000000..b0df445e5 --- /dev/null +++ b/src/Shared/Engine/Sucrose.Shared.Engine/Helper/Awakening.cs @@ -0,0 +1,41 @@ +using ESFLAGS = Skylark.Wing.Native.Methods.ES_FLAGS; +using SMME = Sucrose.Manager.Manage.Engine; +using SSWEW = Sucrose.Shared.Watchdog.Extension.Watch; +using SWNM = Skylark.Wing.Native.Methods; +using Timer = System.Timers.Timer; + +namespace Sucrose.Shared.Engine.Helper +{ + internal static class Awakening + { + public static void Start() + { + int Second = 30; + + Timer Awaker = new(Second * 1000); + + Awaker.Elapsed += async (s, e) => + { + try + { + if (SMME.StayAwake) + { + SWNM.SetThreadExecutionState(ESFLAGS.ES_CONTINUOUS | ESFLAGS.ES_SYSTEM_REQUIRED | ESFLAGS.ES_DISPLAY_REQUIRED); + } + else + { + SWNM.SetThreadExecutionState(ESFLAGS.ES_CONTINUOUS); + } + } + catch (Exception Exception) + { + await SSWEW.Watch_CatchException(Exception); + } + }; + + Awaker.AutoReset = true; + + Awaker.Start(); + } + } +} \ No newline at end of file diff --git a/src/Shared/Engine/Sucrose.Shared.Engine/Sucrose.Shared.Engine.projitems b/src/Shared/Engine/Sucrose.Shared.Engine/Sucrose.Shared.Engine.projitems index 02a7be962..9c54e863d 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine/Sucrose.Shared.Engine.projitems +++ b/src/Shared/Engine/Sucrose.Shared.Engine/Sucrose.Shared.Engine.projitems @@ -11,6 +11,7 @@ +