Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
refactor notification system & tweak action handling using attributes and builder pattern
Greedeks85e4831735ba
diff --git a/.Source/GTweak/Core/ViewModel/Components/DownloadSession.cs b/.Source/GTweak/Core/ViewModel/Components/DownloadSession.csindex 430d432f..990dc7a8 100644--- a/.Source/GTweak/Core/ViewModel/Components/DownloadSession.cs+++ b/.Source/GTweak/Core/ViewModel/Components/DownloadSession.cs@@ -104,10 +104,10 @@ namespace GTweak.Core.ViewModel.Componentsswitch (ex){case Exception e when e.Message == "GitHubRateLimit":- NotificationManager.Show("warn", "error_git_limit_noty").Perform();+ NotificationManager.Warn("error_git_limit_noty").Perform();break;case HttpRequestException _:- NotificationManager.Show("warn", "error_download_noty").Perform();+ NotificationManager.Warn("error_download_noty").Perform();break;default:ErrorLogger.LogDebug(ex);diff --git a/.Source/GTweak/GTweak.csproj b/.Source/GTweak/GTweak.csprojindex 2618444d..c1d5e936 100644--- a/.Source/GTweak/GTweak.csproj+++ b/.Source/GTweak/GTweak.csproj@@ -219,11 +219,12 @@<Compile Include="Behaviors\ScrollFadeBehavior.cs" /><Compile Include="Behaviors\ScrollViewerBehavior.cs" /><Compile Include="Behaviors\TextBoxClearBehavior.cs" />+ <Compile Include="Modules\Common\PostActionAttribute.cs" /><Compile Include="Modules\Configuration\IconProvider.cs" /><Compile Include="Modules\Configuration\NetworkProvider.cs" /><Compile Include="Modules\Configuration\StorageTypeIdentifier.cs" /><Compile Include="Modules\Configuration\HardwareData.cs" />- <Compile Include="Modules\Extensions\ControlDictionaryExtensions.cs" />+ <Compile Include="Modules\Extensions\PostActionExtensions.cs" /><Compile Include="Modules\Helpers\UnlockHandleHelper.cs" /><Compile Include="Modules\Extensions\WindowExtensions.cs" /><Compile Include="Modules\Maintenance\MemoryCleaner.cs" />diff --git a/.Source/GTweak/Modules/Common/GlobalOptions.cs b/.Source/GTweak/Modules/Common/GlobalOptions.csindex aa56d896..73d141ff 100644--- a/.Source/GTweak/Modules/Common/GlobalOptions.cs+++ b/.Source/GTweak/Modules/Common/GlobalOptions.cs@@ -98,7 +98,7 @@ namespace GTweak.Modules.Common{if (INIManager.IsAllTempDictionaryEmpty){- NotificationManager.Show("info", "export_warning_noty").Perform();+ NotificationManager.Info("export_warning_noty").Perform();}else{@@ -164,12 +164,12 @@ namespace GTweak.Modules.Common}else{- NotificationManager.Show("info", "empty_import_noty").Perform();+ NotificationManager.Info("empty_import_noty").Perform();}}else{- NotificationManager.Show("info", "warn_import_noty").Perform();+ NotificationManager.Warn("warn_import_noty").Perform();}}diff --git a/.Source/GTweak/Modules/Common/PostActionAttribute.cs b/.Source/GTweak/Modules/Common/PostActionAttribute.csnew file mode 100644index 00000000..d75ee39d--- /dev/null+++ b/.Source/GTweak/Modules/Common/PostActionAttribute.cs@@ -0,0 +1,18 @@+using System;+using GTweak.Modules.Managers;++namespace GTweak.Modules.Common+{+ [AttributeUsage(AttributeTargets.Field)]+ internal sealed class PostActionAttribute : Attribute+ {+ internal NotificationManager.AlertType Alert { get; }+ internal ExplorerManager.ShellType Shell { get; }++ internal PostActionAttribute(NotificationManager.AlertType alert = NotificationManager.AlertType.None, ExplorerManager.ShellType shell = ExplorerManager.ShellType.None)+ {+ Alert = alert;+ Shell = shell;+ }+ }+}diff --git a/.Source/GTweak/Modules/Extensions/ControlDictionaryExtensions.cs b/.Source/GTweak/Modules/Extensions/ControlDictionaryExtensions.csdeleted file mode 100644index 23e986ee..00000000--- a/.Source/GTweak/Modules/Extensions/ControlDictionaryExtensions.cs+++ /dev/null@@ -1,51 +0,0 @@-using System;-using System.Collections.Generic;--namespace GTweak.Modules.Extensions-{- internal static class ControlDictionaryExtensions- {- private static readonly char[] Digits = "0123456789".ToCharArray();-- internal static bool TryGetAction<TAction>(this Dictionary<Enum, TAction> dict, string controlName, out TAction action)- {- action = default;- if (string.IsNullOrEmpty(controlName))- {- return false;- }-- int digitIndex = controlName.IndexOfAny(Digits);-- if (digitIndex >= 0 && int.TryParse(controlName.Substring(digitIndex), out int index))- {- string prefix = controlName.Substring(0, digitIndex);-- string expectedSuffix = prefix switch- {- "TglButton" => "Toggle",- "Checkbox" => "Checkbox",- "Slider" => "Slider",- "ColorPicker" => "Color",- _ => string.Empty- };-- if (string.IsNullOrEmpty(expectedSuffix))- {- return false;- }-- foreach (var kvp in dict)- {- if (Convert.ToInt32(kvp.Key) == index && kvp.Key.GetType().Name.EndsWith(expectedSuffix))- {- action = kvp.Value;- return true;- }- }- }-- return false;- }- }-}\ No newline at end of filediff --git a/.Source/GTweak/Modules/Extensions/PostActionExtensions.cs b/.Source/GTweak/Modules/Extensions/PostActionExtensions.csnew file mode 100644index 00000000..a7716167--- /dev/null+++ b/.Source/GTweak/Modules/Extensions/PostActionExtensions.cs@@ -0,0 +1,40 @@+using System;+using System.Reflection;+using GTweak.Modules.Common;+using GTweak.Modules.Managers;++namespace GTweak.Modules.Extensions+{+ internal static class PostActionExtensions+ {+ private static readonly char[] Digits = "0123456789".ToCharArray();++ internal static bool HasAlert(this PostActionAttribute action) => action.Alert != NotificationManager.AlertType.None;+ internal static bool HasShell(this PostActionAttribute action) => action.Shell != ExplorerManager.ShellType.None;++ internal static PostActionAttribute GetPostAction(this Enum value)+ {+ return value.GetType().GetField(value.ToString())?.GetCustomAttribute<PostActionAttribute>() ?? new PostActionAttribute();+ }++ internal static PostActionAttribute GetPostAction(this string controlName, Type enumType)+ {+ if (string.IsNullOrEmpty(controlName))+ {+ return new PostActionAttribute();+ }++ int digitIndex = controlName.IndexOfAny(Digits);++ if (digitIndex >= 0 && int.TryParse(controlName.Substring(digitIndex), out int index))+ {+ return ((Enum)Enum.ToObject(enumType, index)).GetPostAction();+ }++ return new PostActionAttribute();+ }++ internal static NotificationManager.AlertType GetAlert(this Enum value) => value.GetPostAction().Alert;+ internal static ExplorerManager.ShellType GetShell(this Enum value) => value.GetPostAction().Shell;+ }+}\ No newline at end of filediff --git a/.Source/GTweak/Modules/Maintenance/RegistryExporter.cs b/.Source/GTweak/Modules/Maintenance/RegistryExporter.csindex b8eb0c09..d5da570e 100644--- a/.Source/GTweak/Modules/Maintenance/RegistryExporter.cs+++ b/.Source/GTweak/Modules/Maintenance/RegistryExporter.cs@@ -96,7 +96,7 @@ namespace GTweak.Modules.Maintenancewriter.WriteLine(File.ReadAllText(file, Encoding.Unicode));}}- catch { NotificationManager.Show("warn", "error_reg_exporter_noty").Perform(); }+ catch { NotificationManager.Warn("error_reg_exporter_noty").Perform(); }finally{foreach (string file in tempFiles)@@ -112,7 +112,7 @@ namespace GTweak.Modules.MaintenanceDirectory.Delete(tempDir);}- NotificationManager.Show("info", "success_reg_exporter_noty").WithDelay(500).Perform();+ NotificationManager.Info("success_reg_exporter_noty").WithDelay(500).Perform();}}}diff --git a/.Source/GTweak/Modules/Maintenance/SystemRestoreService.cs b/.Source/GTweak/Modules/Maintenance/SystemRestoreService.csindex d83b61fd..441ac177 100644--- a/.Source/GTweak/Modules/Maintenance/SystemRestoreService.cs+++ b/.Source/GTweak/Modules/Maintenance/SystemRestoreService.cs@@ -51,7 +51,7 @@ namespace GTweak.Modules.Maintenance_inParams = _restorePoint.GetMethodParameters("CreateRestorePoint");if (_inParams == null){- NotificationManager.Show("warn", "error_point_noty").Perform();+ NotificationManager.Warn("error_point_noty").Perform();return;}@@ -62,16 +62,16 @@ namespace GTweak.Modules.Maintenanceif (_outParams != null && _outParams["ReturnValue"] is uint retCode && retCode == 0){- NotificationManager.Show("info", "success_point_noty").WithDelay(300).Perform();+ NotificationManager.Info("success_point_noty").WithDelay(300).Perform();}else{- NotificationManager.Show("warn", "error_point_noty").WithDelay(300).Perform();+ NotificationManager.Warn("error_point_noty").WithDelay(300).Perform();}RegistryHelper.DeleteValue(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore", "SystemRestorePointCreationFrequency");}- catch { NotificationManager.Show("warn", "error_point_noty").Perform(); }+ catch { NotificationManager.Warn("error_point_noty").Perform(); }}internal void StartRecovery()@@ -85,7 +85,7 @@ namespace GTweak.Modules.MaintenanceCommandExecutor.RunCommand("/c rstrui.exe");}- catch { NotificationManager.Show("warn", "error_recovery_noty").Perform(); }+ catch { NotificationManager.Warn("error_recovery_noty").Perform(); }}internal void DisableRestorePoint()@@ -124,7 +124,7 @@ namespace GTweak.Modules.Maintenanceif (inParams == null){- NotificationManager.Show("warn", errorKey).Perform();+ NotificationManager.Warn(errorKey).Perform();return false;}@@ -135,7 +135,7 @@ namespace GTweak.Modules.Maintenanceif (outParams == null || !(outParams["ReturnValue"] is uint retCode) || retCode != 0){- NotificationManager.Show("warn", errorKey).Perform();+ NotificationManager.Warn(errorKey).Perform();return false;}@@ -143,7 +143,7 @@ namespace GTweak.Modules.Maintenance}catch (Exception){- NotificationManager.Show("warn", errorKey).Perform();+ NotificationManager.Warn(errorKey).Perform();return false;}}diff --git a/.Source/GTweak/Modules/Maintenance/WinLicenseHandler.cs b/.Source/GTweak/Modules/Maintenance/WinLicenseHandler.csindex a7fd17ee..1b124823 100644--- a/.Source/GTweak/Modules/Maintenance/WinLicenseHandler.cs+++ b/.Source/GTweak/Modules/Maintenance/WinLicenseHandler.cs@@ -56,11 +56,11 @@ namespace GTweak.Modules.Maintenanceif (string.IsNullOrEmpty(keyWinHWID) && string.IsNullOrEmpty(keyWinKMS)){- NotificationManager.Show("warn", "keynotfound_noty").WithDelay(300).Perform();+ NotificationManager.Warn("keynotfound_noty").WithDelay(300).Perform();return;}- NotificationManager.Show("warn", "win_activate_noty").Perform();+ NotificationManager.Warn("win_activate_noty").Perform();OverlayWindow overlayWindow = new OverlayWindow();overlayWindow.Show();@@ -102,7 +102,7 @@ namespace GTweak.Modules.Maintenanceif (IsWindowsActivated){overlayWindow.Close();- NotificationManager.Show("warn", "success_activate_noty").WithDelay(300).Restart();+ NotificationManager.Info("success_activate_noty").WithDelay(300).Restart();}else{@@ -116,13 +116,13 @@ namespace GTweak.Modules.MaintenanceoverlayWindow.Close();- NotificationManager.Show("warn", IsWindowsActivated ? "success_activate_noty" : "error_activate_noty").WithDelay(300).Perform(IsWindowsActivated ? NotificationManager.NoticeAction.Restart : default);+ NotificationManager.Info(IsWindowsActivated ? "success_activate_noty" : "error_activate_noty").WithDelay(300).Perform(IsWindowsActivated ? NotificationManager.AlertType.Restart : default);}}catch{overlayWindow.Close();- NotificationManager.Show("warn", "error_activate_noty").WithDelay(300).Perform();+ NotificationManager.Warn("error_activate_noty").WithDelay(300).Perform();}}}diff --git a/.Source/GTweak/Modules/Managers/ExplorerManager.cs b/.Source/GTweak/Modules/Managers/ExplorerManager.csindex b67e59cd..7c376b25 100644--- a/.Source/GTweak/Modules/Managers/ExplorerManager.cs+++ b/.Source/GTweak/Modules/Managers/ExplorerManager.cs@@ -1,11 +1,9 @@using System;-using System.Collections.Generic;using System.Diagnostics;using System.Runtime.InteropServices;using System.Threading;using System.Threading.Tasks;using GTweak.Modules.Common;-using GTweak.Modules.Tweaks;namespace GTweak.Modules.Managers{@@ -25,45 +23,7 @@ namespace GTweak.Modules.Managers[DllImport("user32.dll", SetLastError = true)]static extern IntPtr FindWindow(string lpClassName, string lpWindowName);- internal enum ExplorerAction { None, Refresh, Restart }-- internal static readonly Dictionary<Enum, ExplorerAction> IntfActions = new Dictionary<Enum, ExplorerAction>()- {- [InterfaceCheckbox.ExplorerHome] = ExplorerAction.Restart,- [InterfaceCheckbox.ExplorerGallery] = ExplorerAction.Restart,- [InterfaceCheckbox.ExplorerOneDrive] = ExplorerAction.Restart,- [InterfaceCheckbox.FolderObjects3D] = ExplorerAction.Restart,- [InterfaceCheckbox.FolderDesktop] = ExplorerAction.Restart,- [InterfaceCheckbox.FolderDownloads] = ExplorerAction.Restart,- [InterfaceCheckbox.FolderDocuments] = ExplorerAction.Restart,- [InterfaceCheckbox.FolderPictures] = ExplorerAction.Restart,- [InterfaceCheckbox.FolderMusic] = ExplorerAction.Restart,- [InterfaceCheckbox.FolderVideo] = ExplorerAction.Restart,- [InterfaceCheckbox.HiddenFiles] = ExplorerAction.Restart,- [InterfaceCheckbox.SystemFiles] = ExplorerAction.Restart,- [InterfaceCheckbox.FileExtensions] = ExplorerAction.Restart,- [InterfaceCheckbox.EmptyDrives] = ExplorerAction.Restart,- [InterfaceCheckbox.IconComputer] = ExplorerAction.Refresh,- [InterfaceCheckbox.IconNetwork] = ExplorerAction.Refresh,- [InterfaceCheckbox.IconRecycleBin] = ExplorerAction.Refresh,- [InterfaceCheckbox.IconControlPanel] = ExplorerAction.Refresh,- [InterfaceCheckbox.IconUserFiles] = ExplorerAction.Refresh,- [InterfaceCheckbox.IconOneDrive] = ExplorerAction.Refresh,- [InterfaceToggle.TaskbarDarkTheme] = ExplorerAction.Restart,- [InterfaceToggle.AppDarkTheme] = ExplorerAction.Restart,- [InterfaceToggle.TaskbarAlignment] = ExplorerAction.Restart,- [InterfaceToggle.StartMenuLayout] = ExplorerAction.Restart,- [InterfaceToggle.CompactContextMenu] = ExplorerAction.Restart,- [InterfaceToggle.TaskbarEndTask] = ExplorerAction.Restart,- [InterfaceToggle.TaskbarIconsButtons] = ExplorerAction.Restart,- [InterfaceToggle.BingStartSearch] = ExplorerAction.Restart- };-- internal static readonly Dictionary<string, ExplorerAction> PackageActions = new Dictionary<string, ExplorerAction>()- {- ["Widgets"] = ExplorerAction.Restart,- ["Edge"] = ExplorerAction.Restart- };+ internal enum ShellType { None, Refresh, Restart }private static readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1);private static readonly object _lockObj = new object();@@ -167,5 +127,17 @@ namespace GTweak.Modules.Managerscatch (Exception ex) { ErrorLogger.LogDebug(ex); }});}++ internal static void Handle(ShellType effect)+ {+ if (effect == ShellType.Restart)+ {+ Restart();+ }+ else if (effect == ShellType.Refresh)+ {+ RefreshDesktop();+ }+ }}}\ No newline at end of filediff --git a/.Source/GTweak/Modules/Managers/NotificationManager.cs b/.Source/GTweak/Modules/Managers/NotificationManager.csindex e31be0e1..b05b9894 100644--- a/.Source/GTweak/Modules/Managers/NotificationManager.cs+++ b/.Source/GTweak/Modules/Managers/NotificationManager.cs@@ -1,64 +1,26 @@-using System;-using System.Collections.Generic;using System.Threading;using System.Threading.Tasks;using System.Windows;using System.Windows.Threading;using GTweak.Modules.Common;-using GTweak.Modules.Tweaks;using GTweak.Windows;namespace GTweak.Modules.Managers{internal static class NotificationManager{- internal enum NoticeAction { None, Logout, Restart }-- internal static readonly Dictionary<Enum, NoticeAction> ConfActions = new Dictionary<Enum, NoticeAction>()- {- [ConfidentialityToggle.HardwareConfigurationData] = NoticeAction.Restart,- [ConfidentialityToggle.CovertDataCollectionServices] = NoticeAction.Restart,- [ConfidentialityToggle.IntelTelemetry] = NoticeAction.Restart- };-- internal static readonly Dictionary<Enum, NoticeAction> IntfActions = new Dictionary<Enum, NoticeAction>()- {- [InterfaceToggle.SystemButtonSize] = NoticeAction.Logout,- [InterfaceToggle.CursorFlickerFrequency] = NoticeAction.Logout,- [InterfaceToggle.ScrollbarSize] = NoticeAction.Logout,- [InterfaceToggle.ContextMenuDelay] = NoticeAction.Logout,- [InterfaceToggle.TaskbarPreviewDelay] = NoticeAction.Logout,- [InterfaceToggle.IconOverlayBadges] = NoticeAction.Logout,- [InterfaceToggle.ShortcutNameSuffix] = NoticeAction.Logout,- [InterfaceToggle.CopilotRecall] = NoticeAction.Restart,- [InterfaceToggle.SnapLayouts] = NoticeAction.Logout,- [InterfaceToggle.AdaptiveBrightness] = NoticeAction.Restart- };-- internal static readonly Dictionary<Enum, NoticeAction> SysActions = new Dictionary<Enum, NoticeAction>()- {- [SystemToggle.StickyKeysFilter] = NoticeAction.Logout,- [SystemToggle.WindowsDefender] = NoticeAction.Restart,- [SystemToggle.UserAccountControl] = NoticeAction.Restart,- [SystemToggle.SecurityNotifications] = NoticeAction.Restart,- [SystemToggle.RealtekAudioDelay] = NoticeAction.Restart,- [SystemToggle.MemoryDiagnostics] = NoticeAction.Restart,- [SystemToggle.NetworkProtocols] = NoticeAction.Restart,- [SystemToggle.FileSystemCache] = NoticeAction.Restart,- [SystemToggle.StartupDelay] = NoticeAction.Restart,- [SystemToggle.WindowsFirewall] = NoticeAction.Restart,- [SystemToggle.BackgroundApps] = NoticeAction.Restart,- [SystemToggle.DynamicTickHpet] = NoticeAction.Restart,- [SystemToggle.InsiderTasks] = NoticeAction.Restart,- [SystemToggle.MultiPlaneOverlay] = NoticeAction.Restart- };+ internal enum AlertType { None, Logout, Restart }private static volatile int _isNotificationOpen;- internal static NotificationBuilder Show(string titleKey = "", string textKey = "")+ internal static NotificationBuilder Info(string textKey) => Builder("info", textKey);+ internal static NotificationBuilder Warn(string textKey) => Builder("warn", textKey);+ internal static NotificationBuilder Default() => Builder(string.Empty, string.Empty);++ private static NotificationBuilder Builder(string titleKey, string textKey){- string title = Application.Current?.TryFindResource($"title_{titleKey}_noty") as string ?? string.Empty;- string text = Application.Current?.TryFindResource(textKey) as string ?? string.Empty;+ string title = string.IsNullOrEmpty(titleKey) ? string.Empty : Application.Current?.TryFindResource($"title_{titleKey}_noty") as string ?? string.Empty;+ string text = string.IsNullOrEmpty(textKey) ? string.Empty : Application.Current?.TryFindResource(textKey) as string ?? string.Empty;return new NotificationBuilder(title, text);}@@ -80,11 +42,11 @@ namespace GTweak.Modules.Managersreturn this;}- internal void Perform(NoticeAction action = NoticeAction.None) => ShowNotification(action);- internal void Logout() => ShowNotification(NoticeAction.Logout);- internal void Restart() => ShowNotification(NoticeAction.Restart);+ internal void Perform(AlertType alert = AlertType.None) => ShowNotification(alert);+ internal void Logout() => ShowNotification(AlertType.Logout);+ internal void Restart() => ShowNotification(AlertType.Restart);- private async void ShowNotification(NoticeAction action)+ private async void ShowNotification(AlertType type){if (GlobalOptions.IsViewNotification && Interlocked.CompareExchange(ref _isNotificationOpen, 1, 0) == 0){@@ -101,13 +63,13 @@ namespace GTweak.Modules.Managers{NoticeTitle = _title,NoticeText = _text,- RequiredAction = action+ AlertType = type};if (string.IsNullOrWhiteSpace(window.NoticeTitle) && string.IsNullOrWhiteSpace(window.NoticeText)){window.NoticeTitle = (Application.Current?.Resources)?["title_warn_noty"] as string ?? string.Empty;- window.NoticeText = (Application.Current?.Resources)?[action == NoticeAction.Logout ? "logout_noty" : "restart_noty"] as string ?? string.Empty;+ window.NoticeText = (Application.Current?.Resources)?[type == AlertType.Logout ? "logout_noty" : "restart_noty"] as string ?? string.Empty;}window.Closed += delegate { Interlocked.Exchange(ref _isNotificationOpen, 0); };diff --git a/.Source/GTweak/Modules/Storage/PackageStorage.cs b/.Source/GTweak/Modules/Storage/PackageStorage.csindex 0a5b4330..f0aeeba1 100644--- a/.Source/GTweak/Modules/Storage/PackageStorage.cs+++ b/.Source/GTweak/Modules/Storage/PackageStorage.cs@@ -1,5 +1,6 @@using System;using System.Collections.Generic;+using GTweak.Modules.Managers;namespace GTweak.Modules.Storage{@@ -8,11 +9,13 @@ namespace GTweak.Modules.Storageinternal string Alias { get; }internal bool IsUnavailable { get; set; }internal IReadOnlyList<string> Scripts { get; }+ internal ExplorerManager.ShellType ShellType { get; }- internal PackagesInfo(string alias = null, IReadOnlyList<string> scripts = null)+ internal PackagesInfo(string alias = null, IReadOnlyList<string> scripts = null, ExplorerManager.ShellType shellType = ExplorerManager.ShellType.None){Alias = alias;Scripts = scripts;+ ShellType = shellType;}}@@ -36,7 +39,7 @@ namespace GTweak.Modules.Storage["DevHome"] = new PackagesInfo(scripts: new[] { "Microsoft.Windows.DevHome" }),["Disney"] = new PackagesInfo("Disney", new[] { "Disney.37853FC22B2CE" }),["DolbyAccess"] = new PackagesInfo("DolbyAccess", new[] { "DolbyLaboratories.DolbyAccess" }),- ["Edge"] = new PackagesInfo("MicrosoftEdge", new[] { "Microsoft.MicrosoftEdge.Stable", "Microsoft.MicrosoftEdgeDevToolsClient", "Microsoft.Copilot" }),+ ["Edge"] = new PackagesInfo("MicrosoftEdge", new[] { "Microsoft.MicrosoftEdge.Stable", "Microsoft.MicrosoftEdgeDevToolsClient", "Microsoft.Copilot" }, ExplorerManager.ShellType.Restart),["Facebook"] = new PackagesInfo("Facebook", new[] { "Facebook.Facebook" }),["FeedbackHub"] = new PackagesInfo("feedback", new[] { "Microsoft.WindowsFeedbackHub" }),["GetHelp"] = new PackagesInfo(scripts: new[] { "Microsoft.GetHelp" }),@@ -89,7 +92,7 @@ namespace GTweak.Modules.Storage["WebMediaExtensions"] = new PackagesInfo(scripts: new[] { "Microsoft.WebMediaExtensions" }),["WhatsApp"] = new PackagesInfo("WhatsAppDesktop", new[] { "5319275A.WhatsAppDesktop" }),["WhiteBoard"] = new PackagesInfo(scripts: new[] { "Microsoft.Whiteboard" }),- ["Widgets"] = new PackagesInfo("Windows.Client.WebExperience", new[] { "MicrosoftWindows.Client.WebExperience", "Microsoft.WidgetsPlatformRuntime", "Microsoft.StartExperiencesApp" }),+ ["Widgets"] = new PackagesInfo("Windows.Client.WebExperience", new[] { "MicrosoftWindows.Client.WebExperience", "Microsoft.WidgetsPlatformRuntime", "Microsoft.StartExperiencesApp" }, ExplorerManager.ShellType.Restart),["WindowsTerminal"] = new PackagesInfo(scripts: new[] { "Microsoft.WindowsTerminal" }),["Xbox"] = new PackagesInfo(scripts: new[] { "Microsoft.XboxApp", "Microsoft.GamingApp", "Microsoft.XboxGamingOverlay", "Microsoft.XboxGameOverlay", "Microsoft.XboxIdentityProvider", "Microsoft.Xbox.TCUI", "Microsoft.XboxSpeechToTextOverlay" }),["YandexMusic"] = new PackagesInfo(scripts: new[] { "A025C540.Yandex.Music" }),diff --git a/.Source/GTweak/Modules/Tweaks/ConfidentialityTweaks.cs b/.Source/GTweak/Modules/Tweaks/ConfidentialityTweaks.csindex 623875ab..e37b1511 100644--- a/.Source/GTweak/Modules/Tweaks/ConfidentialityTweaks.cs+++ b/.Source/GTweak/Modules/Tweaks/ConfidentialityTweaks.cs@@ -15,24 +15,47 @@ namespace GTweak.Modules.Tweaksinternal enum ConfidentialityToggle{TargetedAdvertising = 1,+DataSynchronization,+WindowsTelemetry,+SchedulerDataCollection,+InstalledAppsData,+AppUsageStatistics,+HandwritingData,+++ [PostAction(NotificationManager.AlertType.Restart)]HardwareConfigurationData,+HiddenMicrosoftDomains,+UserLocationTracking,+FeedbackRequests,+SpeechSynthesisUpdates,+HiddenSystemMonitoring,+SystemExperiments,++ [PostAction(NotificationManager.AlertType.Restart)]CovertDataCollectionServices,+WindowsEventLogging,+NvidiaTelemetry,+UserBehaviorRecording,+OfflineMapsUpdates,++ [PostAction(NotificationManager.AlertType.Restart)]IntelTelemetry}diff --git a/.Source/GTweak/Modules/Tweaks/InterfaceTweaks.cs b/.Source/GTweak/Modules/Tweaks/InterfaceTweaks.csindex 490960e8..8ca4a7f2 100644--- a/.Source/GTweak/Modules/Tweaks/InterfaceTweaks.cs+++ b/.Source/GTweak/Modules/Tweaks/InterfaceTweaks.cs@@ -19,56 +19,139 @@ namespace GTweak.Modules.Tweaksinternal enum InterfaceCheckbox{+ [PostAction(shell: ExplorerManager.ShellType.Restart)]ExplorerHome = 1,++ [PostAction(shell: ExplorerManager.ShellType.Restart)]ExplorerGallery,++ [PostAction(shell: ExplorerManager.ShellType.Restart)]ExplorerOneDrive,++ [PostAction(shell: ExplorerManager.ShellType.Restart)]HiddenFiles,++ [PostAction(shell: ExplorerManager.ShellType.Restart)]SystemFiles,++ [PostAction(shell: ExplorerManager.ShellType.Restart)]FileExtensions,++ [PostAction(shell: ExplorerManager.ShellType.Restart)]EmptyDrives,++ [PostAction(shell: ExplorerManager.ShellType.Refresh)]IconComputer,++ [PostAction(shell: ExplorerManager.ShellType.Refresh)]IconNetwork,++ [PostAction(shell: ExplorerManager.ShellType.Refresh)]IconRecycleBin,++ [PostAction(shell: ExplorerManager.ShellType.Refresh)]IconControlPanel,++ [PostAction(shell: ExplorerManager.ShellType.Refresh)]IconUserFiles,++ [PostAction(shell: ExplorerManager.ShellType.Refresh)]IconOneDrive,++ [PostAction(shell: ExplorerManager.ShellType.Restart)]FolderObjects3D,++ [PostAction(shell: ExplorerManager.ShellType.Restart)]FolderDesktop,++ [PostAction(shell: ExplorerManager.ShellType.Restart)]FolderDownloads,++ [PostAction(shell: ExplorerManager.ShellType.Restart)]FolderDocuments,++ [PostAction(shell: ExplorerManager.ShellType.Restart)]FolderPictures,++ [PostAction(shell: ExplorerManager.ShellType.Restart)]FolderMusic,++ [PostAction(shell: ExplorerManager.ShellType.Restart)]FolderVideo}internal enum InterfaceToggle{+ [PostAction(NotificationManager.AlertType.Logout)]SystemButtonSize = 1,++ [PostAction(NotificationManager.AlertType.Logout)]CursorFlickerFrequency,++ [PostAction(NotificationManager.AlertType.Logout)]ScrollbarSize,+TaskbarTransparency,++ [PostAction(shell: ExplorerManager.ShellType.Restart)]TaskbarDarkTheme,++ [PostAction(shell: ExplorerManager.ShellType.Restart)]AppDarkTheme,++ [PostAction(NotificationManager.AlertType.Logout)]ContextMenuDelay,++ [PostAction(NotificationManager.AlertType.Logout)]TaskbarPreviewDelay,++ [PostAction(NotificationManager.AlertType.Logout)]IconOverlayBadges,++ [PostAction(NotificationManager.AlertType.Logout)]ShortcutNameSuffix,++ [PostAction(shell: ExplorerManager.ShellType.Restart)]TaskbarAlignment,++ [PostAction(shell: ExplorerManager.ShellType.Restart)]StartMenuLayout,++ [PostAction(shell: ExplorerManager.ShellType.Restart)]CompactContextMenu,+TipsSuggestions,+CompactExplorerMode,++ [PostAction(NotificationManager.AlertType.Restart)]CopilotRecall,++ [PostAction(shell: ExplorerManager.ShellType.Restart)]TaskbarEndTask,++ [PostAction(NotificationManager.AlertType.Logout)]SnapLayouts,++ [PostAction(shell: ExplorerManager.ShellType.Restart)]TaskbarIconsButtons,+PersonalizedAds,+RestoreFolderWindows,+TipsNotifications,+JpegWallpaperCompression,+DesktopTooltips,++ [PostAction(shell: ExplorerManager.ShellType.Restart)]BingStartSearch,+OpenQuickAccess,++ [PostAction(NotificationManager.AlertType.Restart)]AdaptiveBrightness}diff --git a/.Source/GTweak/Modules/Tweaks/SystemTweaks.cs b/.Source/GTweak/Modules/Tweaks/SystemTweaks.csindex 1e01b265..78d08404 100644--- a/.Source/GTweak/Modules/Tweaks/SystemTweaks.cs+++ b/.Source/GTweak/Modules/Tweaks/SystemTweaks.cs@@ -37,34 +37,77 @@ namespace GTweak.Modules.Tweaksinternal enum SystemToggle{PointerPrecision = 1,++ [PostAction(NotificationManager.AlertType.Logout)]+StickyKeysFilter,+WindowsDefender,++ [PostAction(NotificationManager.AlertType.Restart)]UserAccountControl,++ [PostAction(NotificationManager.AlertType.Restart)]SecurityNotifications,+StoreAutoUpdate,++ [PostAction(NotificationManager.AlertType.Restart)]RealtekAudioDelay,+LockScreenTimeout,+HibernationFastStartup,+AutoEndTasks,+ExeLaunchWarnings,++ [PostAction(NotificationManager.AlertType.Restart)]MemoryDiagnostics,++ [PostAction(NotificationManager.AlertType.Restart)]NetworkProtocols,++ [PostAction(NotificationManager.AlertType.Restart)]FileSystemCache,++ [PostAction(NotificationManager.AlertType.Restart)]StartupDelay,+QuickAccessHistory,+RemovableMediaAutoplay,+PowerScheme,+BluetoothFunction,++ [PostAction(NotificationManager.AlertType.Restart)]WindowsFirewall,+GameMode,+GameBar,++ [PostAction(NotificationManager.AlertType.Restart)]BackgroundApps,+ReservedStorage,++ [PostAction(NotificationManager.AlertType.Restart)]DynamicTickHpet,+HealthCheck,++ [PostAction(NotificationManager.AlertType.Restart)]InsiderTasks,+SystemDriveDefrag,+PauseWindowsUpdates,++ [PostAction(NotificationManager.AlertType.Restart)]MultiPlaneOverlay}@@ -162,12 +205,12 @@ namespace GTweak.Modules.TweaksoverlayWindow.Show();BackgroundQueueManager backgroundQueue = new BackgroundQueueManager();- await backgroundQueue.QueueTask(delegate { NotificationManager.Show(state ? "info" : "warn", state ? "info_wd_noty" : "warn_wd_noty").Perform(); });+ await backgroundQueue.QueueTask(() => (state ? NotificationManager.Info("info_wd_noty") : NotificationManager.Warn("warn_wd_noty")).Perform());await backgroundQueue.QueueTask(delegate { DefenderTweaks.SetProtectionState(state); });if (state){- await backgroundQueue.QueueTask(delegate { NotificationManager.Show().WithDelay(300).Restart(); });+ await backgroundQueue.QueueTask(delegate { NotificationManager.Default().WithDelay(300).Restart(); });}overlayWindow.Close();diff --git a/.Source/GTweak/View/ConfidentialityView.xaml.cs b/.Source/GTweak/View/ConfidentialityView.xaml.csindex 5394a5f0..7337d0e7 100644--- a/.Source/GTweak/View/ConfidentialityView.xaml.cs+++ b/.Source/GTweak/View/ConfidentialityView.xaml.cs@@ -3,6 +3,7 @@ using System.Windows.Controls;using System.Windows.Input;using GTweak.Assets.UserControls;using GTweak.Core.Interfaces;+using GTweak.Modules.Common;using GTweak.Modules.Extensions;using GTweak.Modules.Managers;using GTweak.Modules.Tweaks;@@ -29,9 +30,11 @@ namespace GTweak.View_confTweaks.Apply(tglButton.Name, tglButton.State);- if (NotificationManager.ConfActions.TryGetAction(tglButton.Name, out NotificationManager.NoticeAction action))+ PostActionAttribute postAction = tglButton.Name.GetPostAction(typeof(ConfidentialityToggle));++ if (postAction.HasAlert()){- NotificationManager.Show().WithDelay(300).Perform(action);+ NotificationManager.Default().WithDelay(300).Perform(postAction.Alert);}}}diff --git a/.Source/GTweak/View/InterfaceView.xaml.cs b/.Source/GTweak/View/InterfaceView.xaml.csindex a5c1626f..86192e77 100644--- a/.Source/GTweak/View/InterfaceView.xaml.cs+++ b/.Source/GTweak/View/InterfaceView.xaml.cs@@ -4,6 +4,7 @@ using System.Windows.Controls;using System.Windows.Input;using GTweak.Assets.UserControls;using GTweak.Core.Interfaces;+using GTweak.Modules.Common;using GTweak.Modules.Extensions;using GTweak.Modules.Managers;using GTweak.Modules.Tweaks;@@ -13,7 +14,7 @@ namespace GTweak.Viewpublic partial class InterfaceView : UserControl, IViewMarker{private readonly InterfaceTweaks _intfTweaks = new InterfaceTweaks();- private ExplorerManager.ExplorerAction _explorerAction = ExplorerManager.ExplorerAction.None;+ private ExplorerManager.ShellType _shellType = ExplorerManager.ShellType.None;public InterfaceView(){@@ -27,53 +28,38 @@ namespace GTweak.View{ColorPicker colorPicker = (ColorPicker)sender;_intfTweaks.Apply(colorPicker.Name, colorPicker.SelectedColorString);- NotificationManager.Show().WithDelay(300).Logout();+ NotificationManager.Default().WithDelay(300).Logout();}private void CheckBox_Click(object sender, RoutedEventArgs e){CheckBox checkBox = (CheckBox)sender;_intfTweaks.Apply(checkBox.Uid, checkBox.IsChecked == false);-- if (ExplorerManager.IntfActions.TryGetAction(checkBox.Uid, out ExplorerManager.ExplorerAction explorerAction))- {- _explorerAction = explorerAction;- }+ _shellType = checkBox.Uid.GetPostAction(typeof(InterfaceCheckbox)).Shell;}private void ExpandableBox_Closed(object sender, EventArgs e){- switch (_explorerAction)- {- case ExplorerManager.ExplorerAction.Restart:- ExplorerManager.Restart();- break;- case ExplorerManager.ExplorerAction.Refresh:- ExplorerManager.RefreshDesktop();- break;- default:- break;- }-- _explorerAction = ExplorerManager.ExplorerAction.None;+ ExplorerManager.Handle(_shellType);+ _shellType = ExplorerManager.ShellType.None;}private void TglButton_ChangedState(object sender, RoutedEventArgs e){ToggleButton tglButton = (ToggleButton)sender;-DescBlock.ContentSource = tglButton;-_intfTweaks.Apply(tglButton.Name, tglButton.State);- if (ExplorerManager.IntfActions.TryGetAction(tglButton.Name, out ExplorerManager.ExplorerAction explorerAction) && explorerAction == ExplorerManager.ExplorerAction.Restart)+ PostActionAttribute postAction = tglButton.Name.GetPostAction(typeof(InterfaceToggle));++ if (postAction.HasShell()){- ExplorerManager.Restart();+ ExplorerManager.Handle(postAction.Shell);}- if (NotificationManager.IntfActions.TryGetAction(tglButton.Name, out NotificationManager.NoticeAction noticeAction))+ if (postAction.HasAlert()){- NotificationManager.Show().WithDelay(300).Perform(noticeAction);+ NotificationManager.Default().WithDelay(300).Perform(postAction.Alert);}}}diff --git a/.Source/GTweak/View/PackagesView.xaml.cs b/.Source/GTweak/View/PackagesView.xaml.csindex b9ca5968..f6dc8999 100644--- a/.Source/GTweak/View/PackagesView.xaml.cs+++ b/.Source/GTweak/View/PackagesView.xaml.cs@@ -7,6 +7,7 @@ using System.Windows.Threading;using GTweak.Core.Interfaces;using GTweak.Modules.Common;using GTweak.Modules.Managers;+using GTweak.Modules.Storage;using GTweak.Modules.Tweaks;namespace GTweak.View@@ -60,11 +61,11 @@ namespace GTweak.View{if (string.IsNullOrWhiteSpace(PathTargets.Executable.OneDriveSetup)){- NotificationManager.Show("warn", "error_onedrive_noty").Perform();+ NotificationManager.Warn("error_onedrive_noty").Perform();}else{- NotificationManager.Show("info", "success_onedrive_noty").Perform();+ NotificationManager.Info("success_onedrive_noty").Perform();await _backgroundQueue.QueueTask(async () =>{@@ -101,10 +102,7 @@ namespace GTweak.Viewawait Dispatcher.BeginInvoke(new Action(() =>{- if (ExplorerManager.PackageActions.TryGetValue(packageName, out ExplorerManager.ExplorerAction explorerAction))- {- ExplorerManager.Restart();- }+ ExplorerManager.Handle(PackageStorage.PackagesDetails[packageName].ShellType);}), DispatcherPriority.ApplicationIdle);});}diff --git a/.Source/GTweak/View/ServicesView.xaml.cs b/.Source/GTweak/View/ServicesView.xaml.csindex 9dc95f63..ded4aa7a 100644--- a/.Source/GTweak/View/ServicesView.xaml.cs+++ b/.Source/GTweak/View/ServicesView.xaml.cs@@ -28,7 +28,7 @@ namespace GTweak.View_svcTweaks.Apply(tglButton.Name, tglButton.State);- NotificationManager.Show().WithDelay(300).Restart();+ NotificationManager.Default().WithDelay(300).Restart();}}}diff --git a/.Source/GTweak/View/SystemView.xaml.cs b/.Source/GTweak/View/SystemView.xaml.csindex cb76b2dc..1c48a43b 100644--- a/.Source/GTweak/View/SystemView.xaml.cs+++ b/.Source/GTweak/View/SystemView.xaml.cs@@ -3,6 +3,7 @@ using System.Windows.Controls;using System.Windows.Input;using GTweak.Assets.UserControls;using GTweak.Core.Interfaces;+using GTweak.Modules.Common;using GTweak.Modules.Extensions;using GTweak.Modules.Managers;using GTweak.Modules.Tweaks;@@ -26,21 +27,15 @@ namespace GTweak.Viewprivate void TglButton_ChangedState(object sender, RoutedEventArgs e){ToggleButton tglButton = (ToggleButton)sender;-DescBlock.ContentSource = tglButton;- if (tglButton.Name != "TglButton3")- {- _sysTweaks.Apply(tglButton.Name, tglButton.State);+ _sysTweaks.Apply(tglButton.Name, tglButton.State);- if (NotificationManager.SysActions.TryGetAction(tglButton.Name, out NotificationManager.NoticeAction action))- {- NotificationManager.Show().WithDelay(300).Perform(action);- }- }- else+ PostActionAttribute postAction = tglButton.Name.GetPostAction(typeof(SystemToggle));++ if (postAction.HasAlert()){- _sysTweaks.Apply(tglButton.Name, tglButton.State);+ NotificationManager.Default().WithDelay(300).Perform(postAction.Alert);}}}diff --git a/.Source/GTweak/View/UtilsView.xaml.cs b/.Source/GTweak/View/UtilsView.xaml.csindex d2e9ca78..7d1c8228 100644--- a/.Source/GTweak/View/UtilsView.xaml.cs+++ b/.Source/GTweak/View/UtilsView.xaml.cs@@ -29,7 +29,7 @@ namespace GTweak.View{if (WinLicenseHandler.IsWindowsActivated){- NotificationManager.Show("info", "ready_activate_noty").Perform();+ NotificationManager.Info("ready_activate_noty").Perform();}else{@@ -39,7 +39,7 @@ namespace GTweak.View}else{- NotificationManager.Show("warn", "network_activate_noty").Perform();+ NotificationManager.Warn("network_activate_noty").Perform();}}}@@ -48,13 +48,13 @@ namespace GTweak.View{OverlayWindow overlayWindow = new OverlayWindow();overlayWindow.Show();- NotificationManager.Show("info", "createpoint_noty").Perform();+ NotificationManager.Info("createpoint_noty").Perform();BackgroundQueueManager backgroundQueue = new BackgroundQueueManager();if (_systemRestore == null){overlayWindow.Close();- NotificationManager.Show("warn", "error_point_noty").WithDelay(300).Perform();+ NotificationManager.Warn("error_point_noty").WithDelay(300).Perform();return;}@@ -74,11 +74,11 @@ namespace GTweak.View{try { _systemRestore.DisableRestorePoint(); } catch (Exception ex) { ErrorLogger.LogDebug(ex); }});- await backgroundQueue.QueueTask(delegate { NotificationManager.Show("info", "disable_recovery_noty").WithDelay(300).Perform(); });+ await backgroundQueue.QueueTask(delegate { NotificationManager.Info("disable_recovery_noty").WithDelay(300).Perform(); });}else{- NotificationManager.Show("info", "warn_recovery_noty").Perform();+ NotificationManager.Info("warn_recovery_noty").Perform();}}@@ -91,11 +91,11 @@ namespace GTweak.View{try { _systemRestore.EnableRestorePoint(); } catch (Exception ex) { ErrorLogger.LogDebug(ex); }});- await backgroundQueue.QueueTask(delegate { NotificationManager.Show("info", "enable_recovery_noty").WithDelay(300).Perform(); });+ await backgroundQueue.QueueTask(delegate { NotificationManager.Info("enable_recovery_noty").WithDelay(300).Perform(); });}else{- NotificationManager.Show("info", "warn_point_enabled_noty").Perform();+ NotificationManager.Info("warn_point_enabled_noty").Perform();}}@@ -117,18 +117,18 @@ namespace GTweak.Viewawait backgroundQueue.QueueTask(delegate{try { _ntfsCompressor.SetCompression(selectedPath, true); }- catch { NotificationManager.Show("warn", "error_compression_noty").Perform(); }+ catch { NotificationManager.Warn("error_compression_noty").Perform(); }});- await backgroundQueue.QueueTask(delegate { NotificationManager.Show("info", "success_compression_noty").WithDelay(500).Perform(); });+ await backgroundQueue.QueueTask(delegate { NotificationManager.Info("success_compression_noty").WithDelay(500).Perform(); });}else{- NotificationManager.Show("info", "ready_compression_noty").Perform();+ NotificationManager.Info("ready_compression_noty").Perform();}}else{- NotificationManager.Show("warn", "notsupport_ntfs_noty").Perform();+ NotificationManager.Warn("notsupport_ntfs_noty").Perform();}}@@ -150,19 +150,19 @@ namespace GTweak.Viewawait backgroundQueue.QueueTask(delegate{try { _ntfsCompressor.SetCompression(selectedPath, false); }- catch { NotificationManager.Show("warn", "error_compression_noty").Perform(); }+ catch { NotificationManager.Warn("error_compression_noty").Perform(); }});- await backgroundQueue.QueueTask(delegate { NotificationManager.Show("info", "success_decompression_noty").WithDelay(500).Perform(); });+ await backgroundQueue.QueueTask(delegate { NotificationManager.Info("success_decompression_noty").WithDelay(500).Perform(); });}else{- NotificationManager.Show("info", "ready_decompression_noty").Perform();+ NotificationManager.Info("ready_decompression_noty").Perform();}}else{- NotificationManager.Show("warn", "notsupport_ntfs_noty").Perform();+ NotificationManager.Warn("notsupport_ntfs_noty").Perform();}}@@ -182,7 +182,7 @@ namespace GTweak.ViewBackgroundQueueManager backgroundQueue = new BackgroundQueueManager();await backgroundQueue.QueueTask(delegate { clearingMemory.StartMemoryCleanup((bool)_isWinOldRemoval); });- await backgroundQueue.QueueTask(delegate { NotificationManager.Show("info", "clear_ram_noty").WithDelay(500).Perform(); });+ await backgroundQueue.QueueTask(delegate { NotificationManager.Info("clear_ram_noty").WithDelay(500).Perform(); });}private async void BtnRegExport_ClickButton(object sender, EventArgs e)diff --git a/.Source/GTweak/Windows/ImportWindow.xaml.cs b/.Source/GTweak/Windows/ImportWindow.xaml.csindex ef53eda4..4c17f2e1 100644--- a/.Source/GTweak/Windows/ImportWindow.xaml.cs+++ b/.Source/GTweak/Windows/ImportWindow.xaml.cs@@ -19,9 +19,9 @@ namespace GTweak.Windowsprivate readonly ServicesTweaks _svcTweaks = new ServicesTweaks();private readonly SystemTweaks _sysTweaks = new SystemTweaks();private readonly CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource();- private readonly HashSet<NotificationManager.NoticeAction> _notyActions = new HashSet<NotificationManager.NoticeAction>();- private ExplorerManager.ExplorerAction _expAction = ExplorerManager.ExplorerAction.None;- private bool _isWDNotyNeed = false;+ private readonly HashSet<NotificationManager.AlertType> _pendingAlerts = new HashSet<NotificationManager.AlertType>();+ private ExplorerManager.ShellType _shellType = ExplorerManager.ShellType.None;+ private bool _defenderDisabled = false;public ImportWindow(in string importedFile){@@ -40,34 +40,25 @@ namespace GTweak.Windowsprivate async void Window_ContentRendered(object sender, EventArgs e){Progress<byte> progress = new Progress<byte>(ReportProgress);- try { await ApplyTweaksWithProgress(_cancellationTokenSource.Token, progress); } catch (Exception ex) { ErrorLogger.LogDebug(ex); }+ try { await ApplyTweaksWithProgress(_cancellationTokenSource.Token, progress); }+ catch (Exception ex) { ErrorLogger.LogDebug(ex); }}private void ReportProgress(byte valueProgress){if (valueProgress == 100){- if (_isWDNotyNeed)+ if (_defenderDisabled){- NotificationManager.Show("warn", "warn_wd_noty").Perform();+ NotificationManager.Warn("warn_wd_noty").Perform();}else{- switch (_expAction)- {- case ExplorerManager.ExplorerAction.Restart:- ExplorerManager.Restart();- break;- case ExplorerManager.ExplorerAction.Refresh:- ExplorerManager.RefreshDesktop();- break;- default:- break;- }+ ExplorerManager.Handle(_shellType);- if (_notyActions.Count != 0)+ if (_pendingAlerts.Count != 0){- NotificationManager.Show().Perform(_notyActions.Max());+ NotificationManager.Default().Perform(_pendingAlerts.Max());}}@@ -80,17 +71,17 @@ namespace GTweak.Windows{INIManager iniManager = new INIManager(PathTargets.Files.Config);- var allSections = new (string Section, Action<string, bool> TweakAction, Dictionary<Enum, NotificationManager.NoticeAction> NoticeActions, Dictionary<Enum, ExplorerManager.ExplorerAction> ExplorerMapping)[]+ var allSections = new (string Section, Action<string, bool> TweakAction)[]{- (INIManager.SectionConf, _confTweaks.Apply, NotificationManager.ConfActions, null),- (INIManager.SectionIntf, _intfTweaks.Apply, NotificationManager.IntfActions, ExplorerManager.IntfActions),- (INIManager.SectionSvc, _svcTweaks.Apply, null, null),- (INIManager.SectionSys, null, NotificationManager.SysActions, null)+ (INIManager.SectionConf, _confTweaks.Apply),+ (INIManager.SectionIntf, _intfTweaks.Apply),+ (INIManager.SectionSvc, _svcTweaks.Apply),+ (INIManager.SectionSys, null)};List<(string section, string tweak, string value)> allTweaks = new List<(string section, string tweak, string value)>();- foreach (var (Section, _, _, _) in allSections.Where(s => iniManager.IsThereSection(s.Section)))+ foreach (var (Section, _) in allSections.Where(s => iniManager.IsThereSection(s.Section))){List<string> keys = iniManager.GetKeysOrValue(Section);List<string> values = iniManager.GetKeysOrValue(Section, false);@@ -106,11 +97,9 @@ namespace GTweak.Windowsreturn;}+ string defenderTweak = $"TglButton{(int)SystemToggle.WindowsDefender}";var sysTweaks = allTweaks.Where(t => t.section == INIManager.SectionSys).ToList();- var sysTweaksLast = sysTweaks.Where(t => t.tweak == "TglButton3").ToList();- var sysTweaksFirst = sysTweaks.Where(t => t.tweak != "TglButton3").ToList();-- var tweaksToApply = allTweaks.Where(t => t.section != INIManager.SectionSys).Concat(sysTweaksFirst).Concat(sysTweaksLast).ToList();+ var tweaksToApply = allTweaks.Where(t => t.section != INIManager.SectionSys).Concat(sysTweaks.Where(t => t.tweak != defenderTweak)).Concat(sysTweaks.Where(t => t.tweak == defenderTweak)).ToList();foreach (var (section, tweak, value) in tweaksToApply){@@ -119,61 +108,48 @@ namespace GTweak.Windows{if (section == INIManager.SectionSys){- if (tweak.StartsWith("TglButton") && tweak != "TglButton3")- {- _sysTweaks.Apply(tweak, Convert.ToBoolean(value));-- if (NotificationManager.SysActions.TryGetAction(tweak, out NotificationManager.NoticeAction sysAction))- {- _notyActions.Add(sysAction);- }- }- else if (tweak == "TglButton3")+ if (tweak == defenderTweak){BackgroundQueueManager backgroundQueue = new BackgroundQueueManager();await backgroundQueue.QueueTask(delegate{_sysTweaks.Apply(tweak, Convert.ToBoolean(value), false);});-- _isWDNotyNeed = !Convert.ToBoolean(value);+ _defenderDisabled = !Convert.ToBoolean(value);+ }+ else if (tweak.StartsWith("TglButton"))+ {+ _sysTweaks.Apply(tweak, Convert.ToBoolean(value));+ AddPostAction(tweak.GetPostAction(typeof(SystemToggle)));}else{_sysTweaks.Apply(tweak, Convert.ToUInt32(value));}}- else+ else if (section == INIManager.SectionConf){- var (Section, TweakAction, NoticeActions, ExplorerMapping) = allSections.First(s => s.Section == section);-- if (section == INIManager.SectionIntf && tweak.StartsWith("ColorPicker"))+ _confTweaks.Apply(tweak, Convert.ToBoolean(value));+ AddPostAction(tweak.GetPostAction(typeof(ConfidentialityToggle)));+ }+ else if (section == INIManager.SectionIntf)+ {+ if (tweak.StartsWith("ColorPicker")){_intfTweaks.Apply(tweak, value);}else{- TweakAction?.Invoke(tweak, Convert.ToBoolean(value));- }-- if (NoticeActions != null && NoticeActions.TryGetAction(tweak, out NotificationManager.NoticeAction noticeAction))- {- _notyActions.Add(noticeAction);- }-- if (ExplorerMapping != null && ExplorerMapping.TryGetAction(tweak, out ExplorerManager.ExplorerAction expAction))- {- if (expAction > _expAction)- {- _expAction = expAction;- }- }-- if (section == INIManager.SectionSvc)- {- _notyActions.Add(NotificationManager.NoticeAction.Restart);+ _intfTweaks.Apply(tweak, Convert.ToBoolean(value));+ Type enumType = tweak.StartsWith("Checkbox") ? typeof(InterfaceCheckbox) : typeof(InterfaceToggle);+ AddPostAction(tweak.GetPostAction(enumType));}}+ else if (section == INIManager.SectionSvc)+ {+ _svcTweaks.Apply(tweak, Convert.ToBoolean(value));+ _pendingAlerts.Add(NotificationManager.AlertType.Restart);+ }}catch (Exception ex) { ErrorLogger.LogDebug(ex); }@@ -183,6 +159,19 @@ namespace GTweak.Windows}}+ private void AddPostAction(PostActionAttribute action)+ {+ if (action.HasAlert())+ {+ _pendingAlerts.Add(action.Alert);+ }++ if (action.Shell > _shellType)+ {+ _shellType = action.Shell;+ }+ }+public void Dispose(){_cancellationTokenSource.Cancel();diff --git a/.Source/GTweak/Windows/NotificationWindow.xaml b/.Source/GTweak/Windows/NotificationWindow.xamlindex c1d73eca..d4af6f84 100644--- a/.Source/GTweak/Windows/NotificationWindow.xaml+++ b/.Source/GTweak/Windows/NotificationWindow.xaml@@ -8,7 +8,7 @@mc:Ignorable="d" Icon="/GTweak.ico"Background="Transparent" WindowStyle="None" IsTabStop="False" Focusable="False" SnapsToDevicePixels="True" UseLayoutRounding="True" ShowInTaskbar="False"ExtendsContentIntoTitleBar="True" WindowBackdropType="Mica" SizeToContent="Height" ResizeMode="NoResize" WindowStartupLocation="Manual" KeyboardNavigation.TabNavigation="None"- Title="{DynamicResource title_win_noty}" Topmost="True" MinHeight="125" MinWidth="375" MaxHeight="170" MaxWidth="375" CacheMode="BitmapCache" d:CacheMode="{x:Null}">+ Title="{DynamicResource title_win_noty}" Topmost="True" MinHeight="125" MinWidth="375" MaxHeight="170" MaxWidth="375"><Grid Background="{StaticResource Brush_Background}"><Grid.RowDefinitions><RowDefinition Height="Auto"/>diff --git a/.Source/GTweak/Windows/NotificationWindow.xaml.cs b/.Source/GTweak/Windows/NotificationWindow.xaml.csindex 313ce7e1..6cfeba77 100644--- a/.Source/GTweak/Windows/NotificationWindow.xaml.cs+++ b/.Source/GTweak/Windows/NotificationWindow.xaml.cs@@ -16,13 +16,13 @@ namespace GTweak.Windowspublic partial class NotificationWindow : FluentWindow{private static readonly BitmapCache _bitmapCache = new BitmapCache { RenderAtScale = 1, EnableClearType = false };- private NotificationManager.NoticeAction _requiredAction = default;+ private NotificationManager.AlertType _alertType = default;private TimerControlManager _timer = default;private Rect primaryMonitorArea = SystemParameters.WorkArea;internal string NoticeTitle { set => Header.Text = value; get => Header.Text; }internal string NoticeText { set => MessageBody.Text = value; get => MessageBody.Text; }- internal NotificationManager.NoticeAction RequiredAction { set => _requiredAction = value; get => _requiredAction; }+ internal NotificationManager.AlertType AlertType { set => _alertType = value; get => _alertType; }public NotificationWindow(){@@ -63,9 +63,9 @@ namespace GTweak.Windowsprivate void Grid_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e){- if (RequiredAction != NotificationManager.NoticeAction.None)+ if (AlertType != NotificationManager.AlertType.None){- CommandExecutor.RunCommand(RequiredAction == NotificationManager.NoticeAction.Logout ? @"/c logoff" : @"/c shutdown /r /t 0");+ CommandExecutor.RunCommand(AlertType == NotificationManager.AlertType.Logout ? @"/c logoff" : @"/c shutdown /r /t 0");}}}diff --git a/.Source/GTweak/Windows/UpdateWindow.xaml.cs b/.Source/GTweak/Windows/UpdateWindow.xaml.csindex 68b80188..55c5102d 100644--- a/.Source/GTweak/Windows/UpdateWindow.xaml.cs+++ b/.Source/GTweak/Windows/UpdateWindow.xaml.cs@@ -49,7 +49,7 @@ namespace GTweak.Windowscatch{Close();- NotificationManager.Show("warn", "warn_update_noty").Perform();+ NotificationManager.Warn("warn_update_noty").Perform();}}}