Skip to content

Commit

Permalink
Preparing Backgroundog
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiizor committed Sep 21, 2023
1 parent 3a2425b commit e902e35
Show file tree
Hide file tree
Showing 15 changed files with 376 additions and 28 deletions.
32 changes: 18 additions & 14 deletions src/Library/Sucrose.Manager/Manage/Manager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,30 @@ public static class Manager

public static string LibraryLocation => SMMI.LibrarySettingManager.GetSetting(SMC.LibraryLocation, Path.Combine(SMR.DocumentsPath, SMR.AppName));

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

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

public static int DescriptionLength => SHS.Clamp(SMMI.PortalSettingManager.GetSettingStable(SMC.DescriptionLength, 30), 10, 100);

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

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

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);

public static int BatteryUsage => SHS.Clamp(SMMI.BackgroundogSettingManager.GetSettingStable(SMC.BatteryUsage, 50), 0, 100);

public static int MemoryUsage => SHS.Clamp(SMMI.BackgroundogSettingManager.GetSettingStable(SMC.MemoryUsage, 80), 0, 100);

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

public static int PingValue => SHS.Clamp(SMMI.BackgroundogSettingManager.GetSettingStable(SMC.PingValue, 100), 0, 10000);

public static int AdvertisingDelay => SHS.Clamp(SMMI.DonateManager.GetSettingStable(SMC.AdvertisingDelay, 30), 30, 720);

public static int AdaptiveMargin => SHS.Clamp(SMMI.PortalSettingManager.GetSettingStable(SMC.AdaptiveMargin, 8), 5, 25);
Expand All @@ -41,10 +51,14 @@ public static class Manager

public static int TitleLength => SHS.Clamp(SMMI.PortalSettingManager.GetSettingStable(SMC.TitleLength, 25), 10, 100);

public static int CpuUsage => SHS.Clamp(SMMI.BackgroundogSettingManager.GetSettingStable(SMC.CpuUsage, 70), 0, 100);

public static string GraphicAdapter => SMMI.BackgroundogSettingManager.GetSetting(SMC.GraphicAdapter, string.Empty);

public static string NetworkAdapter => SMMI.BackgroundogSettingManager.GetSetting(SMC.NetworkAdapter, string.Empty);

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

public static bool PerformanceCounter => SMMI.BackgroundogSettingManager.GetSetting(SMC.PerformanceCounter, true);

public static string LibrarySelected => SMMI.LibrarySettingManager.GetSetting(SMC.LibrarySelected, string.Empty);
Expand All @@ -53,18 +67,12 @@ public static class Manager

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

public static int Startup => SHS.Clamp(SMMI.GeneralSettingManager.GetSettingStable(SMC.Startup, 0), 0, 10);

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, 10);

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

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

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

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

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

public static List<string> Themes => SMMI.ThemesManager.GetSetting(SMC.Themes, new List<string>());

public static string PingType => SMMI.BackgroundogSettingManager.GetSetting(SMC.PingType, "Bing");

public static bool DiscordRefresh => SMMI.HookSettingManager.GetSetting(SMC.DiscordRefresh, true);

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

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

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

public static bool LibraryMove => SMMI.LibrarySettingManager.GetSetting(SMC.LibraryMove, true);

public static bool DiscordState => SMMI.HookSettingManager.GetSetting(SMC.DiscordState, true);

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

public static int Startup => SMMI.GeneralSettingManager.GetSettingStable(SMC.Startup, 0);

public static bool Visible => SMMI.LauncherSettingManager.GetSetting(SMC.Visible, true);

public static string App => SMMI.AuroraSettingManager.GetSetting(SMC.App, string.Empty);
Expand Down
4 changes: 4 additions & 0 deletions src/Library/Sucrose.Memory/Constant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public static class Constant

public const string CpuUsage = "CpuUsage";

public const string PingType = "PingType";

public const string PingValue = "PingValue";

public const string UserAgent = "UserAgent";

public const string ThemeType = "ThemeType";
Expand Down
5 changes: 3 additions & 2 deletions src/Portal/Sucrose.Portal/Manage/Manager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Wpf.Ui.Controls;
using SEST = Skylark.Enum.ScreenType;
using SEWTT = Skylark.Enum.WindowsThemeType;
using SHS = Skylark.Helper.Skymath;
using SMC = Sucrose.Memory.Constant;
using SMMI = Sucrose.Manager.Manage.Internal;
using SMR = Sucrose.Memory.Readonly;
Expand Down Expand Up @@ -32,12 +33,12 @@ internal static class Manager

public static SEST ScreenType => SMMI.EngineSettingManager.GetSetting(SMC.ScreenType, SEST.DisplayBound);

public static int Port => SHS.Clamp(SMMI.LauncherSettingManager.GetSettingStable(SMC.Port, 0), 0, 65535);

