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 20, 2023
1 parent 090914a commit fbc5b57
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Library/Sucrose.Manager/Manage/Manager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public static class Manager

public static int UploadValue => SMMI.BackgroundogSettingManager.GetSettingStable(SMC.UploadValue, 800);

public static int MemoryUsage => SMMI.BackgroundogSettingManager.GetSettingStable(SMC.MemoryUsage, 75);

public static string UserAgent => SMMI.GeneralSettingManager.GetSetting(SMC.UserAgent, SMR.UserAgent);

public static bool LibraryConfirm => SMMI.LibrarySettingManager.GetSetting(SMC.LibraryConfirm, true);
Expand All @@ -75,6 +77,8 @@ public static class Manager

public static bool AdvertisingState => SMMI.DonateManager.GetSetting(SMC.AdvertisingState, true);

public static int CpuUsage => SMMI.BackgroundogSettingManager.GetSettingStable(SMC.CpuUsage, 75);

public static int ScreenIndex => SMMI.EngineSettingManager.GetSettingStable(SMC.ScreenIndex, 0);

public static bool LibraryMove => SMMI.LibrarySettingManager.GetSetting(SMC.LibraryMove, true);
Expand Down
8 changes: 8 additions & 0 deletions src/Library/Sucrose.Memory/Constant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public static class Constant

public const string Startup = "Startup";

public const string CpuUsage = "CpuUsage";

public const string UserAgent = "UserAgent";

public const string ThemeType = "ThemeType";
Expand All @@ -52,6 +54,8 @@ public static class Constant

public const string UploadType = "UploadType";

public const string MemoryUsage = "MemoryUsage";

public const string LibraryMove = "LibraryMove";

public const string ScreenIndex = "ScreenIndex";
Expand Down Expand Up @@ -102,6 +106,8 @@ public static class Constant

public const string NetworkAdapter = "NetworkAdapter";

public const string CpuPerformance = "CpuPerformance";

public const string StorePagination = "StorePagination";

public const string LibraryLocation = "LibraryLocation";
Expand All @@ -126,6 +132,8 @@ public static class Constant

public const string NetworkInterfaces = "NetworkInterfaces";

public const string MemoryPerformance = "MemoryPerformance";

public const string PerformanceCounter = "PerformanceCounter";

public const string NetworkPerformance = "NetworkPerformance";
Expand Down
4 changes: 4 additions & 0 deletions src/Portal/Sucrose.Portal/Manage/Manager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ internal static class Manager

public static SSDEPT NetworkPerformance => SMMI.BackgroundogSettingManager.GetSetting(SMC.NetworkPerformance, SSDEPT.Resume);

public static SSDEPT MemoryPerformance => SMMI.BackgroundogSettingManager.GetSetting(SMC.MemoryPerformance, SSDEPT.Pause);

public static SSDEPT CpuPerformance => SMMI.BackgroundogSettingManager.GetSetting(SMC.CpuPerformance, SSDEPT.Pause);

public static IPAddress Host => SMMI.LauncherSettingManager.GetSettingAddress(SMC.Host, IPAddress.Loopback);

public static SEST ScreenType => SMMI.EngineSettingManager.GetSetting(SMC.ScreenType, SEST.DisplayBound);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,118 @@ private void InitializeViewModel()

Contents.Add(SystemResourcesArea);

SPVCEC Cpu = new()
{
Margin = new Thickness(0, 10, 0, 0)
};

Cpu.Title.Text = "İşemci Kullanımı";
Cpu.LeftIcon.Symbol = SymbolRegular.HeartPulse24;
Cpu.Description.Text = "İşlemci kullanımı ayarlarınız sonucunda duvar kağıdına ne olacağı.";

ComboBox CpuPerformance = new();

CpuPerformance.SelectionChanged += (s, e) => CpuPerformanceSelected(CpuPerformance.SelectedIndex);

foreach (SSDEPT Type in Enum.GetValues(typeof(SSDEPT)))
{
CpuPerformance.Items.Add(Type);
}

CpuPerformance.SelectedIndex = (int)SPMM.CpuPerformance;

Cpu.HeaderFrame = CpuPerformance;

StackPanel CpuContent = new()
{
Orientation = Orientation.Horizontal
};

TextBlock CpuUsageText = new()
{
Foreground = SSRER.GetResource<Brush>("TextFillColorPrimaryBrush"),
VerticalAlignment = VerticalAlignment.Center,
Margin = new Thickness(0, 0, 10, 0),
FontWeight = FontWeights.SemiBold,
Text = "İşlemci Kullanımı (%):"
};

