Skip to content

Portable Tool for an Ideal Windows Setup

-simplify license status verification

Greedeks2d67f045fa5a
diff --git a/.Source/GTweak/Core/ViewModel/PagesViewModel.cs b/.Source/GTweak/Core/ViewModel/PagesViewModel.cs
index d49b5df9..ef5b7d94 100644
--- a/.Source/GTweak/Core/ViewModel/PagesViewModel.cs
+++ b/.Source/GTweak/Core/ViewModel/PagesViewModel.cs
@@ -14,7 +14,7 @@ namespace GTweak.Core.ViewModel
internal class InterfaceVM : ViewModelBase
{
public bool IsBlockForWin10 => SystemData.СomputerСonfiguration.WindowsClientVersion.Contains("11");
- public bool IsBlockWithoutLicense => WindowsLicense.statusLicense == 1;
+ public bool IsBlockWithoutLicense => WindowsLicense.IsWindowsActivated;
}
internal class InformationSystemVM : ViewModelBase
diff --git a/.Source/GTweak/Styles/Slider.xaml b/.Source/GTweak/Styles/Slider.xaml
index c4345d68..3c68611e 100644
--- a/.Source/GTweak/Styles/Slider.xaml
+++ b/.Source/GTweak/Styles/Slider.xaml
@@ -78,7 +78,6 @@
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" MinHeight="{TemplateBinding MinHeight}" />
- <RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
diff --git a/.Source/GTweak/Utilities/Tweaks/WindowsLicense.cs b/.Source/GTweak/Utilities/Tweaks/WindowsLicense.cs
index ee65c5ac..882f325e 100644
--- a/.Source/GTweak/Utilities/Tweaks/WindowsLicense.cs
+++ b/.Source/GTweak/Utilities/Tweaks/WindowsLicense.cs
@@ -9,7 +9,7 @@ namespace GTweak.Utilities.Tweaks
{
internal sealed class WindowsLicense
{
- internal static uint statusLicense = 0;
+ internal static bool IsWindowsActivated = false;
private static bool IsVersionWindows(string pattern, byte words) => new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled).Matches(SystemData.СomputerСonfiguration.WindowsClientVersion).Count == words;
internal void LicenseStatus()
@@ -17,7 +17,7 @@ namespace GTweak.Utilities.Tweaks
Parallel.Invoke(() =>
{
foreach (var managementObj in new ManagementObjectSearcher(@"root\cimv2", "SELECT LicenseStatus FROM SoftwareLicensingProduct WHERE ApplicationID = '55c92734-d682-4d71-983e-d6ec3f16059f' and LicenseStatus = 1").Get())
- statusLicense = (uint)managementObj["LicenseStatus"];
+ IsWindowsActivated = (uint)managementObj["LicenseStatus"] == 1;
});
}
@@ -94,9 +94,9 @@ namespace GTweak.Utilities.Tweaks
waitingWindow.Close();
- if (statusLicense == 1)
+ if (IsWindowsActivated)
new ViewNotification().Show("restart", (string)Application.Current.Resources["title0_notification"], (string)Application.Current.Resources["successactivate_notification"]);
- else if (statusLicense != 1)
+ else
new ViewNotification().Show("", (string)Application.Current.Resources["title0_notification"], (string)Application.Current.Resources["notsuccessactivate_notification"]);
}
diff --git a/.Source/GTweak/View/InterfaceView.xaml.cs b/.Source/GTweak/View/InterfaceView.xaml.cs
index 296dcfab..48cafc6a 100644
--- a/.Source/GTweak/View/InterfaceView.xaml.cs
+++ b/.Source/GTweak/View/InterfaceView.xaml.cs
@@ -19,7 +19,7 @@ namespace GTweak.View
App.LanguageChanged += delegate { new TypewriterAnimation((string)FindResource("defaultDescription"), TextDescription, TimeSpan.FromMilliseconds(0)); };
- if (WindowsLicense.statusLicense != 1)
+ if (!WindowsLicense.IsWindowsActivated)
new ViewNotification().Show("", (string)Application.Current.Resources["title1_notification"], (string)Application.Current.Resources["viewlicense_notification"]);
}
diff --git a/.Source/GTweak/View/MoreView.xaml.cs b/.Source/GTweak/View/MoreView.xaml.cs
index c9c8f869..4d725310 100644
--- a/.Source/GTweak/View/MoreView.xaml.cs
+++ b/.Source/GTweak/View/MoreView.xaml.cs
@@ -17,10 +17,9 @@ namespace GTweak.View
private void BtnLicenseWindows_ClickButton(object sender, EventArgs e)
{
- if (WindowsLicense.statusLicense == 1)
+ if (WindowsLicense.IsWindowsActivated)
new ViewNotification().Show("", (string)FindResource("title1_notification"), (string)FindResource("readyactivate_notification"));
-
- else if (WindowsLicense.statusLicense != 1)
+ else
{
new ViewNotification().Show("", (string)FindResource("title0_notification"), (string)FindResource("activatewin_notification"));
WindowsLicense.StartActivation();