-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProductKeys.xaml.cs
125 lines (105 loc) · 6.31 KB
/
ProductKeys.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// ReSharper disable RedundantUsingDirective
using HGM.Hotbird64.LicenseManager.Extensions;
using HGM.Hotbird64.Vlmcs;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Navigation;
// ReSharper disable once CheckNamespace
namespace HGM.Hotbird64.LicenseManager
{
public partial class ProductKeys
{
public static IList<ProductKey> ProductKeyList => productKeyList;
private static readonly ProductKey[] productKeyList =
{
new ProductKey ("Windows 10/11 Professional", "VK7JG-NPHTM-C97JM-9MPGT-3V66T", KeyType.StoreLicense ),
new ProductKey ("Windows 10/11 Home", "YTMG3-N6DKC-DKB77-7M9GH-8HVX7", KeyType.StoreLicense ),
new ProductKey ("Windows 8 Preview Core Country Specific", "NDTWC-J28B6-RTR3C-CPRHW-2GV83", KeyType.StoreLicense),
new ProductKey ("Windows 8 Preview Professional N", "G2DR7-7N9C8-KBK9V-D4W3M-H49R8", KeyType.StoreLicense),
new ProductKey ("Windows 8 Preview Enterprise N", "N8BR7-D8XB9-939VB-FMFWD-KWXR9", KeyType.StoreLicense),
new ProductKey ("Windows 8 Preview Standard Server", "YNBF9-GPVTG-FFHQC-MJR4B-B4CQX", KeyType.StoreLicense),
new ProductKey ("Windows 8 Preview Multipoint Server Standard", "3CK7G-VRNKC-8QBFR-9G8HC-YKG8W", KeyType.StoreLicense),
new ProductKey ("Windows 8 Preview Multipoint Server Premium", "GRMDJ-JNF7H-W9WTC-WKQRG-H8KW6", KeyType.StoreLicense),
new ProductKey ("Microsoft Visual Studio 2019 Professional", "NYWVH-HT4XC-R2WYW-9Y3CM-X4V3Y", KeyType.StoreLicense ),
new ProductKey ("Microsoft Visual Studio 2019 Enterprise", "BF8Y8-GN2QH-T84XB-QVY3B-RC4DF", KeyType.StoreLicense ),
new ProductKey ("Microsoft Visual Studio 2022 Professional", "TD244-P4NB7-YQ6XK-Y8MMM-YWV2J", KeyType.StoreLicense ),
new ProductKey ("Microsoft Visual Studio 2022 Enterprise", "VHF9H-NXBBB-638P6-6JHCY-88JWH", KeyType.StoreLicense ),
new ProductKey ("Microsoft SQL Server 2022 Enterprise", "J4V48-P8MM4-9N3J9-HD97X-DYMRM", KeyType.StoreLicense ),
new ProductKey ("Microsoft SCCM 2022 Enterprise", "BXH69-M62YX-QQD6R-3GPWX-8WMFY", KeyType.StoreLicense ),
new ProductKey ("Windows Server 2022 KMS Host", "R47NX-MVMYR-98PV9-XYVXY-XBXCH", KeyType.StoreLicense)
};
private void AddKeysToTreeViewItem(TreeViewItem treeViewItem, IEnumerable<ProductKey> keys)
{
foreach (ProductKey key in keys)
{
TreeViewItem keyItem = new TreeViewItem { Header = key, ToolTip = key.Key };
treeViewItem.Items.Add(keyItem);
}
}
private static readonly KmsGuid winBetaGuid = new KmsGuid("5f94a0bb-d5a0-4081-a685-5819418b2fe0");
public ProductKeys(MainWindow mainWindow) : base(mainWindow)
{
InitializeComponent();
TopElement.LayoutTransform = Scaler;
DataContext = this;
Loaded += (s, e) => Icon = this.GenerateImage(new Icons.InstallKey(), 16, 16);
TreeViewItem treeViewItem = new TreeViewItem { Header = "Store license keys" };
ProductTree.Items.Add(treeViewItem);
AddKeysToTreeViewItem(treeViewItem, ProductKeyList.Where(k => k.KeyType == KeyType.StoreLicense));
treeViewItem = new TreeViewItem { Header = "User-generated GVLKs" };
ProductTree.Items.Add(treeViewItem);
AddKeysToTreeViewItem(treeViewItem, KmsLists.SkuItemList.Where(s => s.IsGeneratedGvlk && s.Gvlk != null).Select(s => new ProductKey(s.ToString(), s.Gvlk, s.IsGeneratedGvlk ? KeyType.GvlkGenerated : KeyType.Gvlk)));
treeViewItem = new TreeViewItem { Header = "Genuine GVLKs" };
ProductTree.Items.Add(treeViewItem);
foreach (AppItem app in KmsLists.AppItemList)
{
TreeViewItem appitem = new TreeViewItem { Header = app };
treeViewItem.Items.Add(appitem);
foreach (KmsItem kmsId in app.KmsItems.OrderBy(k => k.DisplayName))
{
TreeViewItem kmsItem = new TreeViewItem { Header = kmsId };
AddKeysToTreeViewItem(kmsItem, kmsId.SkuItems.Where(s => !s.IsGeneratedGvlk && s.Gvlk != null).OrderBy(s => s.DisplayName).Select(s => new ProductKey(s.ToString(), s.Gvlk, s.IsGeneratedGvlk ? KeyType.GvlkGenerated : KeyType.Gvlk)));
if (kmsId == winBetaGuid)
{
AddKeysToTreeViewItem(kmsItem, ProductKeyList.Where(k => k.KeyType == KeyType.Gvlk).OrderBy(k => k.Name));
}
appitem.Items.Add(kmsItem);
}
}
ProductTree.SelectedItemChanged += (sender, eventArgs) =>
{
InstallButton.IsEnabled = ((TreeViewItem)eventArgs.NewValue).ToolTip is string;
ProductKey key = ((TreeViewItem)eventArgs.NewValue).Header as ProductKey;
if (key != null)
{
TextBlockGenerated.Visibility = key.KeyType == KeyType.GvlkGenerated || key.KeyType == KeyType.RetailGenerated ? Visibility.Visible : Visibility.Collapsed;
}
else
{
TextBlockGenerated.Visibility = Visibility.Collapsed;
}
};
}
private void TreeViewItem_DoubleClick(object sender, MouseButtonEventArgs args)
{
TreeViewItem treeViewItem = ProductTree.SelectedItem as TreeViewItem;
if (treeViewItem == null || !treeViewItem.HasHeader || !(treeViewItem.ToolTip is string)) return;
AnalyzeButton_Click(null, null);
}
private void TreeViewItem_Collapse(object sender, RoutedEventArgs e) => ((ItemsControl)e.Source).ExpandAll(false);
private void AnalyzeButton_Click(object sender, RoutedEventArgs e)
{
new ProductBrowser(MainWindow, GvlkKey.Text).Show();
}
private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
e.Handled = true;
}
private void CancelButton_Clicked(object sender, RoutedEventArgs e) => Close();
}
}