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 b3dda2b commit 7392f32
Show file tree
Hide file tree
Showing 9 changed files with 201 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 @@ -50,6 +50,10 @@ public static class Manager

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

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

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

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

public static bool LibraryConfirm => SMMI.LibrarySettingManager.GetSetting(SMC.LibraryConfirm, true);
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 @@ -64,6 +64,8 @@ public static class Constant

public const string Information = "Information";

public const string UploadValue = "UploadValue";

public const string BackdropType = "BackdropType";

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

public const string DiscordState = "DiscordState";

public const string DownloadValue = "DownloadValue";

public const string DonateVisible = "DonateVisible";

public const string LibraryDelete = "LibraryDelete";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ private void InitializeViewModel()
{
Value = SMMM.AdvertisingDelay,
ClearButtonEnabled = false,
MaxDecimalPlaces = 0,
MaxLength = 3,
Maximum = 720,
Minimum = 30
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ private void InitializeViewModel()
{
Value = SMMM.BackgroundOpacity,
ClearButtonEnabled = false,
MaxDecimalPlaces = 0,
MaxLength = 3,
Maximum = 100,
Minimum = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ private void InitializeViewModel()
{
ClearButtonEnabled = false,
Value = SMMM.DiscordDelay,
MaxDecimalPlaces = 0,
Maximum = 3600,
MaxLength = 4,
Minimum = 60
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CommunityToolkit.Mvvm.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Wpf.Ui.Controls;
using SMC = Sucrose.Memory.Constant;
Expand All @@ -9,6 +10,7 @@
using SPVCEC = Sucrose.Portal.Views.Controls.ExpanderCard;
using SSDECT = Sucrose.Shared.Dependency.Enum.CommandsType;
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 @@ -74,6 +76,95 @@ private void InitializeViewModel()

Contents.Add(SystemResourcesArea);

SPVCEC Adapter = 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ğı.";

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

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

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

NetworkAdapter.SelectedValue = SMMM.NetworkAdapter;

Adapter.HeaderFrame = NetworkAdapter;

StackPanel AdapterContent = new();

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

TextBlock AdapterUploadText = new()
{
Foreground = SSRER.GetResource<Brush>("TextFillColorPrimaryBrush"),
VerticalAlignment = VerticalAlignment.Center,
Margin = new Thickness(0, 0, 10, 0),
FontWeight = FontWeights.SemiBold,
Text = "Yükleme Boyutu:"
};

NumberBox AdapterUpload = new()
{
ClearButtonEnabled = false,
Value = SMMM.UploadValue,
MaxDecimalPlaces = 0,
Maximum = 99999999,
MaxLength = 8,
Minimum = 0
};

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

TextBlock AdapterDownloadText = new()
{
Foreground = SSRER.GetResource<Brush>("TextFillColorPrimaryBrush"),
VerticalAlignment = VerticalAlignment.Center,
Margin = new Thickness(0, 0, 10, 0),
FontWeight = FontWeights.SemiBold,
Text = "İndirme Boyutu:"
};

NumberBox AdapterDownload = new()
{
ClearButtonEnabled = false,
Value = SMMM.DownloadValue,
MaxDecimalPlaces = 0,
Maximum = 99999999,
MaxLength = 8,
Minimum = 0
};

AdapterUploadContent.Children.Add(AdapterUploadText);
AdapterUploadContent.Children.Add(AdapterUpload);

AdapterDownloadContent.Children.Add(AdapterDownloadText);
AdapterDownloadContent.Children.Add(AdapterDownload);

AdapterContent.Children.Add(AdapterUploadContent);
AdapterContent.Children.Add(AdapterDownloadContent);

Adapter.FooterCard = AdapterContent;

Contents.Add(Adapter);

_isInitialized = true;
}

Expand Down Expand Up @@ -104,6 +195,14 @@ private void CounterStateChecked(bool State)
}
}

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

