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 fbc5b57 commit 7f44759
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 0 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 @@ -59,6 +59,8 @@ public static class Manager

public static int DownloadValue => SMMI.BackgroundogSettingManager.GetSettingStable(SMC.DownloadValue, 10);

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

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

public static int MemoryUsage => SMMI.BackgroundogSettingManager.GetSettingStable(SMC.MemoryUsage, 75);
Expand Down
6 changes: 6 additions & 0 deletions src/Library/Sucrose.Memory/Constant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public static class Constant

public const string UploadValue = "UploadValue";

public const string BatteryUsage = "BatteryUsage";

public const string BackdropType = "BackdropType";

public const string CefArguments = "CefArguments";
Expand Down Expand Up @@ -122,6 +124,8 @@ public static class Constant

public const string ExpandScreenType = "ExpandScreenType";

public const string SaverPerformance = "SaverPerformance";

public const string BackgroundOpacity = "BackgroundOpacity";

public const string BackgroundStretch = "BackgroundStretch";
Expand All @@ -138,6 +142,8 @@ public static class Constant

public const string NetworkPerformance = "NetworkPerformance";

public const string BatteryPerformance = "BatteryPerformance";

public const string DuplicateScreenType = "DuplicateScreenType";
}
}
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,8 +20,12 @@ internal static class Manager

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

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

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

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

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

public static IPAddress Host => SMMI.LauncherSettingManager.GetSettingAddress(SMC.Host, IPAddress.Loopback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,97 @@ private void InitializeViewModel()

Contents.Add(Network);

TextBlock LaptopArea = new()
{
Foreground = SSRER.GetResource<Brush>("TextFillColorPrimaryBrush"),
Margin = new Thickness(0, 10, 0, 0),
FontWeight = FontWeights.Bold,
Text = "Dizüstü"
};

Contents.Add(LaptopArea);

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

Battery.Title.Text = "Pil Gücü";
Battery.LeftIcon.Symbol = SymbolRegular.Battery624;
Battery.Description.Text = "Dizüstü bilgisayar pil gücünde çalışırken duvar kağıdına ne olacağı.";

ComboBox BatteryPerformance = new();

BatteryPerformance.SelectionChanged += (s, e) => BatteryPerformanceSelected(BatteryPerformance.SelectedIndex);

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

BatteryPerformance.SelectedIndex = (int)SPMM.BatteryPerformance;

Battery.HeaderFrame = BatteryPerformance;

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

TextBlock BatteryUsageText = new()
{
Foreground = SSRER.GetResource<Brush>("TextFillColorPrimaryBrush"),
VerticalAlignment = VerticalAlignment.Center,
Margin = new Thickness(0, 0, 10, 0),
FontWeight = FontWeights.SemiBold,
Text = "Pil Durumu (%):"
};

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

BatteryUsage.ValueChanged += (s, e) => BatteryUsageChanged(BatteryUsage.Value);

BatteryContent.Children.Add(BatteryUsageText);
BatteryContent.Children.Add(BatteryUsage);

Battery.FooterCard = BatteryContent;

Contents.Add(Battery);

SPVCEC Saver = new()
{
Margin = new Thickness(0, 10, 0, 0),
Expandable = false
};

Saver.Title.Text = "Pil Tasarrufu";
Saver.LeftIcon.Symbol = SymbolRegular.BatterySaver24;
Saver.Description.Text = "Dizüstü bilgisayar pil tasarrufu modundayken duvar kağıdına ne olacağı.";

ComboBox SaverPerformance = new();

SaverPerformance.SelectionChanged += (s, e) => SaverPerformanceSelected(SaverPerformance.SelectedIndex);

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

SaverPerformance.SelectedIndex = (int)SPMM.SaverPerformance;

Saver.HeaderFrame = SaverPerformance;

Contents.Add(Saver);

_isInitialized = true;
}

Expand Down Expand Up @@ -399,6 +490,16 @@ private void MemoryUsageChanged(double? Value)
}
}

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

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

private void NetworkUploadChanged(double? Value)
{
int NewValue = Convert.ToInt32(Value);
Expand All @@ -409,6 +510,16 @@ private void NetworkUploadChanged(double? Value)
}
}

private void SaverPerformanceSelected(int Index)
{
if (Index != (int)SPMM.SaverPerformance)
{
SSDEPT Type = (SSDEPT)Index;

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

private void NetworkUploadTypeSelected(int Index)
{
if (Index != (int)SMMM.UploadType)
Expand Down Expand Up @@ -447,6 +558,16 @@ private void NetworkPerformanceSelected(int Index)
}
}

private void BatteryPerformanceSelected(int Index)
{
if (Index != (int)SPMM.BatteryPerformance)
{
SSDEPT Type = (SSDEPT)Index;

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

private void NetworkDownloadChanged(double? Value)
{
int NewValue = Convert.ToInt32(Value);
Expand Down

0 comments on commit 7f44759

Please sign in to comment.