Skip to content

Portable Tool for an Ideal Windows Setup

-replacing the standard Registry class & re

Greedeks0e2bad4572d0
diff --git a/.Source/GTweak/Utilities/Control/SettingsRepository.cs b/.Source/GTweak/Utilities/Control/SettingsRepository.cs
index 54a06f62..902dbc00 100644
--- a/.Source/GTweak/Utilities/Control/SettingsRepository.cs
+++ b/.Source/GTweak/Utilities/Control/SettingsRepository.cs
@@ -13,13 +13,13 @@ using System.Windows;
namespace GTweak.Utilities.Control
{
[StructLayout(LayoutKind.Sequential)]
- internal readonly struct UsePath
+ internal readonly struct StoragePaths
{
internal static string Config = string.Empty;
- internal static string FileLocation => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"GTweak");
+ internal static string FolderLocation => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"GTweak");
internal static string SystemDisk => Path.GetPathRoot(Environment.GetFolderPath(Environment.SpecialFolder.System));
- internal static string Hosts => Path.Combine(Environment.SystemDirectory, @"drivers\etc\hosts");
- internal static string RegLocation = @"HKEY_CURRENT_USER\Software\GTweak";
+ internal static string HostsFile => Path.Combine(Environment.SystemDirectory, @"drivers\etc\hosts");
+ internal static string RegistryLocation = @"HKEY_CURRENT_USER\Software\GTweak";
}
internal sealed class SettingsRepository
@@ -34,14 +34,14 @@ namespace GTweak.Utilities.Control
private static readonly Dictionary<string, Action> parameterUpdates = new Dictionary<string, Action>
{
- { "Notification", () => IsViewNotification = RegistryHelp.GetValue(UsePath.RegLocation, "Notification", IsViewNotification) },
- { "Update", () => IsСheckingUpdate = RegistryHelp.GetValue(UsePath.RegLocation, "Update", IsСheckingUpdate) },
- { "TopMost", () => IsTopMost = RegistryHelp.GetValue(UsePath.RegLocation, "TopMost", IsTopMost) },
- { "Sound", () => IsPlayingSound = RegistryHelp.GetValue(UsePath.RegLocation, "Sound", IsPlayingSound) },
- { "Volume", () => Volume = RegistryHelp.GetValue(UsePath.RegLocation, "Volume", Volume) },
- { "Language", () => Language = RegistryHelp.GetValue(UsePath.RegLocation, "Language", Language) },
- { "Theme", () => Theme = RegistryHelp.GetValue(UsePath.RegLocation, "Theme", Theme) },
- { "HiddenIP", () => IsHiddenIpAddress = RegistryHelp.GetValue(UsePath.RegLocation, "HiddenIP", IsHiddenIpAddress) }
+ { "Notification", () => IsViewNotification = RegistryHelp.GetValue(StoragePaths.RegistryLocation, "Notification", IsViewNotification) },
+ { "Update", () => IsСheckingUpdate = RegistryHelp.GetValue(StoragePaths.RegistryLocation, "Update", IsСheckingUpdate) },
+ { "TopMost", () => IsTopMost = RegistryHelp.GetValue(StoragePaths.RegistryLocation, "TopMost", IsTopMost) },
+ { "Sound", () => IsPlayingSound = RegistryHelp.GetValue(StoragePaths.RegistryLocation, "Sound", IsPlayingSound) },
+ { "Volume", () => Volume = RegistryHelp.GetValue(StoragePaths.RegistryLocation, "Volume", Volume) },
+ { "Language", () => Language = RegistryHelp.GetValue(StoragePaths.RegistryLocation, "Language", Language) },
+ { "Theme", () => Theme = RegistryHelp.GetValue(StoragePaths.RegistryLocation, "Theme", Theme) },
+ { "HiddenIP", () => IsHiddenIpAddress = RegistryHelp.GetValue(StoragePaths.RegistryLocation, "HiddenIP", IsHiddenIpAddress) }
};
internal static readonly Dictionary<string, object> defaultRegValues = new Dictionary<string, object>
@@ -71,7 +71,7 @@ namespace GTweak.Utilities.Control
foreach (var key in defaultRegValues.Keys)
{
- if (Registry.GetValue(UsePath.RegLocation, key, null) == null)
+ if (RegistryHelp.ValueExists(StoragePaths.RegistryLocation, key))
{
isRegistryEmpty = true;
break;
@@ -115,12 +115,12 @@ namespace GTweak.Utilities.Control
try
{
- UsePath.Config = Path.GetDirectoryName(saveFileDialog.FileName) + @"\" + Path.GetFileNameWithoutExtension(saveFileDialog.FileName) + ".ini";
+ StoragePaths.Config = Path.GetDirectoryName(saveFileDialog.FileName) + @"\" + Path.GetFileNameWithoutExtension(saveFileDialog.FileName) + ".ini";
- if (File.Exists(UsePath.Config))
- File.Delete(UsePath.Config);
+ if (File.Exists(StoragePaths.Config))
+ File.Delete(StoragePaths.Config);
- INIManager iniManager = new INIManager(UsePath.Config);
+ INIManager iniManager = new INIManager(StoragePaths.Config);
iniManager.Write("GTweak", "Author", "Greedeks");
iniManager.Write("GTweak", "Release", currentRelease);
iniManager.WriteAll(INIManager.SectionConf, INIManager.TempTweaksConf);
@@ -143,12 +143,12 @@ namespace GTweak.Utilities.Control
if (isResultNormal != true) return;
- UsePath.Config = openFileDialog.FileName;
- INIManager iniManager = new INIManager(UsePath.Config);
+ StoragePaths.Config = openFileDialog.FileName;
+ INIManager iniManager = new INIManager(StoragePaths.Config);
if (iniManager.GetKeysOrValue("GTweak", false).Contains("Greedeks") && iniManager.GetKeysOrValue("GTweak").Contains("Release"))
{
- if (File.ReadLines(UsePath.Config).Any(line => line.Contains("TglButton")) || File.ReadLines(UsePath.Config).Any(line => line.Contains("Slider")))
+ if (File.ReadLines(StoragePaths.Config).Any(line => line.Contains("TglButton")) || File.ReadLines(StoragePaths.Config).Any(line => line.Contains("Slider")))
new ImportWindow(openFileDialog.SafeFileName).ShowDialog();
else
new ViewNotification().Show("", "info", (string)Application.Current.Resources["import_empty_notification"]);
@@ -168,7 +168,7 @@ namespace GTweak.Utilities.Control
Process.Start(new ProcessStartInfo()
{
Arguments = $"/c taskkill /f /im {currentName} & choice /c y /n /d y /t 3 & del {new FileInfo(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath).Name} & " +
- @$"rd /s /q {UsePath.FileLocation} & rd /s /q {Environment.SystemDirectory}\config\systemprofile\AppData\Local\GTweak",
+ @$"rd /s /q {StoragePaths.FolderLocation} & rd /s /q {Environment.SystemDirectory}\config\systemprofile\AppData\Local\GTweak",
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true,
FileName = "cmd.exe"
diff --git a/.Source/GTweak/Utilities/Control/ViewNotification.cs b/.Source/GTweak/Utilities/Control/ViewNotification.cs
index 5cac1eac..49c5b307 100644
--- a/.Source/GTweak/Utilities/Control/ViewNotification.cs
+++ b/.Source/GTweak/Utilities/Control/ViewNotification.cs
@@ -11,36 +11,29 @@ namespace GTweak.Utilities.Control
internal ViewNotification(int delay = 100) => msec = delay;
- internal void Show(string action, string tittle = "", string content = "")
+ internal async void Show(string action, string tittle = "", string content = "")
{
- if (SettingsRepository.IsViewNotification)
+ if (SettingsRepository.IsViewNotification && !isAlreadyLaunch)
{
- Application.Current.Dispatcher.Invoke(delegate
+ await Application.Current.Dispatcher.InvokeAsync(async delegate
{
- Parallel.Invoke(async delegate
- {
- NotificationWindow notificationWindow = new NotificationWindow();
-
- if (notificationWindow.IsLoaded || isAlreadyLaunch)
- return;
-
- isAlreadyLaunch = true;
+ isAlreadyLaunch = true;
- notificationWindow = new NotificationWindow
+ NotificationWindow notificationWindow = new NotificationWindow
+ {
+ TitleNotice = tittle switch
{
- TitleNotice = tittle switch
- {
- "warn" => (string)Application.Current.Resources["title_warn_notification"],
- "info" => (string)Application.Current.Resources["title_info_notification"],
- _ => string.Empty,
- },
- TextNotice = content,
- ActionNotice = action,
- };
- await Task.Delay(msec);
- notificationWindow.Show();
- notificationWindow.Closed += delegate { isAlreadyLaunch = false; };
- });
+ "warn" => (string)Application.Current.Resources["title_warn_notification"],
+ "info" => (string)Application.Current.Resources["title_info_notification"],
+ _ => string.Empty,
+ },
+ TextNotice = content,
+ ActionNotice = action,
+ };
+
+ await Task.Delay(msec);
+ notificationWindow.Show();
+ notificationWindow.Closed += delegate { isAlreadyLaunch = false; };
});
}
}
diff --git a/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs b/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs
index 2bfbd9a6..3c15f4f2 100644
--- a/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs
+++ b/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs
@@ -90,12 +90,18 @@ namespace GTweak.Utilities.Helpers
});
}
- internal static bool CheckExists(in RegistryKey registrykey, in string subkey, in bool isNegation = true)
+ internal static bool KeyExists(in RegistryKey registrykey, in string subkey, in bool isNegation = true)
{
bool result = registrykey.OpenSubKey(subkey) != null;
return isNegation ? result : !result;
}
+ internal static bool ValueExists(string subKey, string valueName, in bool isNegation = true)
+ {
+ bool result = Registry.GetValue(subKey, valueName, null) == null;
+ return isNegation ? result : !result;
+ }
+
internal static bool CheckValue(in string subkey, in string valueName, in string expectedValue, in bool isNegation = true)
{
string value = Registry.GetValue(subkey, valueName, null)?.ToString();
diff --git a/.Source/GTweak/Utilities/Tweaks/ClearingMemory.cs b/.Source/GTweak/Utilities/Tweaks/ClearingMemory.cs
index 95c9fc4e..d9035856 100644
--- a/.Source/GTweak/Utilities/Tweaks/ClearingMemory.cs
+++ b/.Source/GTweak/Utilities/Tweaks/ClearingMemory.cs
@@ -179,7 +179,7 @@ namespace GTweak.Utilities.Tweaks
{
Process.Start(new ProcessStartInfo()
{
- Arguments = @$"/c rd /s /q {UsePath.SystemDisk}Windows\Temp & rd /s /q %localappdata%\Temp",
+ Arguments = @$"/c rd /s /q {StoragePaths.SystemDisk}Windows\Temp & rd /s /q %localappdata%\Temp",
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true,
FileName = "cmd.exe"
diff --git a/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs b/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs
index 1fc50e13..97a19d34 100644
--- a/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs
@@ -73,8 +73,8 @@ namespace GTweak.Utilities.Tweaks
RegistryHelp.CheckValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PolicyManager\current\device\System", "AllowExperimentation", "0");
confidentialityV.TglButton15.StateNA =
- RegistryHelp.CheckExists(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\DiagTrack") ||
- RegistryHelp.CheckExists(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\dmwappushservice");
+ RegistryHelp.KeyExists(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\DiagTrack") ||
+ RegistryHelp.KeyExists(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\dmwappushservice");
confidentialityV.TglButton16.StateNA =
RegistryHelp.CheckValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\diagnosticshub.standardcollector.service", "Start", "4");
@@ -93,7 +93,7 @@ namespace GTweak.Utilities.Tweaks
{
byte numberHostsRules = 0;
- using (StreamReader streamReader = new StreamReader(UsePath.Hosts))
+ using (StreamReader streamReader = new StreamReader(StoragePaths.HostsFile))
{
string hosts = streamReader.ReadToEnd();
numberHostsRules += (byte)(new string[] {
@@ -197,7 +197,7 @@ namespace GTweak.Utilities.Tweaks
case "TglButton9":
Task.Run(delegate
{
- string backupFile = UsePath.Hosts + @" (Default GTweak)";
+ string backupFile = StoragePaths.HostsFile + @" (Default GTweak)";
try
{
if (isChoose)
@@ -205,12 +205,12 @@ namespace GTweak.Utilities.Tweaks
if (File.Exists(backupFile))
File.Delete(backupFile);
- File.Move(UsePath.Hosts, backupFile);
- new UnarchiveManager(UsePath.Hosts, Resources.hosts);
+ File.Move(StoragePaths.HostsFile, backupFile);
+ new UnarchiveManager(StoragePaths.HostsFile, Resources.hosts);
}
else
{
- File.Copy(backupFile, UsePath.Hosts, true);
+ File.Copy(backupFile, StoragePaths.HostsFile, true);
if (File.Exists(backupFile))
File.Delete(backupFile);
diff --git a/.Source/GTweak/Utilities/Tweaks/Firewall.cs b/.Source/GTweak/Utilities/Tweaks/Firewall.cs
index 35210e9e..cb72e711 100644
--- a/.Source/GTweak/Utilities/Tweaks/Firewall.cs
+++ b/.Source/GTweak/Utilities/Tweaks/Firewall.cs
@@ -21,10 +21,10 @@ namespace GTweak.Utilities.Tweaks
private static readonly SortedList<string, string> PathsForPrograms = new SortedList<string, string>
{
- ["MoUso_New"] = string.Concat(UsePath.SystemDisk, @"Windows\UUS\amd64\MoUsoCoreWorker.exe"),
- ["MoUso_Old"] = string.Concat(UsePath.SystemDisk, @"Windows\System32\MoUsoCoreWorker.exe"),
- ["Uso"] = string.Concat(UsePath.SystemDisk, @"Windows\System32\usoclient.exe"),
- ["WD"] = string.Concat(UsePath.SystemDisk, @"Program Files\Windows Defender\MpCmdRun.exe"),
+ ["MoUso_New"] = string.Concat(StoragePaths.SystemDisk, @"Windows\UUS\amd64\MoUsoCoreWorker.exe"),
+ ["MoUso_Old"] = string.Concat(StoragePaths.SystemDisk, @"Windows\System32\MoUsoCoreWorker.exe"),
+ ["Uso"] = string.Concat(StoragePaths.SystemDisk, @"Windows\System32\usoclient.exe"),
+ ["WD"] = string.Concat(StoragePaths.SystemDisk, @"Program Files\Windows Defender\MpCmdRun.exe"),
};
private static bool CheckRulesWindows(string nameRule)
diff --git a/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs b/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs
index def318e2..8b7c3c2a 100644
--- a/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/InterfaceTweaks.cs
@@ -68,7 +68,7 @@ namespace GTweak.Utilities.Tweaks
SystemDiagnostics.WindowsClientVersion.Contains("11") && RegistryHelp.CheckValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Start_Layout", "1");
interfaceV.TglButton17.StateNA =
- SystemDiagnostics.WindowsClientVersion.Contains("11") && RegistryHelp.CheckExists(Registry.CurrentUser, @"Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32", false);
+ SystemDiagnostics.WindowsClientVersion.Contains("11") && RegistryHelp.KeyExists(Registry.CurrentUser, @"Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32", false);
interfaceV.TglButton18.StateNA =
SystemDiagnostics.WindowsClientVersion.Contains("11") &&
@@ -138,16 +138,16 @@ namespace GTweak.Utilities.Tweaks
RegistryHelp.CheckValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\\PushNotifications", "ToastEnabled", "0"));
interfaceV.TglButton25.StateNA =
- RegistryHelp.CheckExists(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{088e3905-0323-4b02-9826-5d99428e115f}") ||
- RegistryHelp.CheckExists(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{24ad3ad4-a569-4530-98e1-ab02f9417aa8}") ||
- RegistryHelp.CheckExists(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{3dfdf296-dbec-4fb4-81d1-6a3438bcf4de}") ||
- RegistryHelp.CheckExists(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}") ||
- RegistryHelp.CheckExists(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{d3162b92-9365-467a-956b-92703aca08af}") ||
- RegistryHelp.CheckExists(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{f86fa3ab-70d2-4fc7-9c99-fcbf05467f3a}");
+ RegistryHelp.KeyExists(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{088e3905-0323-4b02-9826-5d99428e115f}") ||
+ RegistryHelp.KeyExists(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{24ad3ad4-a569-4530-98e1-ab02f9417aa8}") ||
+ RegistryHelp.KeyExists(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{3dfdf296-dbec-4fb4-81d1-6a3438bcf4de}") ||
+ RegistryHelp.KeyExists(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}") ||
+ RegistryHelp.KeyExists(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{d3162b92-9365-467a-956b-92703aca08af}") ||
+ RegistryHelp.KeyExists(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{f86fa3ab-70d2-4fc7-9c99-fcbf05467f3a}");
interfaceV.TglButton26.StateNA =
- RegistryHelp.CheckExists(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}") ||
- RegistryHelp.CheckExists(Registry.LocalMachine, @"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}");
+ RegistryHelp.KeyExists(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}") ||
+ RegistryHelp.KeyExists(Registry.LocalMachine, @"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}");
interfaceV.TglButton27.StateNA =
RegistryHelp.CheckValue(@"HKEY_CURRENT_USER\Control Panel\Desktop", "JPEGImportQuality", "100");
diff --git a/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs b/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs
index 3df78efb..84db08fa 100644
--- a/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs
@@ -28,10 +28,10 @@ namespace GTweak.Utilities.Tweaks
private static string PathsWinUUP(string program, bool isOldWay = false)
{
- string path = isOldWay ? string.Concat(UsePath.SystemDisk, @"Windows\System32\") : string.Concat(UsePath.SystemDisk, @"Windows\UUS\amd64\");
+ string path = isOldWay ? string.Concat(StoragePaths.SystemDisk, @"Windows\System32\") : string.Concat(StoragePaths.SystemDisk, @"Windows\UUS\amd64\");
if (program == "Uso" || program == "Re_Uso")
- return string.Concat(string.Concat(UsePath.SystemDisk, @"Windows\System32\"), ProgramsUUP[program]);
+ return string.Concat(string.Concat(StoragePaths.SystemDisk, @"Windows\System32\"), ProgramsUUP[program]);
else
return string.Concat(path, ProgramsUUP[program]);
}
@@ -415,7 +415,7 @@ namespace GTweak.Utilities.Tweaks
{
Task.Run(delegate
{
- string cachePath = Path.Combine(UsePath.SystemDisk, @"Windows\SoftwareDistribution\Download");
+ string cachePath = Path.Combine(StoragePaths.SystemDisk, @"Windows\SoftwareDistribution\Download");
string[] WinUpdateTasks = new string[] {
@"Microsoft\Windows\UpdateOrchestrator\Report policies",
diff --git a/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.cs b/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.cs
index b9685a7c..6f2f621e 100644
--- a/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.cs
+++ b/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.cs
@@ -113,7 +113,7 @@ namespace GTweak.Utilities.Tweaks
foreach (var managementObj in new ManagementObjectSearcher(@"\\localhost\root\default", "SELECT SequenceNumber FROM SystemRestore", new EnumerationOptions { ReturnImmediately = true }).Get())
SRRemoveRestorePoint(Convert.ToInt32(managementObj["SequenceNumber"].ToString()));
- DisableSR(UsePath.SystemDisk + @"\\");
+ DisableSR(StoragePaths.SystemDisk + @"\\");
}
else
new ViewNotification().Show("", "info", (string)Application.Current.Resources["warndisable_recovery_notification"]);
diff --git a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
index 0d6423ec..55d4b356 100644
--- a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
@@ -125,8 +125,8 @@ namespace GTweak.Utilities.Tweaks
systemV.TglButton17.StateNA =
RegistryHelp.CheckValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers", "DisableAutoplay", "1");
- systemV.TglButton18.StateNA = !Registry.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\" + activeGuid + "", "Description", string.Empty).ToString().Contains("-18") &&
- !Registry.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\" + activeGuid + "", "FriendlyName", string.Empty).ToString().Contains("-19");
+ systemV.TglButton18.StateNA = !RegistryHelp.GetValue($@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\{activeGuid}", "Description", string.Empty).Contains("-18") &&
+ !RegistryHelp.GetValue($@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\{activeGuid}", "FriendlyName", string.Empty).Contains("-19");
systemV.TglButton19.StateNA = isBluetoothStatus;
@@ -354,16 +354,8 @@ namespace GTweak.Utilities.Tweaks
SetPowercfg(isChoose);
break;
case "TglButton19":
- if (isChoose)
- {
- BluetoothStatusSet();
- isBluetoothStatus = false;
- }
- else
- {
- BluetoothStatusSet("'on'");
- isBluetoothStatus = true;
- }
+ BluetoothStatusSet(isChoose ? "'off'" : "'on'");
+ isBluetoothStatus = !isChoose;
break;
case "TglButton20":
RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\mpssvc", "Start", isChoose ? 4 : 2, RegistryValueKind.DWord);
@@ -387,13 +379,12 @@ namespace GTweak.Utilities.Tweaks
}
}
- private static void BluetoothStatusSet(string status = "'off'")
+ private static void BluetoothStatusSet(string status)
{
Task.Run(() =>
{
- ProcessStartInfo startInfo = new ProcessStartInfo
+ Process.Start(new ProcessStartInfo()
{
- FileName = @"powershell.exe",
Arguments = @"Add-Type -AssemblyName System.Runtime.WindowsRuntime
$asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0]
Function Await($WinRtTask, $ResultType) {
@@ -409,12 +400,10 @@ namespace GTweak.Utilities.Tweaks
$bluetooth = $radios | ? { $_.Kind -eq 'Bluetooth' }
[Windows.Devices.Radios.RadioState,Windows.System.Devices,ContentType=WindowsRuntime] | Out-Null
Await ($bluetooth.SetStateAsync(" + status + ")) ([Windows.Devices.Radios.RadioAccessStatus]) | Out-Null",
- UseShellExecute = false,
- CreateNoWindow = true
- };
- using Process process = new Process() { StartInfo = startInfo };
- process.Start();
- process.Close();
+ WindowStyle = ProcessWindowStyle.Hidden,
+ CreateNoWindow = true,
+ FileName = "powershell.exe"
+ });
});
}
@@ -434,7 +423,7 @@ namespace GTweak.Utilities.Tweaks
string serchScheme = default,
unlockFrequency = @"-attributes SUB_PROCESSOR 75b0ae3f-bce0-45a7-8c89-c9611c25e100 -ATTRIB_HIDE",
- pathTempFile = UsePath.FileLocation + @"\UltimatePerformance.pow";
+ pathTempFile = StoragePaths.FolderLocation + @"\UltimatePerformance.pow";
try
{
@@ -444,8 +433,9 @@ namespace GTweak.Utilities.Tweaks
{
serchScheme = Convert.ToString(managementObj["InstanceID"]);
serchScheme = Regex.Match(serchScheme, @"\{([^)]*)\}").Groups[1].Value;
- if (Registry.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\" + serchScheme + "", "Description", string.Empty).ToString().Contains("-18") &&
- Registry.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\" + serchScheme + "", "FriendlyName", string.Empty).ToString().Contains("-19"))
+
+ if (RegistryHelp.GetValue($@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\{serchScheme}", "Description", string.Empty).Contains("-18") &&
+ RegistryHelp.GetValue($@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\{serchScheme}", "FriendlyName", string.Empty).Contains("-19"))
{
using (_powercfg)
{
@@ -480,7 +470,7 @@ namespace GTweak.Utilities.Tweaks
Process.Start(new ProcessStartInfo()
{
- Arguments = $"/c timeout /t 10 && rd /s /q {UsePath.FileLocation}",
+ Arguments = $"/c timeout /t 10 && rd /s /q {StoragePaths.FolderLocation}",
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true,
FileName = "cmd.exe"
@@ -489,7 +479,7 @@ namespace GTweak.Utilities.Tweaks
}
else
{
- string activeScheme = @"Microsoft:PowerPlan\\{" + Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes").GetValue("ActivePowerScheme").ToString() + "}";
+ string activeScheme = @"Microsoft:PowerPlan\\{" + RegistryHelp.GetValue($@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\{serchScheme}", "ActivePowerScheme", string.Empty) + "}";
foreach (var managementObj in new ManagementObjectSearcher(@"root\cimv2\power", "SELECT InstanceID FROM Win32_PowerPlan WHERE InstanceID !='" + activeScheme + "'").Get())
serchScheme = Convert.ToString(managementObj["InstanceID"]);
diff --git a/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs b/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs
index 99c3fe8e..fbea2dd5 100644
--- a/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs
+++ b/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs
@@ -14,7 +14,7 @@ namespace GTweak.Utilities.Tweaks
internal static bool IsOneDriveInstalled => File.Exists(Environment.ExpandEnvironmentVariables(@"%userprofile%\AppData\Local\Microsoft\OneDrive\OneDrive.exe"));
private static bool isLocalAccount = false;
- private static readonly string pathPackage = $@"{UsePath.SystemDisk}Program Files\WindowsApps";
+ private static readonly string pathPackage = $@"{StoragePaths.SystemDisk}Program Files\WindowsApps";
#region Lists packages
internal static Dictionary<string, bool> IsAppUnavailable = new Dictionary<string, bool>
@@ -219,7 +219,7 @@ namespace GTweak.Utilities.Tweaks
}
string argumentsFolders = $@"/c rd /s /q %userprofile%\AppData\Local\Microsoft\OneDrive & rd /s /q %userprofile%\AppData\Local\OneDrive
- & rd /s /q ""%allusersprofile%\Microsoft OneDrive"" & rd /s /q {UsePath.SystemDisk}\OneDriveTemp";
+ & rd /s /q ""%allusersprofile%\Microsoft OneDrive"" & rd /s /q {StoragePaths.SystemDisk}\OneDriveTemp";
if (isLocalAccount)
argumentsFolders += @" & rd /s /q %userprofile%\OneDrive";
diff --git a/.Source/GTweak/Utilities/Tweaks/WindowsDefender.cs b/.Source/GTweak/Utilities/Tweaks/WindowsDefender.cs
index 5477e197..f8667d6b 100644
--- a/.Source/GTweak/Utilities/Tweaks/WindowsDefender.cs
+++ b/.Source/GTweak/Utilities/Tweaks/WindowsDefender.cs
@@ -124,7 +124,7 @@ namespace GTweak.Utilities.Tweaks
RegistryHelp.Write(Registry.ClassesRoot, @"*\shellex\ContextMenuHandlers\EPP", "", "{09A47860-11B0-4DA5-AFA5-26D86198A780}", RegistryValueKind.String);
RegistryHelp.Write(Registry.ClassesRoot, @"Directory\shellex\ContextMenuHandlers\EPP", "", "{09A47860-11B0-4DA5-AFA5-26D86198A780}", RegistryValueKind.String);
RegistryHelp.Write(Registry.ClassesRoot, @"Drive\shellex\ContextMenuHandlers\EPP", "", "{09A47860-11B0-4DA5-AFA5-26D86198A780}", RegistryValueKind.String);
- RegistryHelp.Write(Registry.ClassesRoot, @"CLSID\{09A47860-11B0-4DA5-AFA5-26D86198A780}\InprocServer32", "", UsePath.SystemDisk + @"Program Files\Windows Defender\shellext.dll", RegistryValueKind.String);
+ RegistryHelp.Write(Registry.ClassesRoot, @"CLSID\{09A47860-11B0-4DA5-AFA5-26D86198A780}\InprocServer32", "", StoragePaths.SystemDisk + @"Program Files\Windows Defender\shellext.dll", RegistryValueKind.String);
RegistryHelp.Write(Registry.ClassesRoot, @"CLSID\{09A47860-11B0-4DA5-AFA5-26D86198A780}\InprocServer32", "ThreadingModel", "Apartment", RegistryValueKind.String);
}
diff --git a/.Source/GTweak/Windows/ImportWindow.xaml.cs b/.Source/GTweak/Windows/ImportWindow.xaml.cs
index 48c565a1..a1cfdefd 100644
--- a/.Source/GTweak/Windows/ImportWindow.xaml.cs
+++ b/.Source/GTweak/Windows/ImportWindow.xaml.cs
@@ -52,7 +52,7 @@ namespace GTweak.Windows
{
List<string> tempKeys = new List<string>(), tempValues = new List<string>();
- INIManager iniManager = new INIManager(UsePath.Config);
+ INIManager iniManager = new INIManager(StoragePaths.Config);
for (byte i = 1; i <= 100; i++)
{
diff --git a/.Source/GTweak/Windows/NotificationWindow.xaml.cs b/.Source/GTweak/Windows/NotificationWindow.xaml.cs
index b958f2ec..4b084c5c 100644
--- a/.Source/GTweak/Windows/NotificationWindow.xaml.cs
+++ b/.Source/GTweak/Windows/NotificationWindow.xaml.cs
@@ -44,15 +44,13 @@ namespace GTweak.Windows
{
if (e.LeftButton == MouseButtonState.Pressed && !string.IsNullOrEmpty(ActionNotice))
{
- string arguments = ActionNotice switch
- {
- "logout" => @"/c logoff",
- _ => @"/c shutdown /r /t 0",
- };
-
Process.Start(new ProcessStartInfo()
{
- Arguments = arguments,
+ Arguments = ActionNotice switch
+ {
+ "logout" => @"/c logoff",
+ _ => @"/c shutdown /r /t 0",
+ },
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true,
FileName = "cmd.exe"
@@ -114,9 +112,8 @@ namespace GTweak.Windows
{
From = 0,
To = 1,
- SpeedRatio = 3,
EasingFunction = new QuadraticEase(),
- Duration = TimeSpan.FromSeconds(0.8)
+ Duration = TimeSpan.FromSeconds(0.25)
};
Timeline.SetDesiredFrameRate(doubleAnim, 400);