Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
add. notification builder for easier interaction
Greedeksc7cb4d9c424b
diff --git a/.Source/GTweak/Utilities/Controls/SettingsEngine.cs b/.Source/GTweak/Utilities/Controls/SettingsEngine.csindex 5057a442..d7e28a2b 100644--- a/.Source/GTweak/Utilities/Controls/SettingsEngine.cs+++ b/.Source/GTweak/Utilities/Controls/SettingsEngine.cs@@ -82,7 +82,7 @@ namespace GTweak.Utilities.Controlsinternal static void SaveFileConfig(){if (INIManager.IsAllTempDictionaryEmpty)- new NotificationManager().Show("", "info", "export_warning_notification");+ new NotificationManager().Show("info", "export_warning_notification").None();else{VistaSaveFileDialog vistaSaveFileDialog = new VistaSaveFileDialog@@ -133,10 +133,10 @@ namespace GTweak.Utilities.Controlsif (File.ReadLines(PathLocator.Files.Config).Any(line => line.Contains("TglButton")) || File.ReadLines(PathLocator.Files.Config).Any(line => line.Contains("Slider")))new ImportWindow(Path.GetFileName(vistaOpenFileDialog.FileName)).ShowDialog();else- new NotificationManager().Show("", "info", "empty_import_notification");+ new NotificationManager().Show("info", "empty_import_notification").None();}else- new NotificationManager().Show("", "info", "warn_import_notification");+ new NotificationManager().Show("info", "warn_import_notification").None();}internal static void SelfRemoval()diff --git a/.Source/GTweak/Utilities/Managers/NotificationManager.cs b/.Source/GTweak/Utilities/Managers/NotificationManager.csindex 83b66fe0..b7dc915f 100644--- a/.Source/GTweak/Utilities/Managers/NotificationManager.cs+++ b/.Source/GTweak/Utilities/Managers/NotificationManager.cs@@ -1,93 +1,102 @@using GTweak.Utilities.Controls;using GTweak.Windows;using System.Collections.Generic;-using System.Linq;using System.Threading;using System.Threading.Tasks;using System.Windows;namespace GTweak.Utilities.Managers{- internal sealed class NotificationManager+ internal class NotificationManager{- internal static readonly Dictionary<string, string> ConfActions = new[]+ internal enum NoticeAction { None, Logout, Restart }++ internal static readonly Dictionary<string, NoticeAction> ConfActions = new Dictionary<string, NoticeAction>(){- new { Button = "TglButton8", Action = "restart" },- new { Button = "TglButton15", Action = "restart" }- }.ToDictionary(x => x.Button, x => x.Action);+ ["TglButton8"] = NoticeAction.Restart,+ ["TglButton15"] = NoticeAction.Restart+ };- internal static readonly Dictionary<string, string> IntfActions = new[]+ internal static readonly Dictionary<string, NoticeAction> IntfActions = new Dictionary<string, NoticeAction>(){- new { Button = "TglButton1", Action = "logout" },- new { Button = "TglButton2", Action = "logout" },- new { Button = "TglButton3", Action = "logout" },- new { Button = "TglButton4", Action = "logout" },- new { Button = "TglButton5", Action = "logout" },- new { Button = "TglButton10", Action = "logout" },- new { Button = "TglButton11", Action = "logout" },- new { Button = "TglButton12", Action = "logout" },- new { Button = "TglButton22", Action = "restart" },- new { Button = "TglButton20", Action = "restart" }- }.ToDictionary(x => x.Button, x => x.Action);+ ["TglButton1"] = NoticeAction.Logout,+ ["TglButton2"] = NoticeAction.Logout,+ ["TglButton3"] = NoticeAction.Logout,+ ["TglButton4"] = NoticeAction.Logout,+ ["TglButton5"] = NoticeAction.Logout,+ ["TglButton10"] = NoticeAction.Logout,+ ["TglButton11"] = NoticeAction.Logout,+ ["TglButton12"] = NoticeAction.Logout,+ ["TglButton22"] = NoticeAction.Restart,+ ["TglButton20"] = NoticeAction.Restart+ };- internal static readonly Dictionary<string, string> SysActions = new[]+ internal static readonly Dictionary<string, NoticeAction> SysActions = new Dictionary<string, NoticeAction>(){- new { Button = "TglButton2", Action = "logout" },- new { Button = "TglButton7", Action = "restart" },- new { Button = "TglButton8", Action = "restart" },- new { Button = "TglButton9", Action = "restart" },- new { Button = "TglButton10", Action = "restart" },- new { Button = "TglButton12", Action = "restart" },- new { Button = "TglButton13", Action = "restart" },- new { Button = "TglButton14", Action = "restart" },- new { Button = "TglButton15", Action = "restart" },- new { Button = "TglButton20", Action = "restart" },- new { Button = "TglButton23", Action = "restart" },- new { Button = "TglButton25", Action = "restart" },- new { Button = "TglButton27", Action = "restart" },- }.ToDictionary(x => x.Button, x => x.Action);+ ["TglButton2"] = NoticeAction.Logout,+ ["TglButton7"] = NoticeAction.Restart,+ ["TglButton8"] = NoticeAction.Restart,+ ["TglButton9"] = NoticeAction.Restart,+ ["TglButton10"] = NoticeAction.Restart,+ ["TglButton12"] = NoticeAction.Restart,+ ["TglButton13"] = NoticeAction.Restart,+ ["TglButton14"] = NoticeAction.Restart,+ ["TglButton15"] = NoticeAction.Restart,+ ["TglButton20"] = NoticeAction.Restart,+ ["TglButton23"] = NoticeAction.Restart,+ ["TglButton25"] = NoticeAction.Restart,+ ["TglButton27"] = NoticeAction.Restart+ };private readonly int _delayMs;- private static int _isNotificationOpen = 0;internal NotificationManager(int delayMs = 100) => _delayMs = delayMs;- internal async void Show(string action, string titleKey = "", string textKey = "")+ internal NotificationBuilder Show(string titleKey = "", string textKey = "") => new NotificationBuilder(_delayMs, (string)Application.Current.TryFindResource($"title_{titleKey}_notification") ?? string.Empty, (string)Application.Current.TryFindResource(textKey) ?? string.Empty);+ }++ internal sealed class NotificationBuilder : NotificationManager+ {+ private static int _isNotificationOpen;+ private readonly int _delayMs;+ private readonly string _title = string.Empty, _text = string.Empty;++ internal NotificationBuilder(int delayMs, string title, string text)+ {+ _delayMs = delayMs;+ _title = title;+ _text = text;+ }++ internal void None() => ShowNotification(NoticeAction.None);+ internal void Logout() => ShowNotification(NoticeAction.Logout);+ internal void Restart() => ShowNotification(NoticeAction.Restart);+ internal void Execute(NoticeAction action) => ShowNotification(action);++ private async void ShowNotification(NoticeAction action){if (SettingsEngine.IsViewNotification && Interlocked.CompareExchange(ref _isNotificationOpen, 1, 0) == 0){await Application.Current.Dispatcher.InvokeAsync(async () =>{- var window = new NotificationWindow+ NotificationWindow window = new NotificationWindow{- ActionNotice = action,- TitleNotice = (string)Application.Current.TryFindResource($"title_{titleKey}_notification") ?? string.Empty,- TextNotice = (string)Application.Current.TryFindResource(textKey) ?? string.Empty,+ NoticeTitle = _title,+ NoticeText = _text,+ RequiredAction = action};- switch (window.ActionNotice)+ if (string.IsNullOrWhiteSpace(window.NoticeTitle) && string.IsNullOrWhiteSpace(window.NoticeText)){- case "logout":- if (string.IsNullOrWhiteSpace(window.TitleNotice) || string.IsNullOrWhiteSpace(window.TextNotice))- {- window.TitleNotice = (string)Application.Current.Resources["title_warn_notification"];- window.TextNotice = (string)Application.Current.Resources["logout_notification"];- }- break;- case "restart":- if (string.IsNullOrWhiteSpace(window.TitleNotice) || string.IsNullOrWhiteSpace(window.TextNotice))- {- window.TitleNotice = (string)Application.Current.Resources["title_warn_notification"];- window.TextNotice = (string)Application.Current.Resources["restart_notification"];- }- break;+ window.NoticeTitle = (string)Application.Current.Resources["title_warn_notification"];+ window.NoticeText = (string)Application.Current.Resources[window.RequiredAction == NoticeAction.Logout ? "logout_notification" : "restart_notification"];}- window.Closed += (s, e) => { Interlocked.Exchange(ref _isNotificationOpen, 0); };+ window.Closed += (s, e) => Interlocked.Exchange(ref _isNotificationOpen, 0);await Task.Delay(_delayMs).ContinueWith(_ => { if (window != null && !window.IsVisible) window.Show(); }, TaskScheduler.FromCurrentSynchronizationContext());});}}}-}+}\ No newline at end of filediff --git a/.Source/GTweak/Utilities/Tweaks/Firewall.cs b/.Source/GTweak/Utilities/Tweaks/Firewall.csindex 24a30b7a..b1de4bf8 100644--- a/.Source/GTweak/Utilities/Tweaks/Firewall.cs+++ b/.Source/GTweak/Utilities/Tweaks/Firewall.cs@@ -67,7 +67,7 @@ namespace GTweak.Utilities.TweaksChangeRules(isDisabled, executableFiles.Item1, executableFiles.Item2, NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_OUT);});}- catch { new NotificationManager().Show("", "warn", "warn_firewall_notification"); }+ catch { new NotificationManager().Show("warn", "warn_firewall_notification").None(); }}@@ -98,7 +98,7 @@ namespace GTweak.Utilities.Tweaksprotected static void BlockSpyDomain(in bool isDisabled){try { RulesHosts(isDisabled); }- catch { new NotificationManager().Show("", "warn", "warn_firewall_notification"); }+ catch { new NotificationManager().Show("warn", "warn_firewall_notification").None(); }}private static void RulesHosts(in bool isDisabled)diff --git a/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.cs b/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.csindex eb50cc47..d212bc3e 100644--- a/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.cs+++ b/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.cs@@ -33,10 +33,10 @@ namespace GTweak.Utilities.TweaksRegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\services\defragsvc", "Start", 2, RegistryValueKind.DWord);RegistryHelp.Write(Registry.LocalMachine, @"SOFTWARE\Microsoft\Dfrg\BootOptimizeFunction", "Enable", "Y", RegistryValueKind.String);- new NotificationManager(300).Show("", "info", "success_defrag_on_notification");+ new NotificationManager(300).Show("info", "success_defrag_on_notification").None();}else- new NotificationManager().Show("", "info", "warn_defrag_on_notification");+ new NotificationManager().Show("info", "warn_defrag_on_notification").None();}else{@@ -46,13 +46,13 @@ namespace GTweak.Utilities.TweaksRegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\services\defragsvc", "Start", 4, RegistryValueKind.DWord);RegistryHelp.Write(Registry.LocalMachine, @"SOFTWARE\Microsoft\Dfrg\BootOptimizeFunction", "Enable", "N", RegistryValueKind.String);- new NotificationManager(300).Show("", "info", "success_defrag_off_notification");+ new NotificationManager(300).Show("info", "success_defrag_off_notification").None();}else- new NotificationManager().Show("", "info", "warn_defrag_off_notification");+ new NotificationManager().Show("info", "warn_defrag_off_notification").None();}}- catch { new NotificationManager().Show("", "warn", "error_defrag_notification"); }+ catch { new NotificationManager().Show("warn", "error_defrag_notification").None(); }}@@ -77,13 +77,13 @@ namespace GTweak.Utilities.Tweaks_outParams = _restorePoint.InvokeMethod("CreateRestorePoint", _inParams, null);if ((uint)_outParams["ReturnValue"] == 0)- new NotificationManager(300).Show("", "info", "success_point_notification");+ new NotificationManager(300).Show("info", "success_point_notification").None();else- new NotificationManager(300).Show("", "warn", "error_point_notification");+ new NotificationManager(300).Show("warn", "error_point_notification").None();RegistryHelp.DeleteValue(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore", "SystemRestorePointCreationFrequency");}- catch { new NotificationManager().Show("", "warn", "error_point_notification"); }+ catch { new NotificationManager().Show("warn", "error_point_notification").None(); }}internal static void StartRecovery()@@ -93,7 +93,7 @@ namespace GTweak.Utilities.TweaksEnableRecovery();CommandExecutor.RunCommand("/c rstrui.exe");}- catch { new NotificationManager().Show("", "warn", "error_recovery_notification"); }+ catch { new NotificationManager().Show("warn", "error_recovery_notification").None(); }}internal static void DisableRestorePoint()@@ -112,7 +112,7 @@ namespace GTweak.Utilities.TweaksDisableSR(PathLocator.Folders.SystemDrive + @"\\");}else- new NotificationManager().Show("", "info", "warn_recovery_notification");+ new NotificationManager().Show("info", "warn_recovery_notification").None();}private static void EnableRecovery()diff --git a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.csindex 140c8bfa..37fc3ace 100644--- a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs+++ b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs@@ -279,9 +279,9 @@ namespace GTweak.Utilities.TweakswaitingWindow.Show();BackgroundQueue backgroundQueue = new BackgroundQueue();- await backgroundQueue.QueueTask(delegate { new NotificationManager().Show("", "info", "defender_notification"); });+ await backgroundQueue.QueueTask(delegate { new NotificationManager().Show("info", "defender_notification").None(); });await backgroundQueue.QueueTask(delegate { WindowsDefender.SetProtectionState(isDisabled); });- await backgroundQueue.QueueTask(delegate { new NotificationManager(300).Show("restart"); });+ await backgroundQueue.QueueTask(delegate { new NotificationManager(300).Show().Restart(); });waitingWindow.Close();}elsediff --git a/.Source/GTweak/Utilities/Tweaks/WindowsLicense.cs b/.Source/GTweak/Utilities/Tweaks/WindowsLicense.csindex 751ad966..5b07e8a7 100644--- a/.Source/GTweak/Utilities/Tweaks/WindowsLicense.cs+++ b/.Source/GTweak/Utilities/Tweaks/WindowsLicense.cs@@ -38,11 +38,11 @@ namespace GTweak.Utilities.Tweaksif (string.IsNullOrEmpty(keyWinHWID) && string.IsNullOrEmpty(keyWinKMS)){- new NotificationManager(300).Show("", "warn", "keynotfound_notification");+ new NotificationManager(300).Show("warn", "keynotfound_notification").None();return;}- new NotificationManager().Show("", "warn", "win_activate_notification");+ new NotificationManager().Show("warn", "win_activate_notification").None();WaitingWindow waitingWindow = new WaitingWindow();waitingWindow.Show();@@ -82,7 +82,7 @@ namespace GTweak.Utilities.Tweaksif (IsWindowsActivated){waitingWindow.Close();- new NotificationManager(300).Show("restart", "warn", "success_activate_notification");+ new NotificationManager(300).Show("warn", "success_activate_notification").Restart();}else{@@ -96,13 +96,13 @@ namespace GTweak.Utilities.TweakswaitingWindow.Close();- new NotificationManager(300).Show(IsWindowsActivated ? "restart" : "", "warn", IsWindowsActivated ? "success_activate_notification" : "error_activate_notification");+ new NotificationManager(300).Show("warn", IsWindowsActivated ? "success_activate_notification" : "error_activate_notification").Execute(IsWindowsActivated ? NotificationManager.NoticeAction.Restart : NotificationManager.NoticeAction.None);}}catch{waitingWindow.Close();- new NotificationManager(300).Show("", "warn", "error_activate_notification");+ new NotificationManager(300).Show("warn", "error_activate_notification").None();}}}diff --git a/.Source/GTweak/View/ConfidentialityView.xaml.cs b/.Source/GTweak/View/ConfidentialityView.xaml.csindex f193e858..5e2d485a 100644--- a/.Source/GTweak/View/ConfidentialityView.xaml.cs+++ b/.Source/GTweak/View/ConfidentialityView.xaml.cs@@ -38,8 +38,8 @@ namespace GTweak.View_confTweaks.ApplyTweaks(toggleButton.Name, toggleButton.State);- if (NotificationManager.ConfActions.TryGetValue(toggleButton.Name, out string action))- new NotificationManager(300).Show(action);+ if (NotificationManager.ConfActions.TryGetValue(toggleButton.Name, out NotificationManager.NoticeAction action))+ new NotificationManager(300).Show().Execute(action);Parallel.Invoke(async delegate { await Task.Delay(1000); _confTweaks.AnalyzeAndUpdate(this); });}diff --git a/.Source/GTweak/View/InterfaceView.xaml.cs b/.Source/GTweak/View/InterfaceView.xaml.csindex 5a669798..42c56509 100644--- a/.Source/GTweak/View/InterfaceView.xaml.cs+++ b/.Source/GTweak/View/InterfaceView.xaml.cs@@ -22,7 +22,7 @@ namespace GTweak.ViewInitializeComponent();if (!WindowsLicense.IsWindowsActivated)- new NotificationManager().Show("", "info", "warn_activate_notification");+ new NotificationManager().Show("info", "warn_activate_notification").None();if (SystemDiagnostics.HardwareData.OSBuild.CompareTo("22621.2361") < 0)TglButton21.IsEnabled = false;@@ -73,8 +73,8 @@ namespace GTweak.Viewif (ExplorerManager.IntfMapping.TryGetValue(toggleButton.Name, out bool needRestart))ExplorerManager.Restart(new Process());- if (NotificationManager.IntfActions.TryGetValue(toggleButton.Name, out string action))- new NotificationManager(300).Show(action);+ if (NotificationManager.IntfActions.TryGetValue(toggleButton.Name, out NotificationManager.NoticeAction action))+ new NotificationManager(300).Show().Execute(action);Parallel.Invoke(async delegate { await Task.Delay(1000); _intfTweaks.AnalyzeAndUpdate(this); });}diff --git a/.Source/GTweak/View/MoreView.xaml.cs b/.Source/GTweak/View/MoreView.xaml.csindex 2d8e6380..e57a4460 100644--- a/.Source/GTweak/View/MoreView.xaml.cs+++ b/.Source/GTweak/View/MoreView.xaml.cs@@ -23,13 +23,13 @@ namespace GTweak.Viewprivate async void BtnLicenseWindows_ClickButton(object sender, EventArgs e){if (WindowsLicense.IsWindowsActivated)- new NotificationManager().Show("", "info", "ready_activate_notification");+ new NotificationManager().Show("info", "ready_activate_notification").None();else{if (new SystemDiagnostics().IsNetworkAvailable())await WindowsLicense.StartActivation();else- new NotificationManager().Show("", "warn", "network_activate_notification");+ new NotificationManager().Show("warn", "network_activate_notification").None();}}@@ -37,7 +37,7 @@ namespace GTweak.View{WaitingWindow waitingWindow = new WaitingWindow();waitingWindow.Show();- new NotificationManager().Show("", "info", "createpoint_notification");+ new NotificationManager().Show("info", "createpoint_notification").None();BackgroundQueue backgroundQueue = new BackgroundQueue();await backgroundQueue.QueueTask(delegate { SystemMaintenance.CreateRestorePoint(); });waitingWindow.Close();@@ -55,7 +55,7 @@ namespace GTweak.ViewBackgroundQueue backgroundQueue = new BackgroundQueue();await backgroundQueue.QueueTask(delegate { ClearingMemory.StartMemoryCleanupAsync(_isWinOldRemoval); });- await backgroundQueue.QueueTask(delegate { new NotificationManager(500).Show("", "info", "clear_ram_notification"); });+ await backgroundQueue.QueueTask(delegate { new NotificationManager(500).Show("info", "clear_ram_notification").None(); });}private void BtnDisableDefrag_ClickButton(object sender, EventArgs e) => SystemMaintenance.SetDefragState(false);@@ -67,7 +67,7 @@ namespace GTweak.View{try { SystemMaintenance.DisableRestorePoint(); } catch (Exception ex) { ErrorLogging.LogDebug(ex); }});- await backgroundQueue.QueueTask(delegate { new NotificationManager(300).Show("", "info", "disable_recovery_notification"); });+ await backgroundQueue.QueueTask(delegate { new NotificationManager(300).Show("info", "disable_recovery_notification").None(); });}private void BtnEnableDefrag_ClickButton(object sender, EventArgs e) => SystemMaintenance.SetDefragState(true);@@ -88,15 +88,15 @@ namespace GTweak.Viewawait backgroundQueue.QueueTask(delegate{try { NTFSCompressor.SetCompression(selectedPath, true); }- catch { new NotificationManager().Show("", "warn", "error_compression_notification"); }+ catch { new NotificationManager().Show("warn", "error_compression_notification").None(); }});- await backgroundQueue.QueueTask(delegate { new NotificationManager(500).Show("", "info", "success_compression_notification"); });+ await backgroundQueue.QueueTask(delegate { new NotificationManager(500).Show("info", "success_compression_notification").None(); });}else- new NotificationManager().Show("", "info", "ready_compression_notification");+ new NotificationManager().Show("info", "ready_compression_notification").None();}else- new NotificationManager().Show("", "warn", "notsupport_ntfs_notification");+ new NotificationManager().Show("warn", "notsupport_ntfs_notification").None();}private async void BtnDecompression_ClickButton(object sender, EventArgs e)@@ -115,16 +115,16 @@ namespace GTweak.Viewawait backgroundQueue.QueueTask(delegate{try { NTFSCompressor.SetCompression(selectedPath, false); }- catch { new NotificationManager().Show("", "warn", "error_compression_notification"); }+ catch { new NotificationManager().Show("warn", "error_compression_notification").None(); }});- await backgroundQueue.QueueTask(delegate { new NotificationManager(500).Show("", "info", "success_decompression_notification"); });+ await backgroundQueue.QueueTask(delegate { new NotificationManager(500).Show("info", "success_decompression_notification").None(); });}else- new NotificationManager().Show("", "info", "ready_decompression_notification");+ new NotificationManager().Show("info", "ready_decompression_notification").None();}else- new NotificationManager().Show("", "warn", "notsupport_ntfs_notification");+ new NotificationManager().Show("warn", "notsupport_ntfs_notification").None();}}}diff --git a/.Source/GTweak/View/PakagesView.xaml.cs b/.Source/GTweak/View/PakagesView.xaml.csindex 8cfe357e..ca6900fc 100644--- a/.Source/GTweak/View/PakagesView.xaml.cs+++ b/.Source/GTweak/View/PakagesView.xaml.cs@@ -102,10 +102,10 @@ namespace GTweak.Viewcase MouseButtonState.Pressed when Equals(packageImage.Source, FindResource("DA_DI_" + packageName)) && packageName == "OneDrive":{if (string.IsNullOrWhiteSpace(PathLocator.Executable.OneDrive))- new NotificationManager().Show("", "warn", "error_onedrive_notification");+ new NotificationManager().Show("warn", "error_onedrive_notification").None();else{- new NotificationManager().Show("", "info", "success_onedrive_notification");+ new NotificationManager().Show("info", "success_onedrive_notification").None();await backgroundQueue.QueueTask(async () =>{diff --git a/.Source/GTweak/View/ServicesView.xaml.cs b/.Source/GTweak/View/ServicesView.xaml.csindex 2cc09d7c..267d9ef8 100644--- a/.Source/GTweak/View/ServicesView.xaml.cs+++ b/.Source/GTweak/View/ServicesView.xaml.cs@@ -35,7 +35,7 @@ namespace GTweak.View{_svcTweaks.ApplyTweaks(((ToggleButton)sender).Name, ((ToggleButton)sender).State);- new NotificationManager(300).Show("restart");+ new NotificationManager(300).Show().Restart();Parallel.Invoke(async delegate { await Task.Delay(((ToggleButton)sender).Name.Contains("15") ? 2000 : 1000); _svcTweaks.AnalyzeAndUpdate(this); });}diff --git a/.Source/GTweak/View/SystemView.xaml.cs b/.Source/GTweak/View/SystemView.xaml.csindex 3d2fb414..06604d95 100644--- a/.Source/GTweak/View/SystemView.xaml.cs+++ b/.Source/GTweak/View/SystemView.xaml.cs@@ -49,8 +49,8 @@ namespace GTweak.View{_sysTweaks.ApplyTweaks(toggleButton.Name, toggleButton.State);- if (NotificationManager.SysActions.TryGetValue(toggleButton.Name, out string action))- new NotificationManager(300).Show(action);+ if (NotificationManager.SysActions.TryGetValue(toggleButton.Name, out NotificationManager.NoticeAction action))+ new NotificationManager(300).Show().Execute(action);Parallel.Invoke(async delegate { await Task.Delay(1000); _sysTweaks.AnalyzeAndUpdate(this); });}diff --git a/.Source/GTweak/Windows/ImportWindow.xaml.cs b/.Source/GTweak/Windows/ImportWindow.xaml.csindex d1a1254e..3403922f 100644--- a/.Source/GTweak/Windows/ImportWindow.xaml.cs+++ b/.Source/GTweak/Windows/ImportWindow.xaml.cs@@ -21,7 +21,7 @@ namespace GTweak.Windowsprivate readonly ServicesTweaks _svcTweaks = new ServicesTweaks();private readonly SystemTweaks _sysTweaks = new SystemTweaks();private readonly CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource();- private readonly HashSet<string> _requiredActions = new HashSet<string>();+ private readonly HashSet<NotificationManager.NoticeAction> _requiredActions = new HashSet<NotificationManager.NoticeAction>();private bool _isExpRestartNeed = false;public ImportWindow(in string importedFile)@@ -50,10 +50,8 @@ namespace GTweak.Windowsif (_isExpRestartNeed)ExplorerManager.Restart(new Process());- if (_requiredActions.Contains("restart"))- new NotificationManager().Show("restart");- else if (_requiredActions.Contains("logout"))- new NotificationManager().Show("logout");+ if (_requiredActions.Count != 0)+ new NotificationManager().Show().Execute(_requiredActions.Max());App.UpdateImport();BeginAnimation(OpacityProperty, FactoryAnimation.CreateTo(0.1, () => { Close(); }));@@ -64,7 +62,7 @@ namespace GTweak.Windows{INIManager iniManager = new INIManager(PathLocator.Files.Config);- var allSections = new (string Section, Action<string, bool> TweakAction, IEnumerable<KeyValuePair<string, string>> NotificationActions, IEnumerable<KeyValuePair<string, bool>> ExplorerMapping)[]+ var allSections = new (string Section, Action<string, bool> TweakAction, IEnumerable<KeyValuePair<string, NotificationManager.NoticeAction>> NoticeActions, IEnumerable<KeyValuePair<string, bool>> ExplorerMapping)[]{(INIManager.SectionConf, _confTweaks.ApplyTweaks, NotificationManager.ConfActions, null),(INIManager.SectionIntf, _intfTweaks.ApplyTweaks, NotificationManager.IntfActions, ExplorerManager.IntfMapping),@@ -108,13 +106,13 @@ namespace GTweak.Windows}else{- var (Section, TweakAction, NotificationActions, ExplorerMapping) = allSections.First(s => s.Section == section);+ var (Section, TweakAction, NoticeActions, ExplorerMapping) = allSections.First(s => s.Section == section);TweakAction?.Invoke(tweak, Convert.ToBoolean(value));- if (NotificationActions != null)+ if (NoticeActions != null){- foreach (var act in NotificationActions.Where(get => get.Key == tweak))+ foreach (var act in NoticeActions.Where(get => get.Key == tweak))_requiredActions.Add(act.Value);}@@ -122,7 +120,7 @@ namespace GTweak.Windows_isExpRestartNeed = true;if (section == INIManager.SectionSvc)- _requiredActions.Add("restart");+ _requiredActions.Add(NotificationManager.NoticeAction.Restart);}}catch (Exception ex) { ErrorLogging.LogDebug(ex); }diff --git a/.Source/GTweak/Windows/NotificationWindow.xaml b/.Source/GTweak/Windows/NotificationWindow.xamlindex 5f73e1a1..ceed1382 100644--- a/.Source/GTweak/Windows/NotificationWindow.xaml+++ b/.Source/GTweak/Windows/NotificationWindow.xaml@@ -96,7 +96,7 @@</Grid.RowDefinitions><Grid Grid.Row="0">- <TextBlock x:Name="TitleSet" Text="Title" Foreground="{StaticResource Color_Highlighted}" Height="auto" FontFamily="{StaticResource Jura}" FontSize="15" TextWrapping="Wrap"+ <TextBlock x:Name="Header" Text="Title" Foreground="{StaticResource Color_Highlighted}" Height="auto" FontFamily="{StaticResource Jura}" FontSize="15" TextWrapping="Wrap"HorizontalAlignment="Left" TextAlignment="Left" FontStretch="Medium"><TextBlock.Effect><DropShadowEffect Opacity="0.2"/>@@ -105,7 +105,7 @@</Grid><Grid Grid.Row="1">- <TextBlock x:Name="TextSet" Text="Text" Foreground="{StaticResource Color_TetBlock_Inactivity}" Height="auto" FontFamily="{StaticResource Jura}" FontSize="14" TextWrapping="Wrap"+ <TextBlock x:Name="MessageBody" Text="Text" Foreground="{StaticResource Color_TetBlock_Inactivity}" Height="auto" FontFamily="{StaticResource Jura}" FontSize="14" TextWrapping="Wrap"HorizontalAlignment="Left" TextAlignment="Left" FontStretch="Medium" MaxWidth="265" Margin="0,0,0,3"><TextBlock.Effect><DropShadowEffect Opacity="0.2"/>diff --git a/.Source/GTweak/Windows/NotificationWindow.xaml.cs b/.Source/GTweak/Windows/NotificationWindow.xaml.csindex c1c85172..b189bffb 100644--- a/.Source/GTweak/Windows/NotificationWindow.xaml.cs+++ b/.Source/GTweak/Windows/NotificationWindow.xaml.cs@@ -14,10 +14,10 @@ namespace GTweak.Windows{public partial class NotificationWindow{- private string clickAction = string.Empty;- internal string TitleNotice { set => TitleSet.Text = value; get => TitleSet.Text; }- internal string TextNotice { set => TextSet.Text = value; get => TextSet.Text; }- internal string ActionNotice { set => clickAction = value; get => clickAction; }+ private NotificationManager.NoticeAction _requiredAction = default;+ 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; }public NotificationWindow(){@@ -35,14 +35,8 @@ namespace GTweak.Windowsprivate void ActionSelection_PreviewMouseDown(object sender, MouseButtonEventArgs e){- if (e.LeftButton == MouseButtonState.Pressed && !string.IsNullOrEmpty(ActionNotice))- {- CommandExecutor.RunCommand(ActionNotice switch- {- "logout" => @"/c logoff",- _ => @"/c shutdown /r /t 0",- });- }+ if (e.LeftButton == MouseButtonState.Pressed && RequiredAction != NotificationManager.NoticeAction.None)+ CommandExecutor.RunCommand(RequiredAction == NotificationManager.NoticeAction.Logout ? @"/c logoff" : @"/c shutdown /r /t 0");}private void Window_Loaded(object sender, RoutedEventArgs e)diff --git a/.Source/GTweak/Windows/UpdateWindow.xaml.cs b/.Source/GTweak/Windows/UpdateWindow.xaml.csindex a1c3dfcc..6397b186 100644--- a/.Source/GTweak/Windows/UpdateWindow.xaml.cs+++ b/.Source/GTweak/Windows/UpdateWindow.xaml.cs@@ -73,7 +73,7 @@ namespace GTweak.Windowscatch{Close();- new NotificationManager().Show("", "warn", "warn_update_notification");+ new NotificationManager().Show("warn", "warn_update_notification").None();}}}