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 7392f32 commit ae8b338
Show file tree
Hide file tree
Showing 9 changed files with 188 additions and 44 deletions.
2 changes: 2 additions & 0 deletions src/Library/Sucrose.Manager/Manage/Internal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public static class Internal

public static readonly SMLM PortalLogManager = new("Portal-{0}.log");

public static readonly SMSM SystemSettingManager = new("System.json");

public static readonly SMSM PortalSettingManager = new("Portal.json");

public static readonly SMSM AuroraSettingManager = new("Aurora.json");
Expand Down
9 changes: 8 additions & 1 deletion src/Library/Sucrose.Manager/Manage/Manager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using SHC = Skylark.Helper.Culture;
using SEST = Skylark.Enum.StorageType;
using SHC = Skylark.Helper.Culture;
using SHS = Skylark.Helper.Skymath;
using SMC = Sucrose.Memory.Constant;
using SMMI = Sucrose.Manager.Manage.Internal;
Expand All @@ -20,6 +21,8 @@ public static class Manager

public static int LibraryPagination => SHS.Clamp(SMMI.PortalSettingManager.GetSettingStable(SMC.LibraryPagination, 36), 1, 100);

public static string[] NetworkInterfaces => SMMI.SystemSettingManager.GetSetting(SMC.NetworkInterfaces, Array.Empty<string>());

public static string Culture => SMMI.GeneralSettingManager.GetSetting(SMC.CultureName, SHC.CurrentUITwoLetterISOLanguageName);

public static int StorePagination => SHS.Clamp(SMMI.PortalSettingManager.GetSettingStable(SMC.StorePagination, 30), 1, 100);
Expand Down Expand Up @@ -48,6 +51,10 @@ public static class Manager

public static string BackgroundImage => SMMI.PortalSettingManager.GetSetting(SMC.BackgroundImage, string.Empty);

public static SEST DownloadType => SMMI.BackgroundogSettingManager.GetSetting(SMC.DownloadType, SEST.Kilobyte);

public static SEST UploadType => SMMI.BackgroundogSettingManager.GetSetting(SMC.UploadType, SEST.Kilobyte);

public static int Volume => SHS.Clamp(SMMI.EngineSettingManager.GetSettingStable(SMC.Volume, 100), 0, 100);

public static int DownloadValue => SMMI.BackgroundogSettingManager.GetSettingStable(SMC.DownloadValue, 0);
Expand Down
11 changes: 11 additions & 0 deletions src/Library/Sucrose.Manager/SettingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,17 @@ private T ConvertToType<T>(object value)

return (T)(object)new KeyValuePair<string, string>(parts[0].Trim(), parts[1].Trim());
}
else if (type == typeof(string[]))
{
if (value is string[] array)
{
return (T)(object)array;
}
else if (value is JArray jArray)
{
return (T)(object)jArray.Select(jValue => (string)jValue).ToArray();
}
}
else if (type == typeof(List<string>))
{
if (value is List<string> list)
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 @@ -50,6 +50,8 @@ public static class Constant

public const string ScreenType = "ScreenType";

public const string UploadType = "UploadType";

public const string LibraryMove = "LibraryMove";

public const string ScreenIndex = "ScreenIndex";
Expand All @@ -76,6 +78,8 @@ public static class Constant

public const string DiscordState = "DiscordState";

public const string DownloadType = "DownloadType";

public const string DownloadValue = "DownloadValue";

public const string DonateVisible = "DonateVisible";
Expand Down Expand Up @@ -120,8 +124,12 @@ public static class Constant

public const string DescriptionLength = "DescriptionLength";

public const string NetworkInterfaces = "NetworkInterfaces";

public const string PerformanceCounter = "PerformanceCounter";

public const string NetworkPerformance = "NetworkPerformance";

public const string DuplicateScreenType = "DuplicateScreenType";
}
}
3 changes: 3 additions & 0 deletions src/Portal/Sucrose.Portal/Manage/Manager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using SMMI = Sucrose.Manager.Manage.Internal;
using SMR = Sucrose.Memory.Readonly;
using SSDEST = Sucrose.Shared.Dependency.Enum.StretchType;
using SSDEPT = Sucrose.Shared.Dependency.Enum.PerformanceType;
using SWHWT = Skylark.Wing.Helper.WindowsTheme;