NumberBox CpuUsage = new()
{
Margin = new Thickness(0, 0, 10, 0),
ClearButtonEnabled = false,
Value = SMMM.CpuUsage,
MaxDecimalPlaces = 0,
Maximum = 100,
MaxLength = 3,
Minimum = 0
};

CpuUsage.ValueChanged += (s, e) => CpuUsageChanged(CpuUsage.Value);

CpuContent.Children.Add(CpuUsageText);
CpuContent.Children.Add(CpuUsage);

Cpu.FooterCard = CpuContent;

Contents.Add(Cpu);

SPVCEC Memory = new()
{
Margin = new Thickness(0, 10, 0, 0)
};

Memory.Title.Text = "Bellek Kullanımı";
Memory.LeftIcon.Symbol = SymbolRegular.Memory16;
Memory.Description.Text = "Bellek kullanımı ayarlarınız sonucunda duvar kağıdına ne olacağı.";

ComboBox MemoryPerformance = new();

MemoryPerformance.SelectionChanged += (s, e) => MemoryPerformanceSelected(MemoryPerformance.SelectedIndex);

foreach (SSDEPT Type in Enum.GetValues(typeof(SSDEPT)))
{
MemoryPerformance.Items.Add(Type);
}

MemoryPerformance.SelectedIndex = (int)SPMM.MemoryPerformance;

Memory.HeaderFrame = MemoryPerformance;

StackPanel MemoryContent = new()
{
Orientation = Orientation.Horizontal
};

TextBlock MemoryUsageText = new()
{
Foreground = SSRER.GetResource<Brush>("TextFillColorPrimaryBrush"),
VerticalAlignment = VerticalAlignment.Center,
Margin = new Thickness(0, 0, 10, 0),
FontWeight = FontWeights.SemiBold,
Text = "Bellek Kullanımı (%):"
};

NumberBox MemoryUsage = new()
{
Margin = new Thickness(0, 0, 10, 0),
ClearButtonEnabled = false,
Value = SMMM.MemoryUsage,
MaxDecimalPlaces = 0,
Maximum = 100,
MaxLength = 3,
Minimum = 0
};

MemoryUsage.ValueChanged += (s, e) => MemoryUsageChanged(MemoryUsage.Value);

MemoryContent.Children.Add(MemoryUsageText);
MemoryContent.Children.Add(MemoryUsage);

Memory.FooterCard = MemoryContent;

Contents.Add(Memory);

SPVCEC Network = new()
{
Margin = new Thickness(0, 10, 0, 0)
Expand Down Expand Up @@ -240,6 +352,16 @@ public void OnNavigatedFrom()
//Dispose();
}

private void CpuUsageChanged(double? Value)
{
int NewValue = Convert.ToInt32(Value);

if (NewValue != SMMM.CpuUsage)
{
SMMI.BackgroundogSettingManager.SetSetting(SMC.CpuUsage, NewValue);
}
}

private void CounterStateChecked(bool State)
{
SMMI.BackgroundogSettingManager.SetSetting(SMC.PerformanceCounter, State);
Expand All @@ -257,6 +379,26 @@ private void CounterStateChecked(bool State)
}
}

private void CpuPerformanceSelected(int Index)
{
if (Index != (int)SPMM.CpuPerformance)
{
SSDEPT Type = (SSDEPT)Index;

SMMI.BackgroundogSettingManager.SetSetting(SMC.CpuPerformance, Type);
}
}

private void MemoryUsageChanged(double? Value)
{
int NewValue = Convert.ToInt32(Value);

if (NewValue != SMMM.MemoryUsage)
{
SMMI.BackgroundogSettingManager.SetSetting(SMC.MemoryUsage, NewValue);
}
}

private void NetworkUploadChanged(double? Value)
{
int NewValue = Convert.ToInt32(Value);
Expand Down Expand Up @@ -285,6 +427,16 @@ private void NetworkAdapterSelected(string Value)
}
}

private void MemoryPerformanceSelected(int Index)
{
if (Index != (int)SPMM.MemoryPerformance)
{
SSDEPT Type = (SSDEPT)Index;

SMMI.BackgroundogSettingManager.SetSetting(SMC.MemoryPerformance, Type);
}
}

private void NetworkPerformanceSelected(int Index)
{
if (Index != (int)SPMM.NetworkPerformance)
Expand Down

0 comments on commit fbc5b57

Please sign in to comment.