public void Dispose()
{
Contents.Clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ private void InitializeViewModel()
{
ClearButtonEnabled = false,
Value = SMMM.StoreDuration,
MaxDecimalPlaces = 0,
MaxLength = 2,
Maximum = 24,
Minimum = 1
Expand Down Expand Up @@ -211,6 +212,7 @@ private void InitializeViewModel()
{
ClearButtonEnabled = false,
Value = SMMM.TitleLength,
MaxDecimalPlaces = 0,
MaxLength = 3,
Maximum = 100,
Minimum = 10
Expand All @@ -237,6 +239,7 @@ private void InitializeViewModel()
{
Value = SMMM.DescriptionLength,
ClearButtonEnabled = false,
MaxDecimalPlaces = 0,
MaxLength = 3,
Maximum = 100,
Minimum = 10
Expand Down Expand Up @@ -286,6 +289,7 @@ private void InitializeViewModel()
{
Value = SMMM.AdaptiveMargin,
ClearButtonEnabled = false,
MaxDecimalPlaces = 0,
MaxLength = 2,
Maximum = 25,
Minimum = 5
Expand All @@ -312,6 +316,7 @@ private void InitializeViewModel()
{
Value = SMMM.AdaptiveLayout,
ClearButtonEnabled = false,
MaxDecimalPlaces = 0,
MaxLength = 3,
Maximum = 100,
Minimum = 0
Expand Down Expand Up @@ -346,6 +351,7 @@ private void InitializeViewModel()
{
Value = SMMM.StorePagination,
ClearButtonEnabled = false,
MaxDecimalPlaces = 0,
MaxLength = 3,
Maximum = 100,
Minimum = 1
Expand All @@ -371,6 +377,7 @@ private void InitializeViewModel()
{
Value = SMMM.LibraryPagination,
ClearButtonEnabled = false,
MaxDecimalPlaces = 0,
MaxLength = 3,
Maximum = 100,
Minimum = 1
Expand Down
82 changes: 82 additions & 0 deletions src/Project/Sucrose.Backgroundog/Extension/Lifecycle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using System.Diagnostics;
using System.Runtime.InteropServices;
using SBMI = Sucrose.Backgroundog.Manage.Internal;

namespace Sucrose.Backgroundog.Extension
{
internal static class Lifecycle
{
public static bool Resume(IntPtr Handle)
{
int Result = NtResumeProcess(Handle);

if (Result == 0)
{
return true;
}
else
{
return false;
}
}

public static bool Resume(Process Process)
{
return Resume(Process.Handle);
}

public static bool Suspend(IntPtr Handle)
{
int Result = NtSuspendProcess(Handle);

if (Result == 0)
{
return true;
}
else
{
return false;
}
}

public static bool Suspend(Process Process)
{
return Suspend(Process.Handle);
}

public static void ResumeThread(Process Process)
{
foreach (ProcessThread Thread in Process.Threads)
{
IntPtr Threading = OpenThread(SBMI.THREAD_SUSPEND_RESUME, false, Thread.Id);

ResumeThread(Threading);
}
}

public static void SuspendThread(Process Process)
{
foreach (ProcessThread Thread in Process.Threads)
{
IntPtr Threading = OpenThread(SBMI.THREAD_SUSPEND_RESUME, false, Thread.Id);

SuspendThread(Threading);
}
}

[DllImport("kernel32.dll")]
private static extern int ResumeThread(IntPtr hThread);

[DllImport("kernel32.dll")]
private static extern uint SuspendThread(IntPtr hThread);

[DllImport("ntdll.dll")]
private static extern int NtResumeProcess(IntPtr ProcessHandle);

[DllImport("ntdll.dll")]
private static extern int NtSuspendProcess(IntPtr ProcessHandle);

[DllImport("kernel32.dll")]
private static extern IntPtr OpenThread(int dwDesiredAccess, bool bInheritHandle, int dwThreadId);
}
}
2 changes: 2 additions & 0 deletions src/Project/Sucrose.Backgroundog/Manage/Internal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ internal static class Internal

public static PerformanceCounter DownloadCounter = null;

public static readonly int THREAD_SUSPEND_RESUME = 0x0002;

public static NowPlayingSessionManager SessionManager = new();

public static SBSDCS CpuData = new()
Expand Down

0 comments on commit 7392f32

Please sign in to comment.