Skip to content

Portable Tool for an Ideal Windows Setup

-storing actions for notification

Greedeksbd9fbfae6193
diff --git a/.Source/GTweak/GTweak.csproj b/.Source/GTweak/GTweak.csproj
index 0766895b..613384b2 100644
--- a/.Source/GTweak/GTweak.csproj
+++ b/.Source/GTweak/GTweak.csproj
@@ -273,6 +273,7 @@
<Compile Include="Utilities\Helpers\RegistryHelp.cs" />
<Compile Include="Utilities\Control\SettingsRepository.cs" />
<Compile Include="Utilities\Helpers\TakingOwnership.cs" />
+ <Compile Include="Utilities\Helpers\Storage\NotifActionsStorage.cs" />
<Compile Include="Utilities\Tweaks\ClearingMemory.cs" />
<Compile Include="Utilities\Helpers\INIManager.cs" />
<Compile Include="Utilities\Control\QueryUpdates.cs" />
@@ -286,7 +287,7 @@
<Compile Include="Utilities\Tweaks\ServicesTweaks.cs" />
<Compile Include="Utilities\Tweaks\SystemMaintenance.cs" />
<Compile Include="Utilities\Tweaks\SystemTweaks.cs" />
- <Compile Include="Utilities\Helpers\TaskStorage.cs" />
+ <Compile Include="Utilities\Helpers\Storage\TaskStorage.cs" />
<Compile Include="Utilities\Tweaks\UninstallingPakages.cs" />
<Compile Include="Utilities\Tweaks\WindowsDefender.cs" />
<Compile Include="Utilities\Tweaks\WindowsLicense.cs" />
diff --git a/.Source/GTweak/Utilities/Helpers/Storage/NotifActionsStorage.cs b/.Source/GTweak/Utilities/Helpers/Storage/NotifActionsStorage.cs
new file mode 100644
index 00000000..a673cd5d
--- /dev/null
+++ b/.Source/GTweak/Utilities/Helpers/Storage/NotifActionsStorage.cs
@@ -0,0 +1,43 @@
+using System.Collections.Generic;
+using System.Linq;
+
+namespace GTweak.Utilities.Helpers.Storage
+{
+ internal class NotifActionsStorage
+ {
+ internal static readonly Dictionary<string, string> GetConfActions = new[]
+ {
+ new { Button = "TglButton8", Action = "restart" },
+ new { Button = "TglButton15", Action = "restart" }
+ }.ToDictionary(x => x.Button, x => x.Action);
+
+ internal static readonly Dictionary<string, string> GetIntfActions = new[]
+ {
+ 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 = "TglButton26", Action = "logout" },
+ new { Button = "TglButton27", Action = "logout" },
+ new { Button = "TglButton22", Action = "restart" },
+ new { Button = "TglButton20", Action = "restart" }
+ }.ToDictionary(x => x.Button, x => x.Action);
+
+ internal static readonly Dictionary<string, string> GetSysActions = new[]
+ {
+ new { Button = "TglButton2", Action = "logout" },
+ new { Button = "TglButton7", 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" }
+ }.ToDictionary(x => x.Button, x => x.Action);
+ }
+}
diff --git a/.Source/GTweak/Utilities/Helpers/TaskStorage.cs b/.Source/GTweak/Utilities/Helpers/Storage/TaskStorage.cs
similarity index 97%
rename from .Source/GTweak/Utilities/Helpers/TaskStorage.cs
rename to .Source/GTweak/Utilities/Helpers/Storage/TaskStorage.cs
index bd93a167..09698ee6 100644
--- a/.Source/GTweak/Utilities/Helpers/TaskStorage.cs
+++ b/.Source/GTweak/Utilities/Helpers/Storage/TaskStorage.cs
@@ -1,4 +1,4 @@
-namespace GTweak.Utilities.Helpers
+namespace GTweak.Utilities.Helpers.Storage
{
internal class TaskStorage
{
diff --git a/.Source/GTweak/Utilities/Helpers/TaskSchedulerManager.cs b/.Source/GTweak/Utilities/Helpers/TaskSchedulerManager.cs
index 2be7ad1d..3729c364 100644
--- a/.Source/GTweak/Utilities/Helpers/TaskSchedulerManager.cs
+++ b/.Source/GTweak/Utilities/Helpers/TaskSchedulerManager.cs
@@ -1,4 +1,5 @@
using GTweak.Utilities.Control;
+using GTweak.Utilities.Helpers.Storage;
using System.Linq;
using System.Threading.Tasks;
diff --git a/.Source/GTweak/View/ConfidentialityView.xaml.cs b/.Source/GTweak/View/ConfidentialityView.xaml.cs
index c01e0213..812b67ed 100644
--- a/.Source/GTweak/View/ConfidentialityView.xaml.cs
+++ b/.Source/GTweak/View/ConfidentialityView.xaml.cs
@@ -1,5 +1,6 @@
using GTweak.Assets.UserControl;
using GTweak.Utilities.Control;
+using GTweak.Utilities.Helpers.Storage;
using GTweak.Utilities.Tweaks;
using System;
using System.Threading.Tasks;
@@ -36,13 +37,8 @@ namespace GTweak.View
ConfidentialityTweaks.ApplyTweaks(toggleButton.Name, toggleButton.State);
- switch (toggleButton.Name)
- {
- case "TglButton8":
- case "TglButton15":
- new ViewNotification(300).Show("restart");
- break;
- }
+ if (NotifActionsStorage.GetConfActions.TryGetValue(toggleButton.Name, out string action))
+ new ViewNotification(300).Show(action);
Parallel.Invoke(async delegate { await Task.Delay(1000); new ConfidentialityTweaks().AnalyzeAndUpdate(this); });
}
diff --git a/.Source/GTweak/View/InterfaceView.xaml.cs b/.Source/GTweak/View/InterfaceView.xaml.cs
index c4ba7f8e..94fc349f 100644
--- a/.Source/GTweak/View/InterfaceView.xaml.cs
+++ b/.Source/GTweak/View/InterfaceView.xaml.cs
@@ -1,6 +1,7 @@
using GTweak.Assets.UserControl;
using GTweak.Utilities.Control;
using GTweak.Utilities.Helpers;
+using GTweak.Utilities.Helpers.Storage;
using GTweak.Utilities.Tweaks;
using System;
using System.Threading.Tasks;
@@ -63,25 +64,8 @@ namespace GTweak.View
ToggleButton toggleButton = (ToggleButton)sender;
InterfaceTweaks.ApplyTweaks(toggleButton.Name, toggleButton.State);
- switch (toggleButton.Name)
- {
- case "TglButton1":
- case "TglButton2":
- case "TglButton3":
- case "TglButton4":
- case "TglButton5":
- case "TglButton10":
- case "TglButton11":
- case "TglButton12":
- case "TglButton26":
- case "TglButton27":
- new ViewNotification(300).Show("logout");
- break;
- case "TglButton22":
- case "TglButton20":
- new ViewNotification(300).Show("restart");
- break;
- }
+ if (NotifActionsStorage.GetIntfActions.TryGetValue(toggleButton.Name, out string action))
+ new ViewNotification(300).Show(action);
Parallel.Invoke(async delegate { await Task.Delay(1000); new InterfaceTweaks().AnalyzeAndUpdate(this); });
}
diff --git a/.Source/GTweak/View/SystemView.xaml.cs b/.Source/GTweak/View/SystemView.xaml.cs
index 78b88741..8d620e7a 100644
--- a/.Source/GTweak/View/SystemView.xaml.cs
+++ b/.Source/GTweak/View/SystemView.xaml.cs
@@ -1,5 +1,6 @@
using GTweak.Assets.UserControl;
using GTweak.Utilities.Control;
+using GTweak.Utilities.Helpers.Storage;
using GTweak.Utilities.Tweaks;
using System;
using System.Threading.Tasks;
@@ -47,22 +48,8 @@ namespace GTweak.View
{
SystemTweaks.ApplyTweaks(toggleButton.Name, toggleButton.State);
- switch (toggleButton.Name)
- {
- case "TglButton7":
- case "TglButton9":
- case "TglButton10":
- case "TglButton12":
- case "TglButton13":
- case "TglButton14":
- case "TglButton15":
- case "TglButton20":
- new ViewNotification(300).Show("restart");
- break;
- case "TglButton2":
- new ViewNotification(300).Show("logout");
- break;
- }
+ if (NotifActionsStorage.GetSysActions.TryGetValue(toggleButton.Name, out string action))
+ new ViewNotification(300).Show(action);
Parallel.Invoke(async delegate { await Task.Delay(1000); new SystemTweaks().AnalyzeAndUpdate(this); });
}
diff --git a/.Source/GTweak/Windows/ImportWindow.xaml.cs b/.Source/GTweak/Windows/ImportWindow.xaml.cs
index a1cfdefd..86c260d4 100644
--- a/.Source/GTweak/Windows/ImportWindow.xaml.cs
+++ b/.Source/GTweak/Windows/ImportWindow.xaml.cs
@@ -1,5 +1,6 @@
using GTweak.Utilities.Control;
using GTweak.Utilities.Helpers;
+using GTweak.Utilities.Helpers.Storage;
using GTweak.Utilities.Tweaks;
using System;
using System.Collections.Generic;
@@ -72,13 +73,8 @@ namespace GTweak.Windows
await Task.Delay(700, _token);
ConfidentialityTweaks.ApplyTweaks(set.Tweak, Convert.ToBoolean(set.Value));
- switch (set.Tweak)
- {
- case "TglButton8":
- case "TglButton15":
- isRestartNeed = true;
- break;
- }
+ isRestartNeed = NotifActionsStorage.GetConfActions.Any(get => get.Key == set.Tweak && get.Value == "restart");
+ isLogoutNeed = NotifActionsStorage.GetConfActions.Any(get => get.Key == set.Tweak && get.Value == "logout");
}
}
@@ -102,25 +98,8 @@ namespace GTweak.Windows
}, _token);
InterfaceTweaks.ApplyTweaks(set.Tweak, Convert.ToBoolean(set.Value));
- switch (set.Tweak)
- {
- case "TglButton1":
- case "TglButton2":
- case "TglButton3":
- case "TglButton4":
- case "TglButton5":
- case "TglButton10":
- case "TglButton11":
- case "TglButton12":
- case "TglButton26":
- case "TglButton27":
- isLogoutNeed = true;
- break;
- case "TglButton22":
- case "TglButton20":
- isRestartNeed = true;
- break;
- }
+ isRestartNeed = NotifActionsStorage.GetIntfActions.Any(get => get.Key == set.Tweak && get.Value == "restart");
+ isLogoutNeed = NotifActionsStorage.GetIntfActions.Any(get => get.Key == set.Tweak && get.Value == "logout");
}
}
@@ -161,22 +140,8 @@ namespace GTweak.Windows
else
SystemTweaks.ApplyTweaksSlider(set.Tweak, Convert.ToUInt32(set.Value));
- switch (set.Tweak)
- {
- case "TglButton7":
- case "TglButton9":
- case "TglButton10":
- case "TglButton12":
- case "TglButton13":
- case "TglButton14":
- case "TglButton15":
- case "TglButton20":
- isRestartNeed = true;
- break;
- case "TglButton2":
- isLogoutNeed = true;
- break;
- }
+ isRestartNeed = NotifActionsStorage.GetSysActions.Any(get => get.Key == set.Tweak && get.Value == "restart");
+ isLogoutNeed = NotifActionsStorage.GetSysActions.Any(get => get.Key == set.Tweak && get.Value == "logout");
}
else
{