public static SSDEST StretchType => SMMI.EngineSettingManager.GetSetting(SMC.StretchType, SSDEST.Fill);

public static SEWTT Theme => SMMI.GeneralSettingManager.GetSetting(SMC.ThemeType, SWHWT.GetTheme());

public static int Port => SMMI.LauncherSettingManager.GetSettingStable(SMC.Port, 0);

public static WindowBackdropType DefaultBackdropType => WindowBackdropType.None;

public static Stretch DefaultBackgroundStretch => Stretch.UniformToFill;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
using SPVCEC = Sucrose.Portal.Views.Controls.ExpanderCard;
using SSDECT = Sucrose.Shared.Dependency.Enum.CommandsType;
using SSDEPT = Sucrose.Shared.Dependency.Enum.PerformanceType;
using SSDSHHS = Sucrose.Shared.Dependency.Struct.Host.HostStruct;
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 @@ -320,6 +322,45 @@ private void InitializeViewModel()

NetworkDownloadType.SelectedIndex = (int)SMMM.DownloadType;

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

TextBlock NetworkPingText = new()
{
Foreground = SSRER.GetResource<Brush>("TextFillColorPrimaryBrush"),
VerticalAlignment = VerticalAlignment.Center,
Margin = new Thickness(0, 0, 10, 0),
FontWeight = FontWeights.SemiBold,
Text = "Ping Değeri:"
};

NumberBox NetworkPing = new()
{
Margin = new Thickness(0, 0, 10, 0),
ClearButtonEnabled = false,
Value = SMMM.PingValue,
MaxDecimalPlaces = 0,
Maximum = 10000,
MaxLength = 5,
Minimum = 0
};

NetworkPing.ValueChanged += (s, e) => NetworkPingChanged(NetworkPing.Value);

ComboBox NetworkPingType = new();

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

foreach (SSDSHHS Host in SSSHN.GetHost())
{
NetworkPingType.Items.Add(Host.Name);
}

NetworkPingType.SelectedValue = SMMM.PingType;

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

Expand All @@ -331,9 +372,14 @@ private void InitializeViewModel()
NetworkDownloadContent.Children.Add(NetworkDownload);
NetworkDownloadContent.Children.Add(NetworkDownloadType);

NetworkPingContent.Children.Add(NetworkPingText);
NetworkPingContent.Children.Add(NetworkPing);
NetworkPingContent.Children.Add(NetworkPingType);

NetworkContent.Children.Add(NetworkAdapterContent);
NetworkContent.Children.Add(NetworkUploadContent);
NetworkContent.Children.Add(NetworkDownloadContent);
NetworkContent.Children.Add(NetworkPingContent);

Network.FooterCard = NetworkContent;

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

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

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

private void NetworkUploadChanged(double? Value)
{
int NewValue = Convert.ToInt32(Value);
Expand Down Expand Up @@ -586,6 +642,14 @@ private void MemoryPerformanceSelected(int Index)
}
}

private void NetworkPingTypeSelected(string Value)
{
if (Value != SMMM.PingType)
{
SMMI.BackgroundogSettingManager.SetSetting(SMC.PingType, Value);
}
}

private void NetworkPerformanceSelected(int Index)
{
if (Index != (int)SPMM.NetworkPerformance)
Expand Down
14 changes: 13 additions & 1 deletion src/Project/Sucrose.Backgroundog/Extension/Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,23 @@ public static JObject GetNetworkInfo()
return new JObject
{
{ "Name", SBMI.NetworkData.Name },
{ "Ping", SBMI.NetworkData.Ping },
{ "State", SBMI.NetworkData.State },
{ "Upload", SBMI.NetworkData.Upload },
{ "Download", SBMI.NetworkData.Download },
{ "FormatUploadData", SBMI.NetworkData.FormatUploadData },
{ "FormatDownloadData", SBMI.NetworkData.FormatDownloadData },
{
"PingData", new JObject
{
{ "Ttl", SBMI.NetworkData.PingData.Ttl },
{ "Buffer", SBMI.NetworkData.PingData.Buffer },
{ "Address", SBMI.NetworkData.PingData.Address },
{ "Fragment", SBMI.NetworkData.PingData.Fragment },
{ "Result", $"{SBMI.NetworkData.PingData.Result}" },
{ "RoundTrip", SBMI.NetworkData.PingData.RoundTrip }
}
},
{
"UploadData", new JObject
{
Expand All @@ -161,7 +173,7 @@ public static JObject GetNetworkInfo()
{ "Type", $"{SBMI.NetworkData.DownloadData.Type}" },
{ "Short", $"{SBMI.NetworkData.DownloadData.Short}" }
}
},
}
};
}

Expand Down
Loading

0 comments on commit e902e35

Please sign in to comment.