diff --git a/src/Library/Sucrose.Manager/Manage/Manager.cs b/src/Library/Sucrose.Manager/Manage/Manager.cs index 626c9d1ef..4cdfddc7e 100644 --- a/src/Library/Sucrose.Manager/Manage/Manager.cs +++ b/src/Library/Sucrose.Manager/Manage/Manager.cs @@ -38,6 +38,8 @@ public static class Manager public static int TitleLength => SHS.Clamp(SMMI.PortalSettingManager.GetSettingStable(SMC.TitleLength, 25), 10, 100); + public static bool PerformanceCounter => SMMI.BackgroundogSettingManager.GetSetting(SMC.PerformanceCounter, true); + public static string LibrarySelected => SMMI.LibrarySettingManager.GetSetting(SMC.LibrarySelected, string.Empty); public static string BackgroundImage => SMMI.PortalSettingManager.GetSetting(SMC.BackgroundImage, string.Empty); diff --git a/src/Library/Sucrose.Memory/Constant.cs b/src/Library/Sucrose.Memory/Constant.cs index 8e8a7fdc5..3763fcf40 100644 --- a/src/Library/Sucrose.Memory/Constant.cs +++ b/src/Library/Sucrose.Memory/Constant.cs @@ -110,6 +110,8 @@ public static class Constant public const string DescriptionLength = "DescriptionLength"; + public const string PerformanceCounter = "PerformanceCounter"; + public const string DuplicateScreenType = "DuplicateScreenType"; } } \ No newline at end of file diff --git a/src/Portal/Sucrose.Portal/ViewModels/Pages/Setting/GeneralSettingViewModel.cs b/src/Portal/Sucrose.Portal/ViewModels/Pages/Setting/GeneralSettingViewModel.cs index 6794e08bf..d02036e65 100644 --- a/src/Portal/Sucrose.Portal/ViewModels/Pages/Setting/GeneralSettingViewModel.cs +++ b/src/Portal/Sucrose.Portal/ViewModels/Pages/Setting/GeneralSettingViewModel.cs @@ -26,6 +26,7 @@ using SSCHOS = Sucrose.Shared.Core.Helper.OperatingSystem; using SSDECT = Sucrose.Shared.Dependency.Enum.CommandsType; using SSDESCT = Sucrose.Shared.Dependency.Enum.SchedulerCommandsType; +using SSLHK = Sucrose.Shared.Live.Helper.Kill; using SSLHR = Sucrose.Shared.Live.Helper.Run; using SSRER = Sucrose.Shared.Resources.Extension.Resources; using SSRHR = Sucrose.Shared.Resources.Helper.Resources; @@ -33,7 +34,6 @@ using SSSHL = Sucrose.Shared.Space.Helper.Live; using SSSHP = Sucrose.Shared.Space.Helper.Processor; using SSSMI = Sucrose.Shared.Space.Manage.Internal; -using SWUD = Skylark.Wing.Utility.Desktop; using TextBlock = System.Windows.Controls.TextBlock; namespace Sucrose.Portal.ViewModels.Pages @@ -629,16 +629,7 @@ private async void LibraryLocationClick(Button LibraryLocation) { if (SSSHL.Run()) { - SSSHL.Kill(); - - if (!string.IsNullOrEmpty(SMMM.App)) - { - SSSHP.Kill(SMMM.App); - } - - SWUD.RefreshDesktop(); - - SMMI.AuroraSettingManager.SetSetting(SMC.App, string.Empty); + SSLHK.Stop(); await Task.Delay(500); @@ -663,16 +654,7 @@ private async void LibraryLocationClick(Button LibraryLocation) { if (SSSHL.Run()) { - SSSHL.Kill(); - - if (!string.IsNullOrEmpty(SMMM.App)) - { - SSSHP.Kill(SMMM.App); - } - - SWUD.RefreshDesktop(); - - SMMI.AuroraSettingManager.SetSetting(SMC.App, string.Empty); + SSLHK.Stop(); } SMMI.LibrarySettingManager.SetSetting(SMC.LibraryLocation, Destination); diff --git a/src/Portal/Sucrose.Portal/ViewModels/Pages/Setting/PerformanceSettingViewModel.cs b/src/Portal/Sucrose.Portal/ViewModels/Pages/Setting/PerformanceSettingViewModel.cs index 15f691080..1b06029a9 100644 --- a/src/Portal/Sucrose.Portal/ViewModels/Pages/Setting/PerformanceSettingViewModel.cs +++ b/src/Portal/Sucrose.Portal/ViewModels/Pages/Setting/PerformanceSettingViewModel.cs @@ -1,13 +1,16 @@ using CommunityToolkit.Mvvm.ComponentModel; using System.Windows; -using System.Windows.Controls; using System.Windows.Media; using Wpf.Ui.Controls; using SMC = Sucrose.Memory.Constant; using SMMI = Sucrose.Manager.Manage.Internal; using SMMM = Sucrose.Manager.Manage.Manager; +using SMR = Sucrose.Memory.Readonly; using SPVCEC = Sucrose.Portal.Views.Controls.ExpanderCard; +using SSDECT = Sucrose.Shared.Dependency.Enum.CommandsType; using SSRER = Sucrose.Shared.Resources.Extension.Resources; +using SSSHP = Sucrose.Shared.Space.Helper.Processor; +using SSSMI = Sucrose.Shared.Space.Manage.Internal; using TextBlock = System.Windows.Controls.TextBlock; namespace Sucrose.Portal.ViewModels.Pages @@ -29,11 +32,43 @@ public PerformanceSettingViewModel() private void InitializeViewModel() { - TextBlock SystemResourcesArea = new() + TextBlock AppearanceBehaviorArea = new() { Foreground = SSRER.GetResource("TextFillColorPrimaryBrush"), Margin = new Thickness(0, 0, 0, 0), FontWeight = FontWeights.Bold, + Text = "Görünüş & Davranış" + }; + + Contents.Add(AppearanceBehaviorArea); + + SPVCEC Counter = new() + { + Margin = new Thickness(0, 10, 0, 0), + Expandable = false + }; + + Counter.Title.Text = "Performans Sayaçları"; + Counter.LeftIcon.Symbol = SymbolRegular.ShiftsActivity24; + Counter.Description.Text = "Tüm performans sayaçlarının çalışıp çalışmayacağı."; + + ToggleSwitch CounterState = new() + { + IsChecked = SMMM.PerformanceCounter + }; + + CounterState.Checked += (s, e) => CounterStateChecked(true); + CounterState.Unchecked += (s, e) => CounterStateChecked(false); + + Counter.HeaderFrame = CounterState; + + Contents.Add(Counter); + + TextBlock SystemResourcesArea = new() + { + Foreground = SSRER.GetResource("TextFillColorPrimaryBrush"), + Margin = new Thickness(0, 10, 0, 0), + FontWeight = FontWeights.Bold, Text = "Sistem Kaynakları" }; @@ -52,6 +87,23 @@ public void OnNavigatedFrom() //Dispose(); } + private void CounterStateChecked(bool State) + { + SMMI.BackgroundogSettingManager.SetSetting(SMC.PerformanceCounter, State); + + if (State) + { + SSSHP.Run(SSSMI.Commandog, $"{SMR.StartCommand}{SSDECT.Backgroundog}{SMR.ValueSeparator}{SSSMI.Backgroundog}"); + } + else + { + if (SSSHP.Work(SMR.Backgroundog)) + { + SSSHP.Kill(SMR.Backgroundog); + } + } + } + public void Dispose() { Contents.Clear(); diff --git a/src/Portal/Sucrose.Portal/Views/Controls/LibraryCard.xaml.cs b/src/Portal/Sucrose.Portal/Views/Controls/LibraryCard.xaml.cs index 60f235240..c96882133 100644 --- a/src/Portal/Sucrose.Portal/Views/Controls/LibraryCard.xaml.cs +++ b/src/Portal/Sucrose.Portal/Views/Controls/LibraryCard.xaml.cs @@ -11,12 +11,12 @@ using SPMI = Sucrose.Portal.Manage.Internal; using SPVCTR = Sucrose.Portal.Views.Controls.ThemeReview; using SPVCTS = Sucrose.Portal.Views.Controls.ThemeShare; +using SSLHK = Sucrose.Shared.Live.Helper.Kill; using SSLHR = Sucrose.Shared.Live.Helper.Run; using SSRER = Sucrose.Shared.Resources.Extension.Resources; using SSSHL = Sucrose.Shared.Space.Helper.Live; using SSSHP = Sucrose.Shared.Space.Helper.Processor; using SSTHI = Sucrose.Shared.Theme.Helper.Info; -using SWUD = Skylark.Wing.Utility.Desktop; namespace Sucrose.Portal.Views.Controls { @@ -46,16 +46,7 @@ private void Use() if (SSSHL.Run()) { - SSSHL.Kill(); - - if (!string.IsNullOrEmpty(SMMM.App)) - { - SSSHP.Kill(SMMM.App); - } - - SWUD.RefreshDesktop(); - - SMMI.AuroraSettingManager.SetSetting(SMC.App, string.Empty); + SSLHK.Stop(); } SSLHR.Start(); diff --git a/src/Portal/Sucrose.Portal/Views/Controls/StoreCard.xaml.cs b/src/Portal/Sucrose.Portal/Views/Controls/StoreCard.xaml.cs index f4ec3b3d7..df98e1d3c 100644 --- a/src/Portal/Sucrose.Portal/Views/Controls/StoreCard.xaml.cs +++ b/src/Portal/Sucrose.Portal/Views/Controls/StoreCard.xaml.cs @@ -14,6 +14,7 @@ using SPEIL = Sucrose.Portal.Extension.ImageLoader; using SPMI = Sucrose.Portal.Manage.Internal; using SSDECT = Sucrose.Shared.Dependency.Enum.CommandsType; +using SSLHK = Sucrose.Shared.Live.Helper.Kill; using SSLHR = Sucrose.Shared.Live.Helper.Run; using SSRER = Sucrose.Shared.Resources.Extension.Resources; using SSSHC = Sucrose.Shared.Space.Helper.Copy; @@ -25,7 +26,6 @@ using SSSPMI = Sucrose.Shared.Space.Manage.Internal; using SSSTMI = Sucrose.Shared.Store.Manage.Internal; using SSTHI = Sucrose.Shared.Theme.Helper.Info; -using SWUD = Skylark.Wing.Utility.Desktop; namespace Sucrose.Portal.Views.Controls { @@ -154,16 +154,7 @@ private async void DownloadTheme() if (SSSHL.Run()) { - SSSHL.Kill(); - - if (!string.IsNullOrEmpty(SMMM.App)) - { - SSSHP.Kill(SMMM.App); - } - - SWUD.RefreshDesktop(); - - SMMI.AuroraSettingManager.SetSetting(SMC.App, string.Empty); + SSLHK.Stop(); } SSLHR.Start(); diff --git a/src/Project/Sucrose.Backgroundog/App.cs b/src/Project/Sucrose.Backgroundog/App.cs index 285b42a65..aa59a8e4a 100644 --- a/src/Project/Sucrose.Backgroundog/App.cs +++ b/src/Project/Sucrose.Backgroundog/App.cs @@ -1,4 +1,6 @@ using System.Globalization; +using SBHI = Sucrose.Backgroundog.Helper.Initialize; +using SBMI = Sucrose.Backgroundog.Manage.Internal; using SBMM = Sucrose.Backgroundog.Manage.Manager; using SGCB = Sucrose.Grpc.Common.Backgroundog; using SGSGSS = Sucrose.Grpc.Services.GeneralServerService; @@ -15,7 +17,7 @@ namespace Sucrose.Backgroundog { internal class App { - internal static void Main() + internal static async Task Main() { try { @@ -32,7 +34,14 @@ internal static void Main() SGSGSS.ServerInstance.Start(); - Console.ReadKey(); + SBHI.Start(); + + do + { + await Task.Delay(1000); + } while (SBMI.Exit); + + SBHI.Stop(); SGSGSS.ServerInstance.KillAsync().Wait(); //SGSGSS.ServerInstance.ShutdownAsync().Wait(); diff --git a/src/Project/Sucrose.Backgroundog/Helper/Counter.cs b/src/Project/Sucrose.Backgroundog/Helper/Counter.cs new file mode 100644 index 000000000..8adf46e7b --- /dev/null +++ b/src/Project/Sucrose.Backgroundog/Helper/Counter.cs @@ -0,0 +1,15 @@ +using SBMI = Sucrose.Backgroundog.Manage.Internal; +using SMMI = Sucrose.Manager.Manage.Internal; +using SMMM = Sucrose.Manager.Manage.Manager; +using SSSHL = Sucrose.Shared.Space.Helper.Live; + +namespace Sucrose.Backgroundog.Helper +{ + internal static class Counter + { + public static void Start() + { + + } + } +} diff --git a/src/Project/Sucrose.Backgroundog/Helper/Initialize.cs b/src/Project/Sucrose.Backgroundog/Helper/Initialize.cs new file mode 100644 index 000000000..47743108d --- /dev/null +++ b/src/Project/Sucrose.Backgroundog/Helper/Initialize.cs @@ -0,0 +1,41 @@ +using SBMI = Sucrose.Backgroundog.Manage.Internal; +using SMMI = Sucrose.Manager.Manage.Internal; +using SMMM = Sucrose.Manager.Manage.Manager; +using SSSHL = Sucrose.Shared.Space.Helper.Live; +using SBHC = Sucrose.Backgroundog.Helper.Counter; +using SBHP = Sucrose.Backgroundog.Helper.Performance; + +namespace Sucrose.Backgroundog.Helper +{ + internal static class Initialize + { + public static void Start() + { + SBMI.InitializeTimer.Tick += new EventHandler(InitializeTimer_Tick); + SBMI.InitializeTimer.Interval = new TimeSpan(0, 0, 1); + SBMI.InitializeTimer.Start(); + } + + public static void Stop() + { + SBMI.InitializeTimer.Stop(); + } + + private static void InitializeTimer_Tick(object sender, EventArgs e) + { + //Libredeki cpu, ram, net bilgileri değişkene atılacak + SBHC.Start(); + + if (SSSHL.Run()) + { + //Performans şartları kontrol edilecek... + SBHP.Start(); + } + else if (SBMI.Condition) + { + //Performans şartları sağlanıp live motoru kapatıldıysa veya durdurulduysa + //Live motoruna gRPC (Live.json) ile durdur mesajı gönderilir + } + } + } +} diff --git a/src/Project/Sucrose.Backgroundog/Helper/Performance.cs b/src/Project/Sucrose.Backgroundog/Helper/Performance.cs new file mode 100644 index 000000000..ff818d88d --- /dev/null +++ b/src/Project/Sucrose.Backgroundog/Helper/Performance.cs @@ -0,0 +1,15 @@ +using SBMI = Sucrose.Backgroundog.Manage.Internal; +using SMMI = Sucrose.Manager.Manage.Internal; +using SMMM = Sucrose.Manager.Manage.Manager; +using SSSHL = Sucrose.Shared.Space.Helper.Live; + +namespace Sucrose.Backgroundog.Helper +{ + internal static class Performance + { + public static void Start() + { + + } + } +} diff --git a/src/Project/Sucrose.Backgroundog/Manage/Internal.cs b/src/Project/Sucrose.Backgroundog/Manage/Internal.cs index ae10bcfa4..268ad9353 100644 --- a/src/Project/Sucrose.Backgroundog/Manage/Internal.cs +++ b/src/Project/Sucrose.Backgroundog/Manage/Internal.cs @@ -1,7 +1,15 @@ -namespace Sucrose.Backgroundog.Manage +using System.Windows.Threading; + +namespace Sucrose.Backgroundog.Manage { internal static class Internal { + public static bool Exit = true; + public static bool State = true; + + public static bool Condition = false; + + public static DispatcherTimer InitializeTimer = new(); } } \ No newline at end of file diff --git a/src/Project/Sucrose.Backgroundog/Sucrose.Backgroundog.csproj b/src/Project/Sucrose.Backgroundog/Sucrose.Backgroundog.csproj index f1f1427e0..8f89206bd 100644 --- a/src/Project/Sucrose.Backgroundog/Sucrose.Backgroundog.csproj +++ b/src/Project/Sucrose.Backgroundog/Sucrose.Backgroundog.csproj @@ -69,6 +69,7 @@ + diff --git a/src/Shared/Sucrose.Shared.Launcher/Command/Close.cs b/src/Shared/Sucrose.Shared.Launcher/Command/Close.cs index eb0d21a4c..566a6ae79 100644 --- a/src/Shared/Sucrose.Shared.Launcher/Command/Close.cs +++ b/src/Shared/Sucrose.Shared.Launcher/Command/Close.cs @@ -1,11 +1,10 @@ using SELLT = Skylark.Enum.LevelLogType; -using SMC = Sucrose.Memory.Constant; using SMMI = Sucrose.Manager.Manage.Internal; using SMMM = Sucrose.Manager.Manage.Manager; using SMR = Sucrose.Memory.Readonly; +using SSLHK = Sucrose.Shared.Live.Helper.Kill; using SSSHL = Sucrose.Shared.Space.Helper.Live; using SSSHP = Sucrose.Shared.Space.Helper.Processor; -using SWUD = Skylark.Wing.Utility.Desktop; using WinForms = System.Windows.Forms.Application; namespace Sucrose.Shared.Launcher.Command @@ -20,16 +19,7 @@ public static void Command() { if (SSSHL.Run()) { - SSSHL.Kill(); - - if (!string.IsNullOrEmpty(SMMM.App)) - { - SSSHP.Kill(SMMM.App); - } - - SWUD.RefreshDesktop(); - - SMMI.AuroraSettingManager.SetSetting(SMC.App, string.Empty); + SSLHK.Stop(); } if (SSSHP.Work(SMR.Portal)) @@ -46,11 +36,6 @@ public static void Command() { SSSHP.Kill(SMR.Commandog); } - - if (SSSHP.Work(SMR.Backgroundog)) - { - SSSHP.Kill(SMR.Backgroundog); - } } WinForms.ExitThread(); diff --git a/src/Shared/Sucrose.Shared.Launcher/Command/Engine.cs b/src/Shared/Sucrose.Shared.Launcher/Command/Engine.cs index 52d07847c..cc158ff23 100644 --- a/src/Shared/Sucrose.Shared.Launcher/Command/Engine.cs +++ b/src/Shared/Sucrose.Shared.Launcher/Command/Engine.cs @@ -1,11 +1,9 @@ -using SMC = Sucrose.Memory.Constant; -using SMMI = Sucrose.Manager.Manage.Internal; +using SMMI = Sucrose.Manager.Manage.Internal; using SMMM = Sucrose.Manager.Manage.Manager; using SSLCI = Sucrose.Shared.Launcher.Command.Interface; +using SSLHK = Sucrose.Shared.Live.Helper.Kill; using SSLHR = Sucrose.Shared.Live.Helper.Run; using SSSHL = Sucrose.Shared.Space.Helper.Live; -using SSSHP = Sucrose.Shared.Space.Helper.Processor; -using SWUD = Skylark.Wing.Utility.Desktop; namespace Sucrose.Shared.Launcher.Command { @@ -15,16 +13,7 @@ public static void Command(bool State = true) { if (State && SSSHL.Run()) { - SSSHL.Kill(); - - if (!string.IsNullOrEmpty(SMMM.App)) - { - SSSHP.Kill(SMMM.App); - } - - SWUD.RefreshDesktop(); - - SMMI.AuroraSettingManager.SetSetting(SMC.App, string.Empty); + SSLHK.Stop(); } else if (!SSSHL.Run() && SMMI.LibrarySettingManager.CheckFile() && !string.IsNullOrEmpty(SMMM.LibrarySelected)) { diff --git a/src/Shared/Sucrose.Shared.Live/Helper/Kill.cs b/src/Shared/Sucrose.Shared.Live/Helper/Kill.cs new file mode 100644 index 000000000..40309015b --- /dev/null +++ b/src/Shared/Sucrose.Shared.Live/Helper/Kill.cs @@ -0,0 +1,26 @@ +using SMC = Sucrose.Memory.Constant; +using SMMI = Sucrose.Manager.Manage.Internal; +using SMMM = Sucrose.Manager.Manage.Manager; +using SSSHL = Sucrose.Shared.Space.Helper.Live; +using SSSHP = Sucrose.Shared.Space.Helper.Processor; +using SWUD = Skylark.Wing.Utility.Desktop; + +namespace Sucrose.Shared.Live.Helper +{ + internal static class Kill + { + public static void Stop() + { + SSSHL.Kill(); + + if (!string.IsNullOrEmpty(SMMM.App)) + { + SSSHP.Kill(SMMM.App); + } + + SWUD.RefreshDesktop(); + + SMMI.AuroraSettingManager.SetSetting(SMC.App, string.Empty); + } + } +} \ No newline at end of file diff --git a/src/Shared/Sucrose.Shared.Live/Helper/Run.cs b/src/Shared/Sucrose.Shared.Live/Helper/Run.cs index 449d5b068..0b1a337b7 100644 --- a/src/Shared/Sucrose.Shared.Live/Helper/Run.cs +++ b/src/Shared/Sucrose.Shared.Live/Helper/Run.cs @@ -23,7 +23,10 @@ public static void Start() if (Info.AppVersion.CompareTo(SHV.Entry()) <= 0) { - SSSHP.Run(SSSMI.Commandog, $"{SMR.StartCommand}{SSDECT.Backgroundog}{SMR.ValueSeparator}{SSSMI.Backgroundog}"); + if (SMMM.PerformanceCounter) + { + SSSHP.Run(SSSMI.Commandog, $"{SMR.StartCommand}{SSDECT.Backgroundog}{SMR.ValueSeparator}{SSSMI.Backgroundog}"); + } switch (Info.Type) { diff --git a/src/Shared/Sucrose.Shared.Live/Sucrose.Shared.Live.projitems b/src/Shared/Sucrose.Shared.Live/Sucrose.Shared.Live.projitems index 482f77c88..6bf7f5514 100644 --- a/src/Shared/Sucrose.Shared.Live/Sucrose.Shared.Live.projitems +++ b/src/Shared/Sucrose.Shared.Live/Sucrose.Shared.Live.projitems @@ -9,6 +9,7 @@ Sucrose.Shared.Live + diff --git a/src/Shared/Sucrose.Shared.Server/Services/LauncherServerService.cs b/src/Shared/Sucrose.Shared.Server/Services/LauncherServerService.cs index 35b65a152..9cb5518da 100644 --- a/src/Shared/Sucrose.Shared.Server/Services/LauncherServerService.cs +++ b/src/Shared/Sucrose.Shared.Server/Services/LauncherServerService.cs @@ -3,8 +3,8 @@ using Google.Protobuf.WellKnownTypes; using Grpc.Core; using Sucrose.Grpc.Common; -using SSLMI = Sucrose.Shared.Launcher.Manage.Internal; using static Sucrose.Grpc.Common.Launcher; +using SSLMI = Sucrose.Shared.Launcher.Manage.Internal; namespace Sucrose.Shared.Server.Services {