diff --git a/src/Library/Sucrose.Manager/Manage/Manager.cs b/src/Library/Sucrose.Manager/Manage/Manager.cs index 5c7950aa1..982adaf2c 100644 --- a/src/Library/Sucrose.Manager/Manage/Manager.cs +++ b/src/Library/Sucrose.Manager/Manage/Manager.cs @@ -69,6 +69,10 @@ public static class Manager public static SEST DownloadType => SMMI.BackgroundogSettingManager.GetSetting(SMC.DownloadType, SEST.Megabyte); + public static bool PausePerformance => SMMI.BackgroundogSettingManager.GetSetting(SMC.PausePerformance, false); + + public static bool ClosePerformance => SMMI.BackgroundogSettingManager.GetSetting(SMC.ClosePerformance, false); + public static int Startup => SHS.Clamp(SMMI.GeneralSettingManager.GetSettingStable(SMC.Startup, 0), 0, 10); public static SEST UploadType => SMMI.BackgroundogSettingManager.GetSetting(SMC.UploadType, SEST.Kilobyte); diff --git a/src/Library/Sucrose.Memory/Constant.cs b/src/Library/Sucrose.Memory/Constant.cs index 00d941358..b140699dc 100644 --- a/src/Library/Sucrose.Memory/Constant.cs +++ b/src/Library/Sucrose.Memory/Constant.cs @@ -124,6 +124,10 @@ public static class Constant public const string BackgroundImage = "BackgroundImage"; + public const string ClosePerformance = "ClosePerformance"; + + public const string PausePerformance = "PausePerformance"; + public const string AdvertisingState = "AdvertisingState"; public const string AdvertisingDelay = "AdvertisingDelay"; diff --git a/src/Portal/Sucrose.Portal/ViewModels/Pages/Setting/GeneralSettingViewModel.cs b/src/Portal/Sucrose.Portal/ViewModels/Pages/Setting/GeneralSettingViewModel.cs index c0898e78a..d47eb2b73 100644 --- a/src/Portal/Sucrose.Portal/ViewModels/Pages/Setting/GeneralSettingViewModel.cs +++ b/src/Portal/Sucrose.Portal/ViewModels/Pages/Setting/GeneralSettingViewModel.cs @@ -465,7 +465,7 @@ private void StartupSelected(int Index) SSSHP.Run(SSSMI.Commandog, $"{SMR.StartCommand}{SSDECT.Startup}{SMR.ValueSeparator}{SMR.AppName}{SMR.ValueSeparator}{SSSMI.Launcher}{SMR.ValueSeparator}{true}"); break; case 2: - SSSHP.Runas(SSSMI.Commandog, $"{SMR.StartCommand}{SSDECT.StartupP}{SMR.ValueSeparator}{SMR.AppName}{SMR.ValueSeparator}{SSSMI.Launcher}{SMR.ValueSeparator}{true}"); + SSSHP.Runas(SSSMI.Commandog, $"{SMR.StartCommand}{SSDECT.StartupP}{SMR.ValueSeparator}{SSSMI.Launcher}{SMR.ValueSeparator}{true}"); break; case 3: SSSHP.Run(SSSMI.Commandog, $"{SMR.StartCommand}{SSDECT.Scheduler}{SMR.ValueSeparator}{SSDESCT.Create}{SMR.ValueSeparator}{SSSMI.Launcher}"); diff --git a/src/Portal/Sucrose.Portal/Views/Controls/LibraryCard.xaml.cs b/src/Portal/Sucrose.Portal/Views/Controls/LibraryCard.xaml.cs index c96882133..1a6a029b8 100644 --- a/src/Portal/Sucrose.Portal/Views/Controls/LibraryCard.xaml.cs +++ b/src/Portal/Sucrose.Portal/Views/Controls/LibraryCard.xaml.cs @@ -16,6 +16,7 @@ using SSRER = Sucrose.Shared.Resources.Extension.Resources; using SSSHL = Sucrose.Shared.Space.Helper.Live; using SSSHP = Sucrose.Shared.Space.Helper.Processor; +using SSSMI = Sucrose.Shared.Space.Manage.Internal; using SSTHI = Sucrose.Shared.Theme.Helper.Info; namespace Sucrose.Portal.Views.Controls @@ -40,18 +41,21 @@ internal LibraryCard(string Theme, SSTHI Info) private void Use() { - if (SMMM.LibrarySelected != Path.GetFileName(Theme) || !SSSHL.Run()) + if ((!SMMM.ClosePerformance && !SMMM.PausePerformance) || !SSSHP.Work(SSSMI.Backgroundog)) { - SMMI.LibrarySettingManager.SetSetting(SMC.LibrarySelected, Path.GetFileName(Theme)); - - if (SSSHL.Run()) + if (SMMM.LibrarySelected != Path.GetFileName(Theme) || !SSSHL.Run()) { - SSLHK.Stop(); - } + SMMI.LibrarySettingManager.SetSetting(SMC.LibrarySelected, Path.GetFileName(Theme)); - SSLHR.Start(); + if (SSSHL.Run()) + { + SSLHK.Stop(); + } - Cursor = Cursors.Arrow; + SSLHR.Start(); + + Cursor = Cursors.Arrow; + } } } @@ -128,23 +132,31 @@ private void ThemeMore_Click(object sender, RoutedEventArgs e) private void ContextMenu_Opened(object sender, RoutedEventArgs e) { - if (SMMM.LibrarySelected == Path.GetFileName(Theme) && SSSHL.Run()) - { - MenuUse.IsEnabled = false; - MenuDelete.IsEnabled = false; - } - else + if ((!SMMM.ClosePerformance && !SMMM.PausePerformance) || !SSSHP.Work(SSSMI.Backgroundog)) { - if (Info.AppVersion.CompareTo(SHV.Entry()) <= 0) + if (SMMM.LibrarySelected == Path.GetFileName(Theme) && SSSHL.Run()) { - MenuUse.IsEnabled = true; + MenuUse.IsEnabled = false; + MenuDelete.IsEnabled = false; } else { - MenuUse.IsEnabled = false; + if (Info.AppVersion.CompareTo(SHV.Entry()) <= 0) + { + MenuUse.IsEnabled = true; + } + else + { + MenuUse.IsEnabled = false; + } + + MenuDelete.IsEnabled = true; } - - MenuDelete.IsEnabled = true; + } + else + { + MenuUse.IsEnabled = false; + MenuDelete.IsEnabled = false; } } diff --git a/src/Portal/Sucrose.Portal/Views/Controls/StoreCard.xaml.cs b/src/Portal/Sucrose.Portal/Views/Controls/StoreCard.xaml.cs index 36a0143b7..4cf084b7b 100644 --- a/src/Portal/Sucrose.Portal/Views/Controls/StoreCard.xaml.cs +++ b/src/Portal/Sucrose.Portal/Views/Controls/StoreCard.xaml.cs @@ -23,6 +23,7 @@ using SSSHN = Sucrose.Shared.Space.Helper.Network; using SSSHP = Sucrose.Shared.Space.Helper.Processor; using SSSIW = Sucrose.Shared.Store.Interface.Wallpaper; +using SSSMI = Sucrose.Shared.Space.Manage.Internal; using SSSPMI = Sucrose.Shared.Space.Manage.Internal; using SSSTMI = Sucrose.Shared.Store.Manage.Internal; using SSTHI = Sucrose.Shared.Theme.Helper.Info; @@ -159,16 +160,19 @@ private async void DownloadTheme() { SSSHC.Folder(TemporaryPath, LibraryPath); - if (SMMM.Start) + if ((!SMMM.ClosePerformance && !SMMM.PausePerformance) || !SSSHP.Work(SSSMI.Backgroundog)) { - SMMI.LibrarySettingManager.SetSetting(SMC.LibrarySelected, Path.GetFileName(Keys)); - - if (SSSHL.Run()) + if (SMMM.Start) { - SSLHK.Stop(); - } + SMMI.LibrarySettingManager.SetSetting(SMC.LibrarySelected, Path.GetFileName(Keys)); + + if (SSSHL.Run()) + { + SSLHK.Stop(); + } - SSLHR.Start(); + SSLHR.Start(); + } } } } diff --git a/src/Project/Sucrose.Backgroundog/Helper/Attempt.cs b/src/Project/Sucrose.Backgroundog/Helper/Attempt.cs index 4c3df6c92..ab0f2ba83 100644 --- a/src/Project/Sucrose.Backgroundog/Helper/Attempt.cs +++ b/src/Project/Sucrose.Backgroundog/Helper/Attempt.cs @@ -1,4 +1,6 @@ using SBMI = Sucrose.Backgroundog.Manage.Internal; +using SMC = Sucrose.Memory.Constant; +using SMMI = Sucrose.Manager.Manage.Internal; using SSSHL = Sucrose.Shared.Space.Helper.Live; namespace Sucrose.Backgroundog.Helper @@ -22,6 +24,8 @@ public static async Task Start() SBMI.Exit = false; SBMI.Initialize.Stop(); + SMMI.BackgroundogSettingManager.SetSetting(SMC.ClosePerformance, false); + SMMI.BackgroundogSettingManager.SetSetting(SMC.PausePerformance, false); await Task.CompletedTask; } diff --git a/src/Project/Sucrose.Backgroundog/Helper/Condition.cs b/src/Project/Sucrose.Backgroundog/Helper/Condition.cs index edcde3ec5..d94737386 100644 --- a/src/Project/Sucrose.Backgroundog/Helper/Condition.cs +++ b/src/Project/Sucrose.Backgroundog/Helper/Condition.cs @@ -3,6 +3,8 @@ using System.Diagnostics; using SBMI = Sucrose.Backgroundog.Manage.Internal; using SBMM = Sucrose.Backgroundog.Manage.Manager; +using SMC = Sucrose.Memory.Constant; +using SMMI = Sucrose.Manager.Manage.Internal; using SMMM = Sucrose.Manager.Manage.Manager; using SMR = Sucrose.Memory.Readonly; using SSDECPT = Sucrose.Shared.Dependency.Enum.CategoryPerformanceType; @@ -85,10 +87,12 @@ private static void Lifecycle() { if (SBMI.Performance == SSDEPT.Close) { + SMMI.BackgroundogSettingManager.SetSetting(SMC.ClosePerformance, false); SSLHR.Start(); } else { + SMMI.BackgroundogSettingManager.SetSetting(SMC.PausePerformance, false); SBMI.Live = SSSHL.Get(); if (SBMI.Live != null && !SBMI.Live.HasExited) diff --git a/src/Project/Sucrose.Backgroundog/Helper/Initialize.cs b/src/Project/Sucrose.Backgroundog/Helper/Initialize.cs index 7f4bb65ee..615094482 100644 --- a/src/Project/Sucrose.Backgroundog/Helper/Initialize.cs +++ b/src/Project/Sucrose.Backgroundog/Helper/Initialize.cs @@ -4,6 +4,8 @@ using SBHS = Sucrose.Backgroundog.Helper.Specification; using SBMI = Sucrose.Backgroundog.Manage.Internal; using SSSHL = Sucrose.Shared.Space.Helper.Live; +using SMC = Sucrose.Memory.Constant; +using SMMI = Sucrose.Manager.Manage.Internal; namespace Sucrose.Backgroundog.Helper { @@ -14,6 +16,9 @@ public void Start() SBMI.Computer.Open(); TimerCallback Callback = InitializeTimer_Callback; SBMI.InitializeTimer = new(Callback, null, 0, SBMI.InitializeTime); + + SMMI.BackgroundogSettingManager.SetSetting(SMC.ClosePerformance, false); + SMMI.BackgroundogSettingManager.SetSetting(SMC.PausePerformance, false); } public void Stop() diff --git a/src/Project/Sucrose.Backgroundog/Helper/Performance.cs b/src/Project/Sucrose.Backgroundog/Helper/Performance.cs index 251ea2bd9..2a5dab0ed 100644 --- a/src/Project/Sucrose.Backgroundog/Helper/Performance.cs +++ b/src/Project/Sucrose.Backgroundog/Helper/Performance.cs @@ -3,6 +3,8 @@ using System.Diagnostics; using SBMI = Sucrose.Backgroundog.Manage.Internal; using SBMM = Sucrose.Backgroundog.Manage.Manager; +using SMC = Sucrose.Memory.Constant; +using SMMI = Sucrose.Manager.Manage.Internal; using SMMM = Sucrose.Manager.Manage.Manager; using SMR = Sucrose.Memory.Readonly; using SSDECPT = Sucrose.Shared.Dependency.Enum.CategoryPerformanceType; @@ -75,10 +77,12 @@ private static void Lifecycle() { if (SBMI.Performance == SSDEPT.Close) { + SMMI.BackgroundogSettingManager.SetSetting(SMC.ClosePerformance, true); SSLHK.Stop(); } else { + SMMI.BackgroundogSettingManager.SetSetting(SMC.PausePerformance, true); SBMI.Live = SSSHL.Get(); if (SBMI.Live != null && !SBMI.Live.HasExited) diff --git a/src/Project/Sucrose.Commandog/Helper/Arguments.cs b/src/Project/Sucrose.Commandog/Helper/Arguments.cs index e33b6132f..b90a7641d 100644 --- a/src/Project/Sucrose.Commandog/Helper/Arguments.cs +++ b/src/Project/Sucrose.Commandog/Helper/Arguments.cs @@ -21,139 +21,136 @@ public static async Task Parse(string[] Arguments) { if (Arguments.Any()) { - for (int Count = 0; Count < Arguments.Length; Count++) - { - string Argument = Arguments[Count]; + string Combined = string.Join(" ", Arguments); - if (Argument.StartsWith(SMR.StartCommand) && Argument.Contains(SMR.ValueSeparatorChar)) - { + if (Combined.StartsWith(SMR.StartCommand) && Combined.Contains(SMR.ValueSeparatorChar)) + { #if NET6_0_OR_GREATER - string[] ArgumentParts = Argument[1..].Split(SMR.ValueSeparatorChar); + string[] ArgumentParts = Combined[1..].Split(SMR.ValueSeparatorChar); #else - string[] ArgumentParts = Argument.Substring(1).Split(SMR.ValueSeparatorChar); + string[] ArgumentParts = Combined.Substring(1).Split(SMR.ValueSeparatorChar); #endif - if (ArgumentParts.Length >= 2) - { - string Name = ArgumentParts[0]; + if (ArgumentParts.Length >= 2) + { + string Name = ArgumentParts[0]; #if NET6_0_OR_GREATER - List Values = new(ArgumentParts[1..]); + List Values = new(ArgumentParts[1..]); #else - List Values = new(); + List Values = new(); - for (int Index = 1; Index < ArgumentParts.Length; Index++) - { - Values.Add(ArgumentParts[Index]); - } + for (int Index = 1; Index < ArgumentParts.Length; Index++) + { + Values.Add(ArgumentParts[Index]); + } #endif - if (Enum.TryParse(Name, true, out SSDECT Command)) + if (Enum.TryParse(Name, true, out SSDECT Command)) + { + switch (Command) { - switch (Command) - { - case SSDECT.Log: - SSSHP.Run(SCHP.ArgumentValue(Values[0])); - break; - case SSDECT.Kill: - SSSHP.Kill(SCHP.ArgumentValue(Values[0])); - break; - case SSDECT.Live: - SSSHP.Run(SCHP.ArgumentValue(Values[0])); - break; - case SSDECT.Test: - Console.WriteLine("Test Values:"); + case SSDECT.Log: + SSSHP.Run(SCHP.ArgumentValue(Values[0])); + break; + case SSDECT.Kill: + SSSHP.Kill(SCHP.ArgumentValue(Values[0])); + break; + case SSDECT.Live: + SSSHP.Run(SCHP.ArgumentValue(Values[0])); + break; + case SSDECT.Test: + Console.WriteLine("Test Values:"); - foreach (string Value in Values) - { - Type Types = SCHM.GetType(Value); + foreach (string Value in Values) + { + Type Types = SCHM.GetType(Value); - if (Types == typeof(int)) - { - Console.WriteLine(SCHP.ArgumentValue(Value)); - } - else if (Types == typeof(bool)) - { - Console.WriteLine(SCHP.ArgumentValue(Value)); - } - else if (Types == typeof(string)) - { - Console.WriteLine(SCHP.ArgumentValue(Value)); - } - } - break; - case SSDECT.Temp: - await SSSHT.Delete(SCHP.ArgumentValue(Values[0]), SCHP.ArgumentValue(Values[1])); - break; - case SSDECT.Wiki: - SSSHP.Run(SCHP.ArgumentValue(Values[0])); - break; - case SSDECT.Reset: - await SSSHR.Start(SCHP.ArgumentValue(Values[0])); - break; - case SSDECT.Bundle: - SSSHP.Run(SCHP.ArgumentValue(Values[0])); - break; - case SSDECT.Update: - SSSHP.Run(SCHP.ArgumentValue(Values[0])); - break; - case SSDECT.Import: - await SSSHI.Start(SCHP.ArgumentValue(Values[0]), SCHP.ArgumentValue(Values[1])); - break; - case SSDECT.Export: - await SSSHE.Start(SCHP.ArgumentValue(Values[0]), SCHP.ArgumentValue(Values[1])); - break; - case SSDECT.Report: - SSSHP.Run(SCHP.ArgumentValue(Values[0])); - break; - case SSDECT.Publish: - SSSHP.Run(SCHP.ArgumentValue(Values[0])); - break; - case SSDECT.Startup: - SWHWS.SetStartup(SCHP.ArgumentValue(Values[0]), SCHP.ArgumentValue(Values[1]), SCHP.ArgumentValue(Values[2])); - break; - case SSDECT.StartupM: - SWHWSM.SetStartup(SCHP.ArgumentValue(Values[0]), SCHP.ArgumentValue(Values[1]), SCHP.ArgumentValue(Values[2])); - break; - case SSDECT.StartupP: - SWHWSP.SetStartup(SCHP.ArgumentValue(Values[0]), SCHP.ArgumentValue(Values[1])); - break; - case SSDECT.Scheduler: - switch (SCHP.ArgumentValue(Values[0])) + if (Types == typeof(int)) { - case SSDESCT.Create: - SCHS.CreateTask(SCHP.ArgumentValue(Values[1])); - break; - case SSDESCT.Enable: - SCHS.EnableTask(); - break; - case SSDESCT.Disable: - SCHS.DisableTask(); - break; - case SSDESCT.Delete: - SCHS.DeleteTask(); - break; - default: - break; + Console.WriteLine(SCHP.ArgumentValue(Value)); } - break; - case SSDECT.Interface: - if (Values.Count() > 1) + else if (Types == typeof(bool)) { - SSSHP.Run(SCHP.ArgumentValue(Values[0]), SCHP.ArgumentValue(Values[1])); + Console.WriteLine(SCHP.ArgumentValue(Value)); } - else + else if (Types == typeof(string)) { - SSSHP.Run(SCHP.ArgumentValue(Values[0])); + Console.WriteLine(SCHP.ArgumentValue(Value)); } - break; - case SSDECT.Backgroundog: - SSSHP.Run(SCHP.ArgumentValue(Values[0]), string.Empty); - break; - default: - break; - } + } + break; + case SSDECT.Temp: + await SSSHT.Delete(SCHP.ArgumentValue(Values[0]), SCHP.ArgumentValue(Values[1])); + break; + case SSDECT.Wiki: + SSSHP.Run(SCHP.ArgumentValue(Values[0])); + break; + case SSDECT.Reset: + await SSSHR.Start(SCHP.ArgumentValue(Values[0])); + break; + case SSDECT.Bundle: + SSSHP.Run(SCHP.ArgumentValue(Values[0])); + break; + case SSDECT.Update: + SSSHP.Run(SCHP.ArgumentValue(Values[0])); + break; + case SSDECT.Import: + await SSSHI.Start(SCHP.ArgumentValue(Values[0]), SCHP.ArgumentValue(Values[1])); + break; + case SSDECT.Export: + await SSSHE.Start(SCHP.ArgumentValue(Values[0]), SCHP.ArgumentValue(Values[1])); + break; + case SSDECT.Report: + SSSHP.Run(SCHP.ArgumentValue(Values[0])); + break; + case SSDECT.Publish: + SSSHP.Run(SCHP.ArgumentValue(Values[0])); + break; + case SSDECT.Startup: + SWHWS.SetStartup(SCHP.ArgumentValue(Values[0]), SCHP.ArgumentValue(Values[1]), SCHP.ArgumentValue(Values[2])); + break; + case SSDECT.StartupM: + SWHWSM.SetStartup(SCHP.ArgumentValue(Values[0]), SCHP.ArgumentValue(Values[1]), SCHP.ArgumentValue(Values[2])); + break; + case SSDECT.StartupP: + SWHWSP.SetStartup(SCHP.ArgumentValue(Values[0]), SCHP.ArgumentValue(Values[1])); + break; + case SSDECT.Scheduler: + switch (SCHP.ArgumentValue(Values[0])) + { + case SSDESCT.Create: + SCHS.CreateTask(SCHP.ArgumentValue(Values[1])); + break; + case SSDESCT.Enable: + SCHS.EnableTask(); + break; + case SSDESCT.Disable: + SCHS.DisableTask(); + break; + case SSDESCT.Delete: + SCHS.DeleteTask(); + break; + default: + break; + } + break; + case SSDECT.Interface: + if (Values.Count() > 1) + { + SSSHP.Run(SCHP.ArgumentValue(Values[0]), SCHP.ArgumentValue(Values[1])); + } + else + { + SSSHP.Run(SCHP.ArgumentValue(Values[0])); + } + break; + case SSDECT.Backgroundog: + SSSHP.Run(SCHP.ArgumentValue(Values[0]), string.Empty); + break; + default: + break; } } } diff --git a/src/Shared/Sucrose.Shared.Launcher/Manager/TrayIconManager.cs b/src/Shared/Sucrose.Shared.Launcher/Manager/TrayIconManager.cs index e0e635987..3be1c1091 100644 --- a/src/Shared/Sucrose.Shared.Launcher/Manager/TrayIconManager.cs +++ b/src/Shared/Sucrose.Shared.Launcher/Manager/TrayIconManager.cs @@ -20,6 +20,8 @@ using SSRHR = Sucrose.Shared.Resources.Helper.Resources; using SSSHA = Sucrose.Shared.Space.Helper.Assets; using SSSHL = Sucrose.Shared.Space.Helper.Live; +using SSSHP = Sucrose.Shared.Space.Helper.Processor; +using SSSMI = Sucrose.Shared.Space.Manage.Internal; using SSTHI = Sucrose.Shared.Theme.Helper.Info; namespace Sucrose.Shared.Launcher.Manager @@ -70,7 +72,7 @@ public void Initialize() SSLSSS Separator1 = new(SSLMM.Theme); - if (SSSHL.Run()) + if (SSSHL.Run() && (!SMMM.PausePerformance || !SSSHP.Work(SSSMI.Backgroundog))) { ContextMenu.Items.Add(Separator1.Strip); @@ -86,7 +88,7 @@ public void Initialize() ContextMenu.Items.Add(SSRER.GetValue("Launcher", "WallCustomizeText"), null, null); } } - else if (SMMI.LibrarySettingManager.CheckFile()) + else if (SMMI.LibrarySettingManager.CheckFile() && ((!SMMM.ClosePerformance && !SMMM.PausePerformance) || !SSSHP.Work(SSSMI.Backgroundog))) { string InfoPath = Path.Combine(SMMM.LibraryLocation, SMMM.LibrarySelected, SMR.SucroseInfo); diff --git a/src/Shared/Sucrose.Shared.Live/Helper/Run.cs b/src/Shared/Sucrose.Shared.Live/Helper/Run.cs index 0b1a337b7..86199219a 100644 --- a/src/Shared/Sucrose.Shared.Live/Helper/Run.cs +++ b/src/Shared/Sucrose.Shared.Live/Helper/Run.cs @@ -15,41 +15,44 @@ internal static class Run { public static void Start() { - string InfoPath = Path.Combine(SMMM.LibraryLocation, SMMM.LibrarySelected, SMR.SucroseInfo); - - if (File.Exists(InfoPath)) + if ((!SMMM.ClosePerformance && !SMMM.PausePerformance) || !SSSHP.Work(SSSMI.Backgroundog)) { - SSTHI Info = SSTHI.ReadJson(InfoPath); + string InfoPath = Path.Combine(SMMM.LibraryLocation, SMMM.LibrarySelected, SMR.SucroseInfo); - if (Info.AppVersion.CompareTo(SHV.Entry()) <= 0) + if (File.Exists(InfoPath)) { - if (SMMM.PerformanceCounter) - { - SSSHP.Run(SSSMI.Commandog, $"{SMR.StartCommand}{SSDECT.Backgroundog}{SMR.ValueSeparator}{SSSMI.Backgroundog}"); - } + SSTHI Info = SSTHI.ReadJson(InfoPath); - switch (Info.Type) + if (Info.AppVersion.CompareTo(SHV.Entry()) <= 0) { - case SSDEWT.Web: - SSSHP.Run(SSSMI.Commandog, $"{SMR.StartCommand}{SSDECT.Live}{SMR.ValueSeparator}{SSSMI.EngineLive[SSLMM.WApp]}"); - break; - case SSDEWT.Url: - SSSHP.Run(SSSMI.Commandog, $"{SMR.StartCommand}{SSDECT.Live}{SMR.ValueSeparator}{SSSMI.EngineLive[SSLMM.UApp]}"); - break; - case SSDEWT.Gif: - SSSHP.Run(SSSMI.Commandog, $"{SMR.StartCommand}{SSDECT.Live}{SMR.ValueSeparator}{SSSMI.EngineLive[SSLMM.GApp]}"); - break; - case SSDEWT.Video: - SSSHP.Run(SSSMI.Commandog, $"{SMR.StartCommand}{SSDECT.Live}{SMR.ValueSeparator}{SSSMI.EngineLive[SSLMM.VApp]}"); - break; - case SSDEWT.YouTube: - SSSHP.Run(SSSMI.Commandog, $"{SMR.StartCommand}{SSDECT.Live}{SMR.ValueSeparator}{SSSMI.EngineLive[SSLMM.YApp]}"); - break; - case SSDEWT.Application: - SSSHP.Run(SSSMI.Commandog, $"{SMR.StartCommand}{SSDECT.Live}{SMR.ValueSeparator}{SSSMI.EngineLive[SSLMM.AApp]}"); - break; - default: - break; + if (SMMM.PerformanceCounter) + { + SSSHP.Run(SSSMI.Commandog, $"{SMR.StartCommand}{SSDECT.Backgroundog}{SMR.ValueSeparator}{SSSMI.Backgroundog}"); + } + + switch (Info.Type) + { + case SSDEWT.Web: + SSSHP.Run(SSSMI.Commandog, $"{SMR.StartCommand}{SSDECT.Live}{SMR.ValueSeparator}{SSSMI.EngineLive[SSLMM.WApp]}"); + break; + case SSDEWT.Url: + SSSHP.Run(SSSMI.Commandog, $"{SMR.StartCommand}{SSDECT.Live}{SMR.ValueSeparator}{SSSMI.EngineLive[SSLMM.UApp]}"); + break; + case SSDEWT.Gif: + SSSHP.Run(SSSMI.Commandog, $"{SMR.StartCommand}{SSDECT.Live}{SMR.ValueSeparator}{SSSMI.EngineLive[SSLMM.GApp]}"); + break; + case SSDEWT.Video: + SSSHP.Run(SSSMI.Commandog, $"{SMR.StartCommand}{SSDECT.Live}{SMR.ValueSeparator}{SSSMI.EngineLive[SSLMM.VApp]}"); + break; + case SSDEWT.YouTube: + SSSHP.Run(SSSMI.Commandog, $"{SMR.StartCommand}{SSDECT.Live}{SMR.ValueSeparator}{SSSMI.EngineLive[SSLMM.YApp]}"); + break; + case SSDEWT.Application: + SSSHP.Run(SSSMI.Commandog, $"{SMR.StartCommand}{SSDECT.Live}{SMR.ValueSeparator}{SSSMI.EngineLive[SSLMM.AApp]}"); + break; + default: + break; + } } } } diff --git a/src/Shared/Sucrose.Shared.Space/Helper/Export.cs b/src/Shared/Sucrose.Shared.Space/Helper/Export.cs index 726c946fa..6eebf8385 100644 --- a/src/Shared/Sucrose.Shared.Space/Helper/Export.cs +++ b/src/Shared/Sucrose.Shared.Space/Helper/Export.cs @@ -17,11 +17,23 @@ public static async Task Start(string Destination, string Application) SSSHP.Kill(SMR.Launcher); SSSHP.Kill(SMR.Backgroundog); - await Task.Delay(TimeSpan.FromSeconds(1)); + await Task.Delay(TimeSpan.FromSeconds(3)); + + if (!Directory.Exists(Destination)) + { + Directory.CreateDirectory(Destination); + } - foreach (string Setting in Settings(Path.Combine(SMR.AppDataPath, SMR.AppName, SMR.SettingFolder))) + if (Directory.Exists(Path.Combine(SMR.AppDataPath, SMR.AppName, SMR.SettingFolder))) + { + foreach (string Setting in Settings(Path.Combine(SMR.AppDataPath, SMR.AppName, SMR.SettingFolder))) + { + File.Copy(Setting, Path.Combine(Destination, Path.GetFileName(Setting)), true); + } + } + else { - File.Copy(Setting, Path.Combine(Destination, Path.GetFileName(Setting)), true); + Directory.CreateDirectory(Path.Combine(SMR.AppDataPath, SMR.AppName, SMR.SettingFolder)); } await Task.Delay(TimeSpan.FromSeconds(1)); @@ -32,11 +44,11 @@ public static async Task Start(string Destination, string Application) await Task.CompletedTask; } - public static string[] Settings(string Path) + public static string[] Settings(string Destination) { try { - return Directory.GetFiles(Path, "*.json", SearchOption.TopDirectoryOnly); + return Directory.GetFiles(Destination, "*.json", SearchOption.TopDirectoryOnly); } catch { diff --git a/src/Shared/Sucrose.Shared.Space/Helper/Import.cs b/src/Shared/Sucrose.Shared.Space/Helper/Import.cs index ddee4a6b4..0eea187c6 100644 --- a/src/Shared/Sucrose.Shared.Space/Helper/Import.cs +++ b/src/Shared/Sucrose.Shared.Space/Helper/Import.cs @@ -17,7 +17,17 @@ public static async Task Start(string Destination, string Application) SSSHP.Kill(SMR.Launcher); SSSHP.Kill(SMR.Backgroundog); - await Task.Delay(TimeSpan.FromSeconds(1)); + await Task.Delay(TimeSpan.FromSeconds(3)); + + if (!Directory.Exists(Destination)) + { + Directory.CreateDirectory(Destination); + } + + if (!Directory.Exists(Path.Combine(SMR.AppDataPath, SMR.AppName, SMR.SettingFolder))) + { + Directory.CreateDirectory(Path.Combine(SMR.AppDataPath, SMR.AppName, SMR.SettingFolder)); + } foreach (string Setting in Settings(Destination)) { @@ -32,11 +42,11 @@ public static async Task Start(string Destination, string Application) await Task.CompletedTask; } - public static string[] Settings(string Path) + public static string[] Settings(string Destination) { try { - return Directory.GetFiles(Path, "*.json", SearchOption.TopDirectoryOnly); + return Directory.GetFiles(Destination, "*.json", SearchOption.TopDirectoryOnly); } catch { diff --git a/src/Shared/Sucrose.Shared.Space/Helper/Processor.cs b/src/Shared/Sucrose.Shared.Space/Helper/Processor.cs index b5ccec2ee..7c21d7d07 100644 --- a/src/Shared/Sucrose.Shared.Space/Helper/Processor.cs +++ b/src/Shared/Sucrose.Shared.Space/Helper/Processor.cs @@ -58,7 +58,7 @@ public static void Runas(string Application, string Arguments, ProcessWindowStyl public static void Run(string Application, string Arguments, ProcessWindowStyle Style, bool Window) { - ProcessStartInfo ProcessInfo = new(Application, Arguments) + ProcessStartInfo ProcessInfo = new(Application, Parse(Arguments)) { CreateNoWindow = Window, UseShellExecute = true, @@ -75,7 +75,7 @@ public static void Run(string Application, string Arguments, ProcessWindowStyle public static void Runas(string Application, string Arguments, ProcessWindowStyle Style, bool Window) { - ProcessStartInfo ProcessInfo = new(Application, Arguments) + ProcessStartInfo ProcessInfo = new(Application, Parse(Arguments)) { CreateNoWindow = Window, UseShellExecute = true, @@ -157,5 +157,20 @@ public static bool Kill(params string[] Applications) { return Applications.Any(Kill); } + + private static string Parse(string Arguments) + { + if (!Arguments.StartsWith("\"")) + { + Arguments = $"\"{Arguments}"; + } + + if (!Arguments.EndsWith("\"")) + { + Arguments = $"{Arguments}\""; + } + + return Arguments; + } } } \ No newline at end of file diff --git a/src/Shared/Sucrose.Shared.Space/Helper/Reset.cs b/src/Shared/Sucrose.Shared.Space/Helper/Reset.cs index c8bd8215d..0962a12f0 100644 --- a/src/Shared/Sucrose.Shared.Space/Helper/Reset.cs +++ b/src/Shared/Sucrose.Shared.Space/Helper/Reset.cs @@ -17,11 +17,18 @@ public static async Task Start(string Application) SSSHP.Kill(SMR.Launcher); SSSHP.Kill(SMR.Backgroundog); - await Task.Delay(TimeSpan.FromSeconds(1)); + await Task.Delay(TimeSpan.FromSeconds(3)); - foreach (string Setting in Settings(Path.Combine(SMR.AppDataPath, SMR.AppName, SMR.SettingFolder))) + if (Directory.Exists(Path.Combine(SMR.AppDataPath, SMR.AppName, SMR.SettingFolder))) + { + foreach (string Setting in Settings(Path.Combine(SMR.AppDataPath, SMR.AppName, SMR.SettingFolder))) + { + File.Delete(Setting); + } + } + else { - File.Delete(Setting); + Directory.CreateDirectory(Path.Combine(SMR.AppDataPath, SMR.AppName, SMR.SettingFolder)); } await Task.Delay(TimeSpan.FromSeconds(1)); @@ -32,11 +39,11 @@ public static async Task Start(string Application) await Task.CompletedTask; } - public static string[] Settings(string Path) + public static string[] Settings(string Destination) { try { - return Directory.GetFiles(Path, "*.json", SearchOption.TopDirectoryOnly); + return Directory.GetFiles(Destination, "*.json", SearchOption.TopDirectoryOnly); } catch { diff --git a/src/Shared/Sucrose.Shared.Space/Helper/Temporary.cs b/src/Shared/Sucrose.Shared.Space/Helper/Temporary.cs index 4dc1e03cb..b493006eb 100644 --- a/src/Shared/Sucrose.Shared.Space/Helper/Temporary.cs +++ b/src/Shared/Sucrose.Shared.Space/Helper/Temporary.cs @@ -15,7 +15,7 @@ namespace Sucrose.Shared.Space.Helper { internal static class Temporary { - public static async Task Delete(string Path, string Application) + public static async Task Delete(string Destination, string Application) { SSLHK.Stop(); SSSHP.Kill(SMR.Portal); @@ -23,9 +23,16 @@ public static async Task Delete(string Path, string Application) SSSHP.Kill(SMR.Launcher); SSSHP.Kill(SMR.Backgroundog); - await Task.Delay(TimeSpan.FromSeconds(1)); + await Task.Delay(TimeSpan.FromSeconds(3)); - Directory.Delete(Path, true); + if (Directory.Exists(Destination)) + { + Directory.Delete(Destination, true); + } + else + { + Directory.CreateDirectory(Destination); + } await Task.Delay(TimeSpan.FromSeconds(1)); @@ -35,13 +42,13 @@ public static async Task Delete(string Path, string Application) await Task.CompletedTask; } - public static async Task Size(string Path) + public static async Task Size(string Destination) { long Total = 0; - if (Directory.Exists(Path)) + if (Directory.Exists(Destination)) { - string[] Files = Directory.GetFiles(Path, "*", SearchOption.AllDirectories); + string[] Files = Directory.GetFiles(Destination, "*", SearchOption.AllDirectories); foreach (string Record in Files) { @@ -59,13 +66,13 @@ public static async Task Size(string Path) } } - public static bool Check(string Path) + public static bool Check(string Destination) { - if (Directory.Exists(Path)) + if (Directory.Exists(Destination)) { return true; } - else if (File.Exists(Path)) + else if (File.Exists(Destination)) { return true; }