namespace Sucrose.Portal.Manage
Expand All @@ -17,6 +18,8 @@ internal static class Manager

public static WindowBackdropType BackdropType => SMMI.PortalSettingManager.GetSetting(SMC.BackdropType, DefaultBackdropType);

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

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 @@ -3,14 +3,16 @@
using System.Windows.Controls;
using System.Windows.Media;
using Wpf.Ui.Controls;
using SEST = Skylark.Enum.StorageType;
using SMC = Sucrose.Memory.Constant;
using SMMI = Sucrose.Manager.Manage.Internal;
using SMMM = Sucrose.Manager.Manage.Manager;
using SPMM = Sucrose.Portal.Manage.Manager;
using SMR = Sucrose.Memory.Readonly;
using SPVCEC = Sucrose.Portal.Views.Controls.ExpanderCard;
using SSDECT = Sucrose.Shared.Dependency.Enum.CommandsType;
using SSDEPT = Sucrose.Shared.Dependency.Enum.PerformanceType;
using SSRER = Sucrose.Shared.Resources.Extension.Resources;
using SSSHN = Sucrose.Shared.Space.Helper.Network;
using SSSHP = Sucrose.Shared.Space.Helper.Processor;
using SSSMI = Sucrose.Shared.Space.Manage.Internal;
using TextBlock = System.Windows.Controls.TextBlock;
Expand Down Expand Up @@ -76,39 +78,65 @@ private void InitializeViewModel()

Contents.Add(SystemResourcesArea);

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

Adapter.Title.Text = "Ağ Kullanımı";
Adapter.LeftIcon.Symbol = SymbolRegular.NetworkCheck24;
Adapter.Description.Text = "Ağ kullanımı belirlenen sınırı geçtiğinde duvar kağıdına ne olacağı.";
Network.Title.Text = "Ağ Kullanımı";
Network.LeftIcon.Symbol = SymbolRegular.NetworkCheck24;
Network.Description.Text = "Ağ kullanımı belirlenen sınırı geçtiğinde duvar kağıdına ne olacağı.";

ComboBox NetworkPerformance = new();

NetworkPerformance.SelectionChanged += (s, e) => NetworkPerformanceSelected(NetworkPerformance.SelectedIndex);

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

NetworkPerformance.SelectedIndex = (int)SPMM.NetworkPerformance;

Network.HeaderFrame = NetworkPerformance;

StackPanel NetworkContent = new();

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

TextBlock NetworkAdapterText = new()
{
Foreground = SSRER.GetResource<Brush>("TextFillColorPrimaryBrush"),
VerticalAlignment = VerticalAlignment.Center,
Margin = new Thickness(0, 0, 10, 0),
FontWeight = FontWeights.SemiBold,
Text = "Ağ Adaptörü:"
};

ComboBox NetworkAdapter = new()
{
MaxWidth = 250
MaxWidth = 700
};

NetworkAdapter.SelectionChanged += (s, e) => NetworkAdapterSelected($"{NetworkAdapter.SelectedValue}");

foreach (string Network in SSSHN.InstanceNetworkInterfaces())
foreach (string Interface in SMMM.NetworkInterfaces)
{
NetworkAdapter.Items.Add(Network);
NetworkAdapter.Items.Add(Interface);
}

NetworkAdapter.SelectedValue = SMMM.NetworkAdapter;

Adapter.HeaderFrame = NetworkAdapter;

StackPanel AdapterContent = new();

StackPanel AdapterUploadContent = new()
StackPanel NetworkUploadContent = new()
{
Orientation = Orientation.Horizontal
Orientation = Orientation.Horizontal,
Margin = new Thickness(0, 10, 0, 0)
};

TextBlock AdapterUploadText = new()
TextBlock NetworkUploadText = new()
{
Foreground = SSRER.GetResource<Brush>("TextFillColorPrimaryBrush"),
VerticalAlignment = VerticalAlignment.Center,
Expand All @@ -117,8 +145,9 @@ private void InitializeViewModel()
Text = "Yükleme Boyutu:"
};

