Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
ref. move hardware and network logic to separate providers
Greedeks61584e52f90b
diff --git a/.Source/GTweak/App.xaml.cs b/.Source/GTweak/App.xaml.csindex f60c5fc4..f58d37cd 100644--- a/.Source/GTweak/App.xaml.cs+++ b/.Source/GTweak/App.xaml.cs@@ -17,7 +17,7 @@ namespace GTweakinternal static event EventHandler ThemeChanged;internal static event EventHandler TweaksImported;- private readonly SystemDataCollector _systemDataCollector = new SystemDataCollector();+ private readonly HardwareProvider _hardwareProvider = new HardwareProvider();internal static void UpdateImport() => TweaksImported?.Invoke(default, EventArgs.Empty);@@ -27,7 +27,7 @@ namespace GTweakDispatcherUnhandledException += OnDispatcherUnhandledException;AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;- _systemDataCollector.HandleDevicesEvents += OnHandleDevicesEvents;+ _hardwareProvider.HandleDevicesEvents += OnHandleDevicesEvents;}private async void App_Startup(object sender, StartupEventArgs e)@@ -45,7 +45,7 @@ namespace GTweakawait RunGuard.CheckingSystemRequirements();RunGuard.CheckingAdministratorPrivileges();- await _systemDataCollector.StartDeviceMonitoring();+ await _hardwareProvider.StartDeviceMonitoring();new LoadingWindow().Show();}@@ -70,10 +70,10 @@ namespace GTweakEnvironment.Exit(0);}- private async void OnHandleDevicesEvents(MonitoringService.DeviceType deviceType)+ private async void OnHandleDevicesEvents(MonitoringProvider.DeviceType deviceType){BackgroundQueue backgroundQueue = new BackgroundQueue();- await backgroundQueue.QueueTask(delegate { _systemDataCollector.RefreshDevicesData(deviceType); });+ await backgroundQueue.QueueTask(delegate { _hardwareProvider.RefreshDevicesData(deviceType); });}private static Uri GetResourceUri(string folder, bool isTheme = false) => isTheme ? new Uri($"Styles/Themes/{folder}/Colors.xaml", UriKind.Relative) : new Uri($"Languages/{folder}/Localize.xaml", UriKind.Relative);@@ -82,7 +82,7 @@ namespace GTweak{set{- var (code, region) = SystemDataCollector.GetCurrentSystemLang();+ var (code, region) = HardwareProvider.GetCurrentSystemLang();value ??= $"{code}-{region}";@@ -132,7 +132,7 @@ namespace GTweakprotected override void OnExit(ExitEventArgs e){- _systemDataCollector?.StopDeviceMonitoring();+ _hardwareProvider?.StopDeviceMonitoring();base.OnExit(e);}}diff --git a/.Source/GTweak/Core/ViewModel/DataSystemViewModel.cs b/.Source/GTweak/Core/ViewModel/DataSystemViewModel.csindex 9cb6600d..3c0da45a 100644--- a/.Source/GTweak/Core/ViewModel/DataSystemViewModel.cs+++ b/.Source/GTweak/Core/ViewModel/DataSystemViewModel.cs@@ -86,8 +86,8 @@ namespace GTweak.Core.ViewModelCreateModelCollection("IpAddress", HardwareData.UserIPAddress, "connection_lose_sysinfo")};- SetBlurValue = (SystemDataCollector.isIPAddressFormatValid && SettingsEngine.IsHiddenIpAddress) ? 20 : 0;- SetVisibility = SystemDataCollector.isIPAddressFormatValid ? Visibility.Visible : Visibility.Hidden;+ SetBlurValue = (NetworkProvider.isIPAddressFormatValid && SettingsEngine.IsHiddenIpAddress) ? 20 : 0;+ SetVisibility = NetworkProvider.isIPAddressFormatValid ? Visibility.Visible : Visibility.Hidden;}private DataSystemModel CreateModelCollection(string name, object data, string fallbackResourceKey = null)diff --git a/.Source/GTweak/Core/ViewModel/MainWinViewModel.cs b/.Source/GTweak/Core/ViewModel/MainWinViewModel.csindex fd7055bf..4d394095 100644--- a/.Source/GTweak/Core/ViewModel/MainWinViewModel.cs+++ b/.Source/GTweak/Core/ViewModel/MainWinViewModel.cs@@ -19,7 +19,7 @@ namespace GTweak.Core.ViewModelpublic ObservableCollection<MainWinModel.LanguageItem> Languages { get; } = new ObservableCollection<MainWinModel.LanguageItem>();private readonly MainWinModel _model = new MainWinModel();- private readonly SystemDataCollector _systemDataCollector = new SystemDataCollector();+ private readonly HardwareProvider _hardwareProvider = new HardwareProvider();public object CurrentView{@@ -27,9 +27,9 @@ namespace GTweak.Core.ViewModelset { _model.CurrentView = value; OnPropertyChanged(); }}- public ImageSource DisplayProfileAvatar => _systemDataCollector.GetProfileImage();+ public ImageSource DisplayProfileAvatar => _hardwareProvider.GetProfileImage();- public string DisplayProfileName => _systemDataCollector.GetProfileName();+ public string DisplayProfileName => _hardwareProvider.GetProfileName();public string DisplayTweakVersion => (Assembly.GetEntryAssembly() ?? throw new InvalidOperationException()).GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;@@ -45,7 +45,7 @@ namespace GTweak.Core.ViewModelpublic string CurrentVersion => SettingsEngine.currentRelease;- public string DownloadVersion => SystemDataCollector.DownloadVersion;+ public string DownloadVersion => HardwareProvider.DownloadVersion;public bool IsViewNotification => SettingsEngine.IsViewNotification;diff --git a/.Source/GTweak/GTweak.csproj b/.Source/GTweak/GTweak.csprojindex e40b6525..e5f3ec3d 100644--- a/.Source/GTweak/GTweak.csproj+++ b/.Source/GTweak/GTweak.csproj@@ -159,6 +159,7 @@<Compile Include="Core\ViewModel\PackagesViewModel.cs" /><Compile Include="Core\ViewModel\ServicesViewModel.cs" /><Compile Include="Core\ViewModel\SystemViewModel.cs" />+ <Compile Include="Utilities\Configuration\NetworkProvider.cs" /><Compile Include="Utilities\Configuration\StorageTypeIdentifier.cs" /><Compile Include="Utilities\Configuration\HardwareData.cs" /><Compile Include="Utilities\Helpers\UnlockHandleHelper.cs" />@@ -428,8 +429,8 @@<Compile Include="Utilities\Animation\FactoryAnimation.cs" /><Compile Include="Utilities\Animation\NumberAnimation.cs" /><Compile Include="Utilities\Animation\TypewriterAnimation.cs" />- <Compile Include="Utilities\Configuration\MonitoringService.cs" />- <Compile Include="Utilities\Configuration\SystemDataCollector.cs" />+ <Compile Include="Utilities\Configuration\MonitoringProvider.cs" />+ <Compile Include="Utilities\Configuration\HardwareProvider.cs" /><Compile Include="Utilities\Controls\ErrorLogging.cs" /><Compile Include="Utilities\Controls\PathLocator.cs" /><Compile Include="Utilities\Controls\RunGuard.cs" />diff --git a/.Source/GTweak/Utilities/Configuration/SystemDataCollector.cs b/.Source/GTweak/Utilities/Configuration/HardwareProvider.cssimilarity index 78%rename from .Source/GTweak/Utilities/Configuration/SystemDataCollector.csrename to .Source/GTweak/Utilities/Configuration/HardwareProvider.csindex b56e4f96..d008b987 100644--- a/.Source/GTweak/Utilities/Configuration/SystemDataCollector.cs+++ b/.Source/GTweak/Utilities/Configuration/HardwareProvider.cs@@ -1,11 +1,8 @@using System;-using System.Collections.Generic;using System.Globalization;using System.IO;using System.Linq;using System.Management;-using System.Net;-using System.Net.Http;using System.Security.Principal;using System.Text;using System.Text.RegularExpressions;@@ -16,49 +13,12 @@ using System.Windows.Media.Imaging;using GTweak.Utilities.Controls;using GTweak.Utilities.Helpers;using Microsoft.Win32;-using Newtonsoft.Json;-using Newtonsoft.Json.Linq;namespace GTweak.Utilities.Configuration{- internal sealed class SystemDataCollector : MonitoringService+ internal sealed class HardwareProvider : NetworkProvider{- private class GitMetadata- {- [JsonProperty("tag_name")]- internal string CurrentVersion { get; set; }- }-- private sealed class GitLabMetadata : GitMetadata- {- [JsonProperty("description")]- internal string Description { get; set; }- }-- private sealed class IPMetadata- {- internal string Ip { get; set; }- internal string Country { get; set; }-- internal static IPMetadata ParseData(string response)- {- if (!string.IsNullOrWhiteSpace(response))- {- JObject jObject = JObject.Parse(response);- string ip = jObject["ip"]?.ToString() ?? jObject["ipAddress"]?.ToString() ?? jObject["query"]?.ToString() ?? string.Empty;- string country = jObject["country_code"]?.ToString() ?? jObject["countryCode"]?.ToString() ?? string.Empty;- return new IPMetadata { Ip = ip, Country = country };- }- return new IPMetadata { Ip = string.Empty, Country = string.Empty };- }- }-- private static readonly HttpClient sharedClient = new HttpClient { Timeout = TimeSpan.FromSeconds(5) };-- internal static bool IsNeedUpdate { get; private set; } = false;- internal static string DownloadVersion { get; private set; } = string.Empty;-- internal static bool isIPAddressFormatValid = false, isMsftAvailable = false;+ internal static bool isMsftAvailable = false;internal static (string Code, string Region) GetCurrentSystemLang(){@@ -611,170 +571,5 @@ namespace GTweak.Utilities.Configurationreturn result.ToString().TrimEnd('\n', '\r');}-- internal async Task<bool> IsNetworkAvailable()- {- string dns = GetCurrentSystemLang().Code switch- {- "fa" => "aparat.com",- "zh" => "baidu.com",- "ru" => "yandex.ru",- "kk" => "yandex.kz",- "ko" => "naver.com",- "cs" => "seznam.cz",- "tk" => "turkmenportal.com",- "vi" => "fpt.vn",- "es" => "terra.es",- "ja" => "yahoo.co.jp",- "de" => "t-online.de",- "fr" => "orange.fr",- "it" => "libero.it",- "th" => "true.th",- "pl" => "wp.pl",- "nl" => "nu.nl",- "pt" => "globo.com",- "sv" => "aftonbladet.se",- "no" => "vg.no",- "fi" => "yle.fi",- "ro" => "digisport.ro",- "gr" => "in.gr",- "id" => "detik.com",- "mx" => "univision.com",- "ar" => "claro.com.ar",- string name when new[] { "tr", "hi", "ar" }.Contains(name) => "bing.com",- _ => "google.com"- };-- Task<IPHostEntry> dnsTask = Dns.GetHostEntryAsync(dns);- Task timeoutTask = Task.Delay(TimeSpan.FromSeconds(5));-- if (await Task.WhenAny(dnsTask, timeoutTask) == timeoutTask) { return false; }-- try- {- IPHostEntry entry = await dnsTask;- return entry?.AddressList?.Length > 0;- }- catch { return false; }- }-- internal async Task GetUserIpAddress()- {- if (await IsNetworkAvailable())- {- bool hadLimited = false, hadBlock = false;-- foreach (string url in PathLocator.Links.IpServices)- {- try- {- using HttpResponseMessage response = await sharedClient.GetAsync(url);-- if (!response.IsSuccessStatusCode)- {- hadBlock = true;- continue;- }-- string content = await response.Content.ReadAsStringAsync();- IPMetadata ipMetadata = IPMetadata.ParseData(content);-- if (ipMetadata != null && !string.IsNullOrWhiteSpace(ipMetadata.Ip) && !string.IsNullOrWhiteSpace(ipMetadata.Country) && IPAddress.TryParse(ipMetadata.Ip, out _))- {- CurrentConnection = ConnectionStatus.Available;- UserIPAddress = $"{ipMetadata.Ip} ({ipMetadata.Country})";- break;- }-- hadBlock = true;- }- catch { hadLimited = true; }- }-- if (CurrentConnection != ConnectionStatus.Available)- {- if (hadLimited)- {- CurrentConnection = ConnectionStatus.Limited;- }- else if (hadBlock)- {- CurrentConnection = ConnectionStatus.Block;- }- else- {- CurrentConnection = ConnectionStatus.Lose;- }- }- }- else- {- CurrentConnection = ConnectionStatus.Lose;- }-- if (new Dictionary<ConnectionStatus, string>- {- { ConnectionStatus.Lose, "connection_lose_sysinfo" },- { ConnectionStatus.Block, "connection_block_sysinfo" },- { ConnectionStatus.Limited, "connection_limited_sysinfo" }- }.TryGetValue(CurrentConnection, out string resourceKey)) { UserIPAddress = (string)Application.Current.Resources[resourceKey]; }-- isIPAddressFormatValid = UserIPAddress.Any(char.IsDigit);- }-- internal async Task ValidateVersionUpdates()- {- if (SettingsEngine.IsUpdateCheckRequired && await IsNetworkAvailable())- {- foreach (string api in PathLocator.Links.ReleaseApi)- {- try- {- HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(api);- webRequest.ContentType = "application/json";- webRequest.UserAgent = "Nothing";- webRequest.Timeout = 5000;-- using HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();- using StreamReader reader = new StreamReader(response.GetResponseStream());- string json = reader.ReadToEnd();- GitMetadata latest = null;-- if (api.Contains("github"))- {- latest = JsonConvert.DeserializeObject<GitMetadata>(json);- }- else- {- List<GitLabMetadata> releases = JsonConvert.DeserializeObject<List<GitLabMetadata>>(json);- latest = releases?.FirstOrDefault();-- if (latest != null && !string.IsNullOrEmpty(((GitLabMetadata)latest).Description))- {- GitLabMetadata gitLabMetadata = (GitLabMetadata)latest;- Match match = Regex.Match(gitLabMetadata.Description, @"\[(?<name>.*?)\]\(/uploads/(?<hash>.+?)\)");-- if (match.Success)- {- string hashFile = match.Groups["hash"].Value;- PathLocator.Links.GitLabLatest = (true, $"{PathLocator.Links.GitLabLatest.Url}{hashFile}");- }- }- }-- if (latest != null && !string.IsNullOrWhiteSpace(latest.CurrentVersion))- {- if (new Version(latest.CurrentVersion) > new Version(SettingsEngine.currentRelease))- {- IsNeedUpdate = true;- DownloadVersion = latest.CurrentVersion;- break;- }- }- }- catch { continue; }- }- }- }}}diff --git a/.Source/GTweak/Utilities/Configuration/MonitoringService.cs b/.Source/GTweak/Utilities/Configuration/MonitoringProvider.cssimilarity index 96%rename from .Source/GTweak/Utilities/Configuration/MonitoringService.csrename to .Source/GTweak/Utilities/Configuration/MonitoringProvider.csindex dc6f93d0..8172c3c8 100644--- a/.Source/GTweak/Utilities/Configuration/MonitoringService.cs+++ b/.Source/GTweak/Utilities/Configuration/MonitoringProvider.cs@@ -11,7 +11,7 @@ using GTweak.Utilities.Controls;namespace GTweak.Utilities.Configuration{- internal class MonitoringService : HardwareData+ internal class MonitoringProvider : HardwareData{internal event Action<DeviceType> HandleDevicesEvents;private readonly List<(ManagementEventWatcher watcher, EventArrivedEventHandler handler)> _watcherHandler = new List<(ManagementEventWatcher watcher, EventArrivedEventHandler handler)>();@@ -181,7 +181,7 @@ namespace GTweak.Utilities.Configuration{await Task.WhenAll(new List<(string filter, DeviceType type, string scope)>{- ($"TargetInstance ISA {(SystemDataCollector.isMsftAvailable ? "'MSFT_PhysicalDisk'" : "'Win32_DiskDrive'")}", DeviceType.Storage, SystemDataCollector.isMsftAvailable ? @"root\microsoft\windows\storage" : null),+ ($"TargetInstance ISA {(HardwareProvider.isMsftAvailable ? "'MSFT_PhysicalDisk'" : "'Win32_DiskDrive'")}", DeviceType.Storage, HardwareProvider.isMsftAvailable ? @"root\microsoft\windows\storage" : null),("TargetInstance ISA 'Win32_SoundDevice'", DeviceType.Audio, null),("TargetInstance ISA 'Win32_NetworkAdapter' AND TargetInstance.NetConnectionStatus IS NOT NULL", DeviceType.Network, null)}.Select(device => Task.Run(() => SubscribeToDeviceEvents(device.filter, device.type, device.scope))).ToArray());diff --git a/.Source/GTweak/Utilities/Configuration/NetworkProvider.cs b/.Source/GTweak/Utilities/Configuration/NetworkProvider.csnew file mode 100644index 00000000..2479128b--- /dev/null+++ b/.Source/GTweak/Utilities/Configuration/NetworkProvider.cs@@ -0,0 +1,219 @@+using System;+using System.Collections.Generic;+using System.Linq;+using System.Net;+using System.Net.Http;+using System.Text.RegularExpressions;+using System.Threading.Tasks;+using System.Windows;+using GTweak.Utilities.Controls;+using Newtonsoft.Json;+using Newtonsoft.Json.Linq;++namespace GTweak.Utilities.Configuration+{+ internal class NetworkProvider : MonitoringProvider+ {+ private class GitMetadata+ {+ [JsonProperty("tag_name")]+ internal string CurrentVersion { get; set; }+ }++ private sealed class GitLabMetadata : GitMetadata+ {+ [JsonProperty("description")]+ internal string Description { get; set; }+ }++ private sealed class IPMetadata+ {+ internal string Ip { get; set; }+ internal string Country { get; set; }++ internal static IPMetadata ParseData(string response)+ {+ if (!string.IsNullOrWhiteSpace(response))+ {+ JObject jObject = JObject.Parse(response);+ string ip = jObject["ip"]?.ToString() ?? jObject["ipAddress"]?.ToString() ?? jObject["query"]?.ToString() ?? string.Empty;+ string country = jObject["country_code"]?.ToString() ?? jObject["countryCode"]?.ToString() ?? string.Empty;+ return new IPMetadata { Ip = ip, Country = country };+ }+ return new IPMetadata { Ip = string.Empty, Country = string.Empty };+ }+ }++ private static readonly HttpClient sharedClient = new HttpClient { Timeout = TimeSpan.FromSeconds(5) };++ internal static bool IsNeedUpdate { get; private set; } = false;+ internal static string DownloadVersion { get; private set; } = string.Empty;++ internal static bool isIPAddressFormatValid = false;++ internal async Task<bool> IsNetworkAvailable()+ {+ string dns = HardwareProvider.GetCurrentSystemLang().Code switch+ {+ "fa" => "aparat.com",+ "zh" => "baidu.com",+ "ru" => "yandex.ru",+ "kk" => "yandex.kz",+ "ko" => "naver.com",+ "cs" => "seznam.cz",+ "tk" => "turkmenportal.com",+ "vi" => "fpt.vn",+ "es" => "terra.es",+ "ja" => "yahoo.co.jp",+ "de" => "t-online.de",+ "fr" => "orange.fr",+ "it" => "libero.it",+ "th" => "true.th",+ "pl" => "wp.pl",+ "nl" => "nu.nl",+ "pt" => "globo.com",+ "sv" => "aftonbladet.se",+ "no" => "vg.no",+ "fi" => "yle.fi",+ "ro" => "digisport.ro",+ "gr" => "in.gr",+ "id" => "detik.com",+ "mx" => "univision.com",+ "tr" => "bing.com",+ "hi" => "bing.com",+ "ar" => "bing.com",+ _ => "google.com"+ };++ Task<IPHostEntry> dnsTask = Dns.GetHostEntryAsync(dns);+ Task timeoutTask = Task.Delay(TimeSpan.FromSeconds(5));++ if (await Task.WhenAny(dnsTask, timeoutTask) == timeoutTask) { return false; }++ try+ {+ IPHostEntry entry = await dnsTask;+ return entry?.AddressList?.Length > 0;+ }+ catch { return false; }+ }++ internal async Task GetUserIpAddress()+ {+ if (await IsNetworkAvailable())+ {+ bool hadLimited = false, hadBlock = false;++ foreach (string url in PathLocator.Links.IpServices)+ {+ try+ {+ using HttpResponseMessage response = await sharedClient.GetAsync(url);++ if (!response.IsSuccessStatusCode)+ {+ hadBlock = true;+ continue;+ }++ string content = await response.Content.ReadAsStringAsync();+ IPMetadata ipMetadata = IPMetadata.ParseData(content);++ if (ipMetadata != null && !string.IsNullOrWhiteSpace(ipMetadata.Ip) && !string.IsNullOrWhiteSpace(ipMetadata.Country) && IPAddress.TryParse(ipMetadata.Ip, out _))+ {+ CurrentConnection = ConnectionStatus.Available;+ UserIPAddress = $"{ipMetadata.Ip} ({ipMetadata.Country})";+ break;+ }++ hadBlock = true;+ }+ catch { hadLimited = true; }+ }++ if (CurrentConnection != ConnectionStatus.Available)+ {+ if (hadLimited)+ {+ CurrentConnection = ConnectionStatus.Limited;+ }+ else if (hadBlock)+ {+ CurrentConnection = ConnectionStatus.Block;+ }+ else+ {+ CurrentConnection = ConnectionStatus.Lose;+ }+ }+ }+ else+ {+ CurrentConnection = ConnectionStatus.Lose;+ }++ if (new Dictionary<ConnectionStatus, string>+ {+ { ConnectionStatus.Lose, "connection_lose_sysinfo" },+ { ConnectionStatus.Block, "connection_block_sysinfo" },+ { ConnectionStatus.Limited, "connection_limited_sysinfo" }+ }.TryGetValue(CurrentConnection, out string resourceKey)) { UserIPAddress = (string)Application.Current.Resources[resourceKey]; }++ isIPAddressFormatValid = UserIPAddress.Any(char.IsDigit);+ }++ internal async Task ValidateVersionUpdates()+ {+ if (SettingsEngine.IsUpdateCheckRequired && await IsNetworkAvailable())+ {+ foreach (string api in PathLocator.Links.ReleaseApi)+ {+ try+ {+ using HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, api);+ request.Headers.Add("User-Agent", "GTweak");+ request.Headers.Add("Accept", "application/json");++ using HttpResponseMessage response = await sharedClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);+ response.EnsureSuccessStatusCode();++ string json = await response.Content.ReadAsStringAsync();+ GitMetadata latest = null;++ if (api.Contains("github"))+ {+ latest = JsonConvert.DeserializeObject<GitMetadata>(json);+ }+ else+ {+ List<GitLabMetadata> releases = JsonConvert.DeserializeObject<List<GitLabMetadata>>(json);+ latest = releases?.FirstOrDefault();++ if (latest is GitLabMetadata gitLabMetadata && !string.IsNullOrEmpty(gitLabMetadata.Description))+ {+ Match match = Regex.Match(gitLabMetadata.Description, @"\[(?<name>.*?)\]\(/uploads/(?<hash>.+?)\)");++ if (match.Success)+ {+ string hashFile = match.Groups["hash"].Value;+ PathLocator.Links.GitLabLatest = (true, $"{PathLocator.Links.GitLabLatest.Url}{hashFile}");+ }+ }+ }++ if (latest != null && !string.IsNullOrWhiteSpace(latest.CurrentVersion))+ {+ if (new Version(latest.CurrentVersion) > new Version(SettingsEngine.currentRelease))+ {+ IsNeedUpdate = true;+ DownloadVersion = latest.CurrentVersion;+ break;+ }+ }+ }+ catch { continue; }+ }+ }+ }+ }+}\ No newline at end of filediff --git a/.Source/GTweak/Utilities/Controls/RunGuard.cs b/.Source/GTweak/Utilities/Controls/RunGuard.csindex 15bdc2f9..02282f13 100644--- a/.Source/GTweak/Utilities/Controls/RunGuard.cs+++ b/.Source/GTweak/Utilities/Controls/RunGuard.cs@@ -50,7 +50,7 @@ namespace GTweak.Utilities.Controlsinternal static async Task CheckingSystemRequirements(){- await Task.Run(() => new SystemDataCollector().GetOperatingSystemInfo());+ await Task.Run(() => new HardwareProvider().GetOperatingSystemInfo());if ((HardwareData.OS.IsWin11 || HardwareData.OS.IsWin10) && HardwareData.OS.Build.CompareTo(18362.116m) >= 0){diff --git a/.Source/GTweak/Utilities/Controls/SettingsEngine.cs b/.Source/GTweak/Utilities/Controls/SettingsEngine.csindex 5dd24487..b7b22478 100644--- a/.Source/GTweak/Utilities/Controls/SettingsEngine.cs+++ b/.Source/GTweak/Utilities/Controls/SettingsEngine.cs@@ -34,7 +34,7 @@ namespace GTweak.Utilities.Controls["EnableIpBlur"] = true,["EnableSound"] = true,["VolumeLevel"] = 50,- ["Language"] = SystemDataCollector.GetCurrentSystemLang().Code,+ ["Language"] = HardwareProvider.GetCurrentSystemLang().Code,["Theme"] = AvailableThemes.First(),["AddonsPath"] = string.Empty,};diff --git a/.Source/GTweak/View/DataSystemView.xaml.cs b/.Source/GTweak/View/DataSystemView.xaml.csindex ae3230ba..f5743eb4 100644--- a/.Source/GTweak/View/DataSystemView.xaml.cs+++ b/.Source/GTweak/View/DataSystemView.xaml.cs@@ -20,7 +20,7 @@ namespace GTweak.View{public partial class DataSystemView : UserControl, IViewPageBase{- private readonly SystemDataCollector _systemDataCollector = new SystemDataCollector();+ private readonly HardwareProvider _hardwareProvider = new HardwareProvider();private readonly BackgroundQueue backgroundQueue = new BackgroundQueue();private TimerControlManager _timer = default;@@ -63,8 +63,8 @@ namespace GTweak.Viewif ((int)time.TotalSeconds % 2 == 0){- await backgroundQueue.QueueTask(async delegate { await _systemDataCollector.GetTotalProcessorUsage(); });- await backgroundQueue.QueueTask(async delegate { await _systemDataCollector.GetPhysicalAvailableMemory(); });+ await backgroundQueue.QueueTask(async delegate { await _hardwareProvider.GetTotalProcessorUsage(); });+ await backgroundQueue.QueueTask(async delegate { await _hardwareProvider.GetPhysicalAvailableMemory(); });_ = Dispatcher.BeginInvoke(new Action(() =>{AnimateArcProgress(CPULoad, HardwareData.Processor.Usage);@@ -72,18 +72,18 @@ namespace GTweak.View}));_ = Dispatcher.BeginInvoke(new Action(async () =>{- HardwareData.RunningProcessesCount = await Task.Run(() => _systemDataCollector.GetProcessCount());- HardwareData.RunningServicesCount = await Task.Run(() => _systemDataCollector.GetServicesCount());+ HardwareData.RunningProcessesCount = await Task.Run(() => _hardwareProvider.GetProcessCount());+ HardwareData.RunningServicesCount = await Task.Run(() => _hardwareProvider.GetServicesCount());}));}else if ((int)time.TotalSeconds % 5 == 0){- await backgroundQueue.QueueTask(async delegate { await _systemDataCollector.GetUserIpAddress(); });+ await backgroundQueue.QueueTask(async delegate { await _hardwareProvider.GetUserIpAddress(); });_ = Dispatcher.BeginInvoke(new Action(() => { DataContext = new DataSystemViewModel(); }));}_ = Dispatcher.BeginInvoke(new Action(() =>{- if (BtnVision.IsChecked.Value & BtnVision.Visibility == Visibility.Hidden & !SystemDataCollector.isIPAddressFormatValid)+ if (BtnVision.IsChecked.Value & BtnVision.Visibility == Visibility.Hidden & !NetworkProvider.isIPAddressFormatValid){IpAddress.Effect.BeginAnimation(BlurEffect.RadiusProperty, FactoryAnimation.CreateTo(0.18, () => { SettingsEngine.IsHiddenIpAddress = false; }));}diff --git a/.Source/GTweak/View/UtilsView.xaml.cs b/.Source/GTweak/View/UtilsView.xaml.csindex 3b3c7f0e..7b49f28b 100644--- a/.Source/GTweak/View/UtilsView.xaml.cs+++ b/.Source/GTweak/View/UtilsView.xaml.cs@@ -33,7 +33,7 @@ namespace GTweak.View}else{- if (await new SystemDataCollector().IsNetworkAvailable())+ if (await new NetworkProvider().IsNetworkAvailable()){await WinLicenseHandler.StartActivation();}diff --git a/.Source/GTweak/Windows/LoadingWindow.xaml.cs b/.Source/GTweak/Windows/LoadingWindow.xaml.csindex de814393..46933164 100644--- a/.Source/GTweak/Windows/LoadingWindow.xaml.cs+++ b/.Source/GTweak/Windows/LoadingWindow.xaml.cs@@ -14,7 +14,7 @@ namespace GTweak.Windows{public partial class LoadingWindow : FluentWindow{- private readonly SystemDataCollector _systemDataCollector = new SystemDataCollector();+ private readonly HardwareProvider _hardwareProvider = new HardwareProvider();private readonly UninstallingPakages _uninstallingPakages = new UninstallingPakages();public LoadingWindow()@@ -54,17 +54,17 @@ namespace GTweak.WindowsExecuteWithLogging(TrustedInstaller.StartTrustedInstallerService, nameof(TrustedInstaller.StartTrustedInstallerService));ExecuteWithLogging(WinLicenseHandler.LicenseStatus, nameof(WinLicenseHandler.LicenseStatus));- ExecuteWithLogging(_systemDataCollector.GetHardwareData, nameof(_systemDataCollector.GetHardwareData));+ ExecuteWithLogging(_hardwareProvider.GetHardwareData, nameof(_hardwareProvider.GetHardwareData));ExecuteWithLogging(_uninstallingPakages.GetInstalledPackages, nameof(_uninstallingPakages.GetInstalledPackages));ExecuteWithLogging(UninstallingPakages.CheckingForLocalAccount, nameof(UninstallingPakages.CheckingForLocalAccount));ExecuteWithLogging(SystemTweaks.ViewNetshState, nameof(SystemTweaks.ViewNetshState));ExecuteWithLogging(SystemTweaks.ViewBluetoothStatus, nameof(SystemTweaks.ViewBluetoothStatus));ExecuteWithLogging(SystemTweaks.ViewConfigTick, nameof(SystemTweaks.ViewConfigTick));- ExecuteWithLogging(() => HardwareData.RunningProcessesCount = _systemDataCollector.GetProcessCount().GetAwaiter().GetResult(), nameof(_systemDataCollector.GetProcessCount));- ExecuteWithLogging(() => HardwareData.RunningServicesCount = _systemDataCollector.GetServicesCount().GetAwaiter().GetResult(), nameof(_systemDataCollector.GetServicesCount));- ExecuteWithLogging(() => _systemDataCollector.ValidateVersionUpdates().GetAwaiter().GetResult(), nameof(_systemDataCollector.ValidateVersionUpdates));- ExecuteWithLogging(() => _systemDataCollector.GetTotalProcessorUsage().GetAwaiter().GetResult(), nameof(_systemDataCollector.GetTotalProcessorUsage));- ExecuteWithLogging(() => _systemDataCollector.GetPhysicalAvailableMemory().GetAwaiter().GetResult(), nameof(_systemDataCollector.GetPhysicalAvailableMemory));+ ExecuteWithLogging(() => HardwareData.RunningProcessesCount = _hardwareProvider.GetProcessCount().GetAwaiter().GetResult(), nameof(_hardwareProvider.GetProcessCount));+ ExecuteWithLogging(() => HardwareData.RunningServicesCount = _hardwareProvider.GetServicesCount().GetAwaiter().GetResult(), nameof(_hardwareProvider.GetServicesCount));+ ExecuteWithLogging(() => _hardwareProvider.ValidateVersionUpdates().GetAwaiter().GetResult(), nameof(_hardwareProvider.ValidateVersionUpdates));+ ExecuteWithLogging(() => _hardwareProvider.GetTotalProcessorUsage().GetAwaiter().GetResult(), nameof(_hardwareProvider.GetTotalProcessorUsage));+ ExecuteWithLogging(() => _hardwareProvider.GetPhysicalAvailableMemory().GetAwaiter().GetResult(), nameof(_hardwareProvider.GetPhysicalAvailableMemory));ExecuteWithLogging(RunGuard.CheckingDefenderExclusions, nameof(RunGuard.CheckingDefenderExclusions));}diff --git a/.Source/GTweak/Windows/MainWindow.xaml.cs b/.Source/GTweak/Windows/MainWindow.xaml.csindex b479ac78..f286ed10 100644--- a/.Source/GTweak/Windows/MainWindow.xaml.cs+++ b/.Source/GTweak/Windows/MainWindow.xaml.cs@@ -254,7 +254,7 @@ namespace GTweak.Windows{TypewriterAnimation.Create(TitleName.Text, TitleName, TimeSpan.FromSeconds(0.4));- if (SystemDataCollector.IsNeedUpdate && SettingsEngine.IsUpdateCheckRequired)+ if (NetworkProvider.IsNeedUpdate && SettingsEngine.IsUpdateCheckRequired){await Task.Delay(500);diff --git a/.Source/GTweak/Windows/UpdateWindow.xaml.cs b/.Source/GTweak/Windows/UpdateWindow.xaml.csindex 8e7ff3be..06058795 100644--- a/.Source/GTweak/Windows/UpdateWindow.xaml.cs+++ b/.Source/GTweak/Windows/UpdateWindow.xaml.cs@@ -12,7 +12,7 @@ namespace GTweak.Windows{public partial class UpdateWindow : FluentWindow{- public string DownloadVersion { get; set; } = SystemDataCollector.DownloadVersion;+ public string DownloadVersion { get; set; } = HardwareProvider.DownloadVersion;public UpdateWindow(){