Skip to content

Commit

Permalink
Preparing Performance Setting Page
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiizor committed Sep 18, 2023
1 parent afc4e2b commit 855376a
Show file tree
Hide file tree
Showing 18 changed files with 194 additions and 81 deletions.
2 changes: 2 additions & 0 deletions src/Library/Sucrose.Manager/Manage/Manager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/Library/Sucrose.Memory/Constant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ public static class Constant

public const string DescriptionLength = "DescriptionLength";

public const string PerformanceCounter = "PerformanceCounter";

public const string DuplicateScreenType = "DuplicateScreenType";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
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;
using SSSHC = Sucrose.Shared.Space.Helper.Copy;
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
Expand Down Expand Up @@ -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);

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -29,11 +32,43 @@ public PerformanceSettingViewModel()

private void InitializeViewModel()
{
TextBlock SystemResourcesArea = new()
TextBlock AppearanceBehaviorArea = new()
{
Foreground = SSRER.GetResource<Brush>("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<Brush>("TextFillColorPrimaryBrush"),
Margin = new Thickness(0, 10, 0, 0),
FontWeight = FontWeights.Bold,
Text = "Sistem Kaynakları"
};

Expand All @@ -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();
Expand Down
13 changes: 2 additions & 11 deletions src/Portal/Sucrose.Portal/Views/Controls/LibraryCard.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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();
Expand Down
13 changes: 2 additions & 11 deletions src/Portal/Sucrose.Portal/Views/Controls/StoreCard.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
{
Expand Down Expand Up @@ -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();
Expand Down
13 changes: 11 additions & 2 deletions src/Project/Sucrose.Backgroundog/App.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -15,7 +17,7 @@ namespace Sucrose.Backgroundog
{
internal class App
{
internal static void Main()
internal static async Task Main()
{
try
{
Expand All @@ -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();
Expand Down
15 changes: 15 additions & 0 deletions src/Project/Sucrose.Backgroundog/Helper/Counter.cs
Original file line number Diff line number Diff line change
@@ -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()
{

}
}
}
41 changes: 41 additions & 0 deletions src/Project/Sucrose.Backgroundog/Helper/Initialize.cs
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}
15 changes: 15 additions & 0 deletions src/Project/Sucrose.Backgroundog/Helper/Performance.cs
Original file line number Diff line number Diff line change
@@ -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()
{

}
}
}
10 changes: 9 additions & 1 deletion src/Project/Sucrose.Backgroundog/Manage/Internal.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@

<ItemGroup>
<PackageReference Include="Skylark.Wing" Version="3.1.1.3" />
<PackageReference Include="Skylark.Standard" Version="3.1.1.3" />
<PackageReference Include="LibreHardwareMonitorLib" Version="0.9.3-pre256" />
</ItemGroup>

Expand Down
19 changes: 2 additions & 17 deletions src/Shared/Sucrose.Shared.Launcher/Command/Close.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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))
Expand All @@ -46,11 +36,6 @@ public static void Command()
{
SSSHP.Kill(SMR.Commandog);
}

if (SSSHP.Work(SMR.Backgroundog))
{
SSSHP.Kill(SMR.Backgroundog);
}
}

WinForms.ExitThread();
Expand Down
Loading

0 comments on commit 855376a

Please sign in to comment.