Skip to content

Portable Tool for an Ideal Windows Setup

-fxied update info for ip, correction

Greedeksce04881a6734
diff --git a/.Source/GTweak/Core/ViewModel/MainViewModel.cs b/.Source/GTweak/Core/ViewModel/MainViewModel.cs
index 9cbf033b..766b269f 100644
--- a/.Source/GTweak/Core/ViewModel/MainViewModel.cs
+++ b/.Source/GTweak/Core/ViewModel/MainViewModel.cs
@@ -17,9 +17,9 @@ namespace GTweak.Core.ViewModel
set { _currentView = value; OnPropertyChanged(); }
}
- public ImageSource DisplayProfileAvatar => SystemDiagnostics.GetProfileImage() ?? Application.Current.Resources["DI_AvatarProfile"] as DrawingImage;
+ public ImageSource DisplayProfileAvatar => new SystemDiagnostics().GetProfileImage() ?? Application.Current.Resources["DI_AvatarProfile"] as DrawingImage;
- public string DisplayProfileName => SystemDiagnostics.GetProfileName();
+ public string DisplayProfileName => new SystemDiagnostics().GetProfileName();
public string DisplayTweakVersion => (Assembly.GetEntryAssembly() ?? throw new InvalidOperationException()).GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
diff --git a/.Source/GTweak/Languages/ru/Localize.xaml b/.Source/GTweak/Languages/ru/Localize.xaml
index 2036ab06..925786e2 100644
--- a/.Source/GTweak/Languages/ru/Localize.xaml
+++ b/.Source/GTweak/Languages/ru/Localize.xaml
@@ -338,7 +338,7 @@
<v:String x:Key="tgl4_system">Технология «Гибернация» и «Быстрый запуск»</v:String>
<v:String x:Key="tgl5_system">Окно предупреждения при завершении работы</v:String>
<v:String x:Key="tgl6_system">Автообновление приложений через Microsoft Store</v:String>
- <v:String x:Key="tgl7_system">Задержка появление звука - Realtek Sound driver</v:String>
+ <v:String x:Key="tgl7_system">Задержка появления звука - Realtek Sound driver</v:String>
<v:String x:Key="tgl8_system">Защитник Windows, Antimalware, SmartScreen и VBS</v:String>
<v:String x:Key="tgl9_system">UAC (Контроль учётных записей)</v:String>
<v:String x:Key="tgl10_system">Уведомления о безопасности от Центра уведомлений</v:String>
diff --git a/.Source/GTweak/Utilities/Configuration/MonitoringSystem.cs b/.Source/GTweak/Utilities/Configuration/MonitoringSystem.cs
index e93237e6..e09a9298 100644
--- a/.Source/GTweak/Utilities/Configuration/MonitoringSystem.cs
+++ b/.Source/GTweak/Utilities/Configuration/MonitoringSystem.cs
@@ -7,6 +7,10 @@ namespace GTweak.Utilities.Configuration
{
internal sealed class MonitoringSystem
{
+ internal int GetMemoryUsage => (int)Math.Truncate(100 - ((decimal)GetPhysicalAvailableMemory() / GetTotalMemory() * 100) + (decimal)0.5);
+ internal string GetNumberRunningProcesses => Process.GetProcesses().Length.ToString();
+ internal static int GetProcessorUsage = default;
+
[StructLayout(LayoutKind.Sequential)]
private struct PerformanceInformation
{
@@ -30,7 +34,7 @@ namespace GTweak.Utilities.Configuration
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool GetPerformanceInfo([Out] out PerformanceInformation PerformanceInformation, [In] int Size);
- private static long GetPhysicalAvailableMemory()
+ private long GetPhysicalAvailableMemory()
{
if (GetPerformanceInfo(out PerformanceInformation _performanceInformation, Marshal.SizeOf(new PerformanceInformation())))
return Convert.ToInt64((_performanceInformation.PhysicalAvailable.ToInt64() * _performanceInformation.PageSize.ToInt64() / 1048576));
@@ -38,7 +42,7 @@ namespace GTweak.Utilities.Configuration
return -1;
}
- private static long GetTotalMemory()
+ private long GetTotalMemory()
{
if (GetPerformanceInfo(out PerformanceInformation _performanceInformation, Marshal.SizeOf(new PerformanceInformation())))
return Convert.ToInt64((_performanceInformation.PhysicalTotal.ToInt64() * _performanceInformation.PageSize.ToInt64() / 1048576));
@@ -46,13 +50,7 @@ namespace GTweak.Utilities.Configuration
return -1;
}
- internal int GetMemoryUsage() => (int)Math.Truncate(100 - ((decimal)GetPhysicalAvailableMemory() / GetTotalMemory() * 100) + (decimal)0.5);
-
- internal string GetNumberRunningProcesses => Process.GetProcesses().Length.ToString();
-
- internal static int GetProcessorUsage = default;
-
- internal static async Task<int> GetTotalProcessorUsage()
+ internal async Task<int> GetTotalProcessorUsage()
{
return await Task.Run(async () =>
{
diff --git a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
index 9d06fee5..7db130be 100644
--- a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
+++ b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
@@ -54,7 +54,7 @@ namespace GTweak.Utilities.Configuration
{ "UserIpAddress", Application.Current.Resources["connection_lose_systemInformation"].ToString() }
};
- internal static ImageSource GetProfileImage()
+ internal ImageSource GetProfileImage()
{
try
{
@@ -68,7 +68,7 @@ namespace GTweak.Utilities.Configuration
catch { return null; }
}
- internal static string GetProfileName()
+ internal string GetProfileName()
{
string nameProfile = string.Empty;
foreach (var managementObj in new ManagementObjectSearcher(@"root\cimv2", $"select FullName from Win32_UserAccount where domain='{Environment.UserDomainName}' and name='{Environment.UserName.ToLower()}'").Get())
@@ -91,7 +91,7 @@ namespace GTweak.Utilities.Configuration
);
}
- internal static void GetUpdatingDevices()
+ internal void GetUpdatingDevices()
{
Parallel.Invoke(
GetStorageDevices,
@@ -164,7 +164,7 @@ namespace GTweak.Utilities.Configuration
}
- private static void GetAudioDevices()
+ private void GetAudioDevices()
{
static (bool, string) IsUsbAudioDevice(string deviceID)
{
@@ -205,7 +205,7 @@ namespace GTweak.Utilities.Configuration
HardwareData["Audio"] = HardwareData["Audio"].TrimEnd('\n');
}
- private static void GetNetworkAdapters()
+ private void GetNetworkAdapters()
{
HardwareData["NetAdapter"] = string.Empty;
foreach (var managementObj in new ManagementObjectSearcher(@"root\cimv2", "select Name from Win32_NetworkAdapter where NetConnectionStatus=2 or NetConnectionStatus=7", new EnumerationOptions { ReturnImmediately = true }).Get())
@@ -213,7 +213,7 @@ namespace GTweak.Utilities.Configuration
HardwareData["NetAdapter"] = HardwareData["NetAdapter"].TrimEnd('\n');
}
- private static bool IsNetworkAvailable()
+ private bool IsNetworkAvailable()
{
try
{
@@ -238,7 +238,7 @@ namespace GTweak.Utilities.Configuration
catch { return false; }
}
- internal static async void GetUserIpAddress()
+ internal async void GetUserIpAddress()
{
await Task.Run(async () =>
{
diff --git a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
index 80ea51a9..d345f93b 100644
--- a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
@@ -64,28 +64,24 @@ namespace GTweak.Utilities.Tweaks
try
{
+ using RegistryKey regKey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Class\{4d36e96c-e325-11ce-bfc1-08002be10318}", true);
- using RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Class\{4d36e96c-e325-11ce-bfc1-08002be10318}", true);
+ if (regKey == null) return;
- if (registryKey == null)
- return;
-
- foreach (string keyname in registryKey.GetSubKeyNames())
+ foreach (string keyname in regKey.GetSubKeyNames())
{
- using RegistryKey key = registryKey.OpenSubKey(keyname, true);
- if (key == null) continue;
+ using RegistryKey subkey = regKey.OpenSubKey(keyname, true);
+ if (subkey == null) continue;
- if (key.GetValue("DriverDesc")?.ToString() == "Realtek High Definition Audio")
+ if (subkey.GetValue("DriverDesc")?.ToString() == "Realtek High Definition Audio")
{
- using RegistryKey powerSettingsKey = key.OpenSubKey("PowerSettings", true);
+ using RegistryKey powerKey = subkey.OpenSubKey("PowerSettings", true);
- byte[] conservationIdleTime = powerSettingsKey.GetValue("ConservationIdleTime") as byte[];
- byte[] idlePowerState = powerSettingsKey.GetValue("IdlePowerState") as byte[];
- byte[] performanceIdleTime = powerSettingsKey.GetValue("PerformanceIdleTime") as byte[];
+ byte[] conservationIdleTime = powerKey.GetValue("ConservationIdleTime") as byte[];
+ byte[] idlePowerState = powerKey.GetValue("IdlePowerState") as byte[];
+ byte[] performanceIdleTime = powerKey.GetValue("PerformanceIdleTime") as byte[];
systemV.TglButton7.StateNA = conservationIdleTime?[0].ToString() != "255" || idlePowerState?[0].ToString() != "0" || performanceIdleTime?[0].ToString() != "255";
-
-
}
}
}
diff --git a/.Source/GTweak/View/DataSystemView.xaml.cs b/.Source/GTweak/View/DataSystemView.xaml.cs
index c9df2d03..a8d0dd70 100644
--- a/.Source/GTweak/View/DataSystemView.xaml.cs
+++ b/.Source/GTweak/View/DataSystemView.xaml.cs
@@ -4,7 +4,6 @@ using GTweak.Utilities.Control;
using GTweak.Utilities.Helpers;
using System;
using System.Collections.Generic;
-using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
@@ -32,11 +31,9 @@ namespace GTweak.View
{ SystemDiagnostics.ConnectionStatus.Lose, "connection_lose_systemInformation" },
{ SystemDiagnostics.ConnectionStatus.Block, "connection_block_systemInformation" },
{ SystemDiagnostics.ConnectionStatus.Limited, "limited_systemInformation" }
- }.TryGetValue(SystemDiagnostics.CurrentConnection, out string resourceKey))
- {
- SystemDiagnostics.HardwareData["UserIpAddress"] = (string)FindResource(resourceKey);
- DataContext = new DataSystemVM();
- }
+ }.TryGetValue(SystemDiagnostics.CurrentConnection,
+ out string resourceKey)) { SystemDiagnostics.HardwareData["UserIpAddress"] = (string)FindResource(resourceKey); }
+ DataContext = new DataSystemVM();
};
timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, async delegate
@@ -46,8 +43,8 @@ namespace GTweak.View
BackgroundQueue backgroundQueue = new BackgroundQueue();
await backgroundQueue.QueueTask(async delegate
{
- Parallel.Invoke(SystemDiagnostics.GetUpdatingDevices);
- await MonitoringSystem.GetTotalProcessorUsage();
+ new SystemDiagnostics().GetUpdatingDevices();
+ await new MonitoringSystem().GetTotalProcessorUsage();
});
Application.Current.Dispatcher.Invoke(AnimationProgressBars);
if (BtnHiddenIP.IsChecked.Value & BtnHiddenIP.Visibility == Visibility.Hidden)
@@ -61,7 +58,7 @@ namespace GTweak.View
else if (time.TotalSeconds % 5 == 0)
{
BackgroundQueue backgroundQueue = new BackgroundQueue();
- await backgroundQueue.QueueTask(delegate { SystemDiagnostics.GetUserIpAddress(); });
+ await backgroundQueue.QueueTask(delegate { new SystemDiagnostics().GetUserIpAddress(); });
DataContext = new DataSystemVM();
}
@@ -69,7 +66,7 @@ namespace GTweak.View
}, Application.Current.Dispatcher);
timer.Start();
- RAMLoad.Value = new MonitoringSystem().GetMemoryUsage();
+ RAMLoad.Value = new MonitoringSystem().GetMemoryUsage;
CPULoad.Value = MonitoringSystem.GetProcessorUsage;
}
@@ -92,7 +89,7 @@ namespace GTweak.View
doubleAnim = new DoubleAnimation()
{
From = RAMLoad.Value,
- To = new MonitoringSystem().GetMemoryUsage(),
+ To = new MonitoringSystem().GetMemoryUsage,
EasingFunction = new PowerEase(),
Duration = TimeSpan.FromSeconds(0.2)
};
diff --git a/.Source/GTweak/View/SystemView.xaml.cs b/.Source/GTweak/View/SystemView.xaml.cs
index 4659e8da..46fc9bc0 100644
--- a/.Source/GTweak/View/SystemView.xaml.cs
+++ b/.Source/GTweak/View/SystemView.xaml.cs
@@ -87,8 +87,6 @@ namespace GTweak.View
if (!SystemTweaks.isTweakWorkingAntivirus)
{
SystemTweaks.isTweakWorkingAntivirus = true;
- INIManager.TempTweaksSys.Remove(toggleButton.Name);
- INIManager.TempTweaksSys.Add(toggleButton.Name, Convert.ToString(toggleButton.State));
SystemTweaks.UseSystem(toggleButton.Name, toggleButton.State);
new ViewNotification().Show("", "info", (string)FindResource("windefender_notification"));
}
diff --git a/.Source/GTweak/Windows/ImportWindow.xaml.cs b/.Source/GTweak/Windows/ImportWindow.xaml.cs
index 83c7dd94..ee1954fe 100644
--- a/.Source/GTweak/Windows/ImportWindow.xaml.cs
+++ b/.Source/GTweak/Windows/ImportWindow.xaml.cs
@@ -70,7 +70,7 @@ namespace GTweak.Windows
foreach (var set in acceptanceList)
{
await Task.Delay(700, _token);
- Parallel.Invoke(() => ConfidentialityTweaks.UseСonfidentiality(set.Tweak, Convert.ToBoolean(set.Value)));
+ ConfidentialityTweaks.UseСonfidentiality(set.Tweak, Convert.ToBoolean(set.Value));
switch (set.Tweak)
{
@@ -94,7 +94,7 @@ namespace GTweak.Windows
foreach (var set in acceptanceList)
{
await Task.Delay(700, _token);
- Parallel.Invoke(() => InterfaceTweaks.UseInterface(set.Tweak, Convert.ToBoolean(set.Value)));
+ InterfaceTweaks.UseInterface(set.Tweak, Convert.ToBoolean(set.Value));
switch (set.Tweak)
{
@@ -130,7 +130,7 @@ namespace GTweak.Windows
foreach (var set in acceptanceList)
{
await Task.Delay(700, _token);
- Parallel.Invoke(() => ServicesTweaks.UseServices(set.Tweak, Convert.ToBoolean(set.Value)));
+ ServicesTweaks.UseServices(set.Tweak, Convert.ToBoolean(set.Value));
isRestartNeed = true;
}
}
@@ -151,7 +151,7 @@ namespace GTweak.Windows
if (set.Tweak != "TglButton8")
{
if (set.Tweak.Contains("TglButton"))
- Parallel.Invoke(() => SystemTweaks.UseSystem(set.Tweak, Convert.ToBoolean(set.Value)));
+ SystemTweaks.UseSystem(set.Tweak, Convert.ToBoolean(set.Value));
else
SystemTweaks.UseSystemSliders(set.Tweak, Convert.ToUInt32(set.Value));
diff --git a/.Source/GTweak/Windows/LoadingWindow.xaml.cs b/.Source/GTweak/Windows/LoadingWindow.xaml.cs
index b2e8752f..894f1174 100644
--- a/.Source/GTweak/Windows/LoadingWindow.xaml.cs
+++ b/.Source/GTweak/Windows/LoadingWindow.xaml.cs
@@ -58,7 +58,7 @@ namespace GTweak.Windows
new SystemTweaks().ViewNetshState,
new SystemTweaks().ViewBluetoothStatus);
- await MonitoringSystem.GetTotalProcessorUsage();
+ await new MonitoringSystem().GetTotalProcessorUsage();
}
private void BackgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)