Skip to content

Portable Tool for an Ideal Windows Setup

-re code

Greedeksd0eea73ab55c
diff --git a/.Source/GTweak/Core/ViewModel/DataSystemVM.cs b/.Source/GTweak/Core/ViewModel/DataSystemVM.cs
index ba995807..67eedbab 100644
--- a/.Source/GTweak/Core/ViewModel/DataSystemVM.cs
+++ b/.Source/GTweak/Core/ViewModel/DataSystemVM.cs
@@ -78,7 +78,7 @@ namespace GTweak.Core.ViewModel
public int SetBlurValue
{
get => model.BlurValue;
- set { model.BlurValue = value; OnPropertyChanged("SetBlurValue"); }
+ set { model.BlurValue = value; OnPropertyChanged(); }
}
public Visibility SetVisibility
@@ -98,7 +98,7 @@ namespace GTweak.Core.ViewModel
model = new DataSystemModel();
DisplayWindows = SystemData.СomputerСonfiguration.СonfigurationData["Windows"];
- DisplayNumberProcesses = new SystemData.MonitoringSystem().CountProcess.ToString();
+ DisplayNumberProcesses = new SystemData.MonitoringSystem().GetNumberRunningProcesses;
DisplayBios = !string.IsNullOrEmpty(SystemData.СomputerСonfiguration.СonfigurationData["BIOS"]) ? SystemData.СomputerСonfiguration.СonfigurationData["BIOS"] : (string)Application.Current.Resources["no_device_information_systemInformatin"];
DisplayMotherBr = !string.IsNullOrEmpty(SystemData.СomputerСonfiguration.СonfigurationData["MotherBr"]) ? SystemData.СomputerСonfiguration.СonfigurationData["MotherBr"] : (string)Application.Current.Resources["no_device_information_systemInformatin"];
diff --git a/.Source/GTweak/GTweak.csproj b/.Source/GTweak/GTweak.csproj
index b9782bc2..90ebd595 100644
--- a/.Source/GTweak/GTweak.csproj
+++ b/.Source/GTweak/GTweak.csproj
@@ -266,6 +266,7 @@
<Compile Include="Utilities\Helpers\TakingOwnership.cs" />
<Compile Include="Utilities\Tweaks\ClearingMemory.cs" />
<Compile Include="Utilities\Helpers\INIManager.cs" />
+ <Compile Include="Utilities\UpdatingUtility.cs" />
<Compile Include="Utilities\ViewNotification.cs" />
<Compile Include="Utilities\Helpers\TrustedInstaller.cs" />
<Compile Include="Utilities\Tweaks\ConfidentialityTweaks.cs" />
diff --git a/.Source/GTweak/Utilities/Tweaks/SystemData.cs b/.Source/GTweak/Utilities/Tweaks/SystemData.cs
index 05a08649..d6f762a7 100644
--- a/.Source/GTweak/Utilities/Tweaks/SystemData.cs
+++ b/.Source/GTweak/Utilities/Tweaks/SystemData.cs
@@ -4,7 +4,6 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
-using System.IO;
using System.Management;
using System.Net;
using System.Net.Http;
@@ -19,7 +18,7 @@ namespace GTweak.Utilities.Tweaks
{
internal sealed class SystemData
{
- internal struct ProfileData
+ internal sealed class ProfileData
{
internal static ImageSource GetProfileImage()
{
@@ -45,8 +44,10 @@ namespace GTweak.Utilities.Tweaks
}
}
- internal struct MonitoringSystem
+ internal class MonitoringSystem
{
+ internal static int PercentageProcessorUsage = 1;
+
[StructLayout(LayoutKind.Sequential)]
private struct PerformanceInformation
{
@@ -66,11 +67,6 @@ namespace GTweak.Utilities.Tweaks
internal int ThreadCount;
}
- internal readonly int CountProcess => GetCountProcess();
- internal static int CpuUsage = 1;
- internal readonly int RamUsage => GetRamUsage();
-
-
[DllImport("psapi.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool GetPerformanceInfo([Out] out PerformanceInformation PerformanceInformation, [In] int Size);
@@ -91,29 +87,29 @@ namespace GTweak.Utilities.Tweaks
return -1;
}
- internal readonly int GetCountProcess()
- {
- Process[] countProcess = Process.GetProcesses();
- return countProcess.Length;
- }
+ internal string GetNumberRunningProcesses => Process.GetProcesses().Length.ToString();
- internal readonly void GetCpuUsage()
+ internal async void GetProcessorUsage()
{
- Parallel.Invoke(async () =>
- {
- PerformanceCounter cpuCounter = new PerformanceCounter("Processor Information", "% Processor Utility", "_Total", true);
- cpuCounter.NextValue();
- await Task.Delay(1000);
- CpuUsage = (int)cpuCounter.NextValue();
- });
+ PerformanceCounter cpuCounter = new PerformanceCounter("Processor Information", "% Processor Utility", "_Total", true);
+ cpuCounter.NextValue();
+ await Task.Delay(1000);
+ PercentageProcessorUsage = (int)cpuCounter.NextValue();
}
- internal readonly int GetRamUsage() => (int)Math.Truncate(100 - ((decimal)GetPhysicalAvailableMemory() / GetTotalMemory() * 100) + (decimal)0.5);
+ internal int GetMemoryUsage() => (int)Math.Truncate(100 - ((decimal)GetPhysicalAvailableMemory() / GetTotalMemory() * 100) + (decimal)0.5);
}
- internal sealed class СomputerСonfiguration
+ internal class СomputerСonfiguration
{
- internal static string WindowsClientVersion { get; set; } = string.Empty;
+ internal sealed class ClientInternetProtocol
+ {
+ [JsonProperty("query")]
+ internal string Ip { get; set; }
+
+ [JsonProperty("countryCode")]
+ internal string Country { get; set; }
+ }
/// <summary>
/// No connection problems - [0];
@@ -123,6 +119,8 @@ namespace GTweak.Utilities.Tweaks
/// </summary>
internal static byte ConnectionStatus = 1;
+ internal static string WindowsClientVersion { get; set; } = string.Empty;
+
internal static readonly Dictionary<string, string> СonfigurationData = new Dictionary<string, string>()
{
{"Windows", Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName", string.Empty).ToString() },
@@ -137,7 +135,7 @@ namespace GTweak.Utilities.Tweaks
{"UserIpAddress", (string)Application.Current.Resources["connection_lose_systemInformation"] }
};
- internal void GetСonfigurationComputer()
+ internal void GetConfiguration()
{
Parallel.Invoke(delegate
{
@@ -228,14 +226,6 @@ namespace GTweak.Utilities.Tweaks
});
}
- internal sealed class ClientInternetProtocol
- {
- [JsonProperty("query")]
- internal string Ip { get; set; }
-
- [JsonProperty("countryCode")]
- internal string Country { get; set; }
- }
internal static bool IsNetworkAvailable()
{
@@ -302,40 +292,5 @@ namespace GTweak.Utilities.Tweaks
});
}
}
-
- internal sealed class UtilityСonfiguration
- {
- internal static bool IsNeedUpdate { get; set; } = false;
- internal static string DownloadVersion { get; set; } = string.Empty;
-
- internal sealed class GitVersionUtility
- {
- [JsonProperty("tag_name")]
- internal string СurrentVersion { get; set; }
- }
-
- internal void CheckingUpdate()
- {
- if (!Settings.IsСheckingUpdate)
- return;
-
- if (!(WebRequest.Create("https://api.github.com/repos/greedeks/gtweak/releases/latest") is HttpWebRequest webRequest))
- return;
-
- webRequest.ContentType = "application/json";
- webRequest.UserAgent = "Nothing";
-
- using StreamReader sreader = new StreamReader(webRequest.GetResponse().GetResponseStream());
- string DataAsJson = sreader.ReadToEnd();
- GitVersionUtility gitVersionUtility = JsonConvert.DeserializeObject<GitVersionUtility>(DataAsJson);
-
-
- if (!string.IsNullOrEmpty(gitVersionUtility.СurrentVersion) && gitVersionUtility.СurrentVersion.CompareTo(Settings.currentRelease) > 0)
- {
- IsNeedUpdate = true;
- DownloadVersion = gitVersionUtility.СurrentVersion;
- }
- }
- }
}
}
diff --git a/.Source/GTweak/Utilities/UpdatingUtility.cs b/.Source/GTweak/Utilities/UpdatingUtility.cs
new file mode 100644
index 00000000..044f7464
--- /dev/null
+++ b/.Source/GTweak/Utilities/UpdatingUtility.cs
@@ -0,0 +1,41 @@
+using Newtonsoft.Json;
+using System.IO;
+using System.Net;
+
+namespace GTweak.Utilities
+{
+ internal class UpdatingUtility
+ {
+ internal class GitVersionUtility
+ {
+ [JsonProperty("tag_name")]
+ internal string СurrentVersion { get; set; }
+ }
+
+ internal static bool IsNeedUpdate { get; set; } = false;
+ internal static string DownloadVersion { get; set; } = string.Empty;
+
+ internal void CheckingUpdate()
+ {
+ if (!Settings.IsСheckingUpdate)
+ return;
+
+ if (!(WebRequest.Create("https://api.github.com/repos/greedeks/gtweak/releases/latest") is HttpWebRequest webRequest))
+ return;
+
+ webRequest.ContentType = "application/json";
+ webRequest.UserAgent = "Nothing";
+
+ using StreamReader sreader = new StreamReader(webRequest.GetResponse().GetResponseStream());
+ string DataAsJson = sreader.ReadToEnd();
+ GitVersionUtility gitVersionUtility = JsonConvert.DeserializeObject<GitVersionUtility>(DataAsJson);
+
+
+ if (!string.IsNullOrEmpty(gitVersionUtility.СurrentVersion) && gitVersionUtility.СurrentVersion.CompareTo(Settings.currentRelease) > 0)
+ {
+ IsNeedUpdate = true;
+ DownloadVersion = gitVersionUtility.СurrentVersion;
+ }
+ }
+ }
+}
diff --git a/.Source/GTweak/View/DataSystemView.xaml.cs b/.Source/GTweak/View/DataSystemView.xaml.cs
index 48c8baef..55a2f2bd 100644
--- a/.Source/GTweak/View/DataSystemView.xaml.cs
+++ b/.Source/GTweak/View/DataSystemView.xaml.cs
@@ -50,12 +50,11 @@ namespace GTweak.View
await backgroundQueue.QueueTask(delegate
{
Parallel.Invoke(SystemData.СomputerСonfiguration.UpdatingDeviceData);
- Thread _thread = new Thread(() => { new SystemData.MonitoringSystem().GetCpuUsage(); }) { IsBackground = true };
+ Thread _thread = new Thread(() => { new SystemData.MonitoringSystem().GetProcessorUsage(); }) { IsBackground = true };
_thread.Start();
});
backgroundQueue.QueueCompleted(delegate
{
- Thread _thread = new Thread(() => { new SystemData.MonitoringSystem().CountProcess.ToString(); }) { IsBackground = true };
Application.Current.Dispatcher.Invoke(AnimationProgressBars);
if (BtnHiddenIP.IsChecked.Value & BtnHiddenIP.Visibility == Visibility.Hidden)
@@ -87,7 +86,7 @@ namespace GTweak.View
DoubleAnimation doubleAnim = new DoubleAnimation()
{
From = CPULoad.Value,
- To = SystemData.MonitoringSystem.CpuUsage,
+ To = SystemData.MonitoringSystem.PercentageProcessorUsage,
EasingFunction = new PowerEase(),
Duration = TimeSpan.FromSeconds(0.2)
};
@@ -98,7 +97,7 @@ namespace GTweak.View
doubleAnim = new DoubleAnimation()
{
From = RAMLoad.Value,
- To = new SystemData.MonitoringSystem().RamUsage,
+ To = new SystemData.MonitoringSystem().GetMemoryUsage(),
EasingFunction = new PowerEase(),
Duration = TimeSpan.FromSeconds(0.2)
};
@@ -176,11 +175,11 @@ namespace GTweak.View
private void Page_Loaded(object sender, RoutedEventArgs e)
{
- Thread _thread = new Thread(() => { new SystemData.MonitoringSystem().GetCpuUsage(); }) { IsBackground = true };
-
- RAMLoad.Value = new SystemData.MonitoringSystem().RamUsage;
- CPULoad.Value = SystemData.MonitoringSystem.CpuUsage;
-
+ Parallel.Invoke(delegate
+ {
+ CPULoad.Value = SystemData.MonitoringSystem.PercentageProcessorUsage;
+ RAMLoad.Value = new SystemData.MonitoringSystem().GetMemoryUsage();
+ });
}
}
}
diff --git a/.Source/GTweak/Windows/LoadingWindow.xaml.cs b/.Source/GTweak/Windows/LoadingWindow.xaml.cs
index 8323e728..0e628c25 100644
--- a/.Source/GTweak/Windows/LoadingWindow.xaml.cs
+++ b/.Source/GTweak/Windows/LoadingWindow.xaml.cs
@@ -51,8 +51,8 @@ namespace GTweak.Windows
new Settings().СheckingParameters,
new Settings().CheckingTempFiles,
new WindowsLicense().LicenseStatus,
- new SystemData.СomputerСonfiguration().GetСonfigurationComputer,
- new SystemData.UtilityСonfiguration().CheckingUpdate,
+ new SystemData.СomputerСonfiguration().GetConfiguration,
+ new UpdatingUtility().CheckingUpdate,
new UninstallingPakages().ViewInstalledPackages,
new UninstallingPakages().CheckingForLocalAccount,
new SystemTweaks().ViewNetshState,
diff --git a/.Source/GTweak/Windows/MainWindow.xaml.cs b/.Source/GTweak/Windows/MainWindow.xaml.cs
index c8f33481..34e5ba0c 100644
--- a/.Source/GTweak/Windows/MainWindow.xaml.cs
+++ b/.Source/GTweak/Windows/MainWindow.xaml.cs
@@ -122,7 +122,7 @@ namespace GTweak
};
doubleAnim.Completed += async delegate
{
- if (SystemData.UtilityСonfiguration.IsNeedUpdate && Settings.IsСheckingUpdate)
+ if (UpdatingUtility.IsNeedUpdate && Settings.IsСheckingUpdate)
{
await Task.Delay(500);
new UpdateWindow().ShowDialog();
diff --git a/.Source/GTweak/Windows/UpdateWindow.xaml.cs b/.Source/GTweak/Windows/UpdateWindow.xaml.cs
index 3e58af9b..06671fb0 100644
--- a/.Source/GTweak/Windows/UpdateWindow.xaml.cs
+++ b/.Source/GTweak/Windows/UpdateWindow.xaml.cs
@@ -15,7 +15,7 @@ namespace GTweak.Windows
{
InitializeComponent();
CurrentVerison.Text = Settings.currentRelease;
- DownloadVersion.Text = NewVerison.Text = Utilities.Tweaks.SystemData.UtilityСonfiguration.DownloadVersion;
+ DownloadVersion.Text = NewVerison.Text = UpdatingUtility.DownloadVersion;
}
private void TitleBar_MouseDown(object sender, MouseButtonEventArgs e)