NumberBox AdapterUpload = new()
NumberBox NetworkUpload = new()
{
Margin = new Thickness(0, 0, 10, 0),
ClearButtonEnabled = false,
Value = SMMM.UploadValue,
MaxDecimalPlaces = 0,
Expand All @@ -127,13 +156,24 @@ private void InitializeViewModel()
Minimum = 0
};

StackPanel AdapterDownloadContent = new()
ComboBox NetworkUploadType = new();

NetworkUploadType.SelectionChanged += (s, e) => NetworkUploadTypeSelected(NetworkUploadType.SelectedIndex);

foreach (SEST Type in Enum.GetValues(typeof(SEST)))
{
NetworkUploadType.Items.Add(Type);
}

NetworkUploadType.SelectedIndex = (int)SMMM.UploadType;

StackPanel NetworkDownloadContent = new()
{
Orientation = Orientation.Horizontal,
Margin = new Thickness(0, 10, 0, 0)
};

TextBlock AdapterDownloadText = new()
TextBlock NetworkDownloadText = new()
{
Foreground = SSRER.GetResource<Brush>("TextFillColorPrimaryBrush"),
VerticalAlignment = VerticalAlignment.Center,
Expand All @@ -142,8 +182,9 @@ private void InitializeViewModel()
Text = "İndirme Boyutu:"
};

NumberBox AdapterDownload = new()
NumberBox NetworkDownload = new()
{
Margin = new Thickness(0, 0, 10, 0),
ClearButtonEnabled = false,
Value = SMMM.DownloadValue,
MaxDecimalPlaces = 0,
Expand All @@ -152,18 +193,35 @@ private void InitializeViewModel()
Minimum = 0
};

AdapterUploadContent.Children.Add(AdapterUploadText);
AdapterUploadContent.Children.Add(AdapterUpload);
ComboBox NetworkDownloadType = new();

NetworkDownloadType.SelectionChanged += (s, e) => NetworkDownloadTypeSelected(NetworkDownloadType.SelectedIndex);

foreach (SEST Type in Enum.GetValues(typeof(SEST)))
{
NetworkDownloadType.Items.Add(Type);
}

NetworkDownloadType.SelectedIndex = (int)SMMM.DownloadType;

NetworkAdapterContent.Children.Add(NetworkAdapterText);
NetworkAdapterContent.Children.Add(NetworkAdapter);

AdapterDownloadContent.Children.Add(AdapterDownloadText);
AdapterDownloadContent.Children.Add(AdapterDownload);
NetworkUploadContent.Children.Add(NetworkUploadText);
NetworkUploadContent.Children.Add(NetworkUpload);
NetworkUploadContent.Children.Add(NetworkUploadType);

AdapterContent.Children.Add(AdapterUploadContent);
AdapterContent.Children.Add(AdapterDownloadContent);
NetworkDownloadContent.Children.Add(NetworkDownloadText);
NetworkDownloadContent.Children.Add(NetworkDownload);
NetworkDownloadContent.Children.Add(NetworkDownloadType);

Adapter.FooterCard = AdapterContent;
NetworkContent.Children.Add(NetworkAdapterContent);
NetworkContent.Children.Add(NetworkUploadContent);
NetworkContent.Children.Add(NetworkDownloadContent);

Contents.Add(Adapter);
Network.FooterCard = NetworkContent;

Contents.Add(Network);

_isInitialized = true;
}
Expand Down Expand Up @@ -195,6 +253,16 @@ private void CounterStateChecked(bool State)
}
}

private void NetworkUploadTypeSelected(int Index)
{
if (Index != (int)SMMM.UploadType)
{
SEST Type = (SEST)Index;

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

private void NetworkAdapterSelected(string Value)
{
if (Value != SMMM.NetworkAdapter)
Expand All @@ -203,6 +271,26 @@ private void NetworkAdapterSelected(string Value)
}
}

private void NetworkPerformanceSelected(int Index)
{
if (Index != (int)SPMM.NetworkPerformance)
{
SSDEPT Type = (SSDEPT)Index;

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

private void NetworkDownloadTypeSelected(int Index)
{
if (Index != (int)SMMM.DownloadType)
{
SEST Type = (SEST)Index;

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

public void Dispose()
{
Contents.Clear();
Expand Down
Loading

0 comments on commit ae8b338

Please sign in to comment.