Skip to content

Commit db0179e

Browse files
authored
Merge pull request #2 from CodeDead/release/v2.0.0
Release/v2.0.0
2 parents 5958ee8 + f27016a commit db0179e

26 files changed

+509
-700
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 0 additions & 31 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 0 additions & 20 deletions
This file was deleted.

.idea/.gitignore

Whitespace-only changes.

CODE_OF_CONDUCT.md

Lines changed: 0 additions & 76 deletions
This file was deleted.

PK Finder/App.config

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,12 @@
99
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
1010
</startup>
1111
<runtime>
12-
<AppContextSwitchOverrides value = "Switch.System.Windows.DoNotScaleForDpiChanges=false; Switch.System.Windows.DoNotUsePresentationDpiCapabilityTier2OrGreater=false"/>
12+
<AppContextSwitchOverrides value="Switch.System.Windows.DoNotScaleForDpiChanges=false; Switch.System.Windows.DoNotUsePresentationDpiCapabilityTier2OrGreater=false" />
1313
</runtime>
1414
<userSettings>
1515
<PK_Finder.Properties.Settings>
1616
<setting name="VisualStyle" serializeAs="String">
17-
<value>Metro</value>
18-
</setting>
19-
<setting name="MetroColor" serializeAs="String">
20-
<value>#FF07779C</value>
21-
</setting>
22-
<setting name="BorderThickness" serializeAs="String">
23-
<value>3</value>
17+
<value>MaterialLight</value>
2418
</setting>
2519
<setting name="AutoUpdate" serializeAs="String">
2620
<value>True</value>
@@ -31,12 +25,6 @@
3125
<setting name="CopyMessage" serializeAs="String">
3226
<value>True</value>
3327
</setting>
34-
<setting name="WindowOpacity" serializeAs="String">
35-
<value>100</value>
36-
</setting>
37-
<setting name="WindowResizeBorder" serializeAs="String">
38-
<value>3</value>
39-
</setting>
4028
<setting name="WindowDraggable" serializeAs="String">
4129
<value>True</value>
4230
</setting>

PK Finder/App.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ public App()
1616
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR LICENSE KEY HERE");
1717
}
1818
}
19-
}
19+
}

PK Finder/Classes/ExportManager.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.IO;
3+
using Newtonsoft.Json;
34

45
namespace PK_Finder.Classes
56
{
@@ -43,8 +44,8 @@ private static void Export(string path, string content)
4344
/// <param name="path">The path where the KeyInfo object should be stored in plain text format</param>
4445
internal void ExportToTxt(string path)
4546
{
46-
string content = "Product name: " + _keyInfo.GetProductName() + Environment.NewLine + "Product key: " +
47-
_keyInfo.GetProductKey();
47+
string content = "Product name: " + _keyInfo.ProductName + Environment.NewLine + "Product key: " +
48+
_keyInfo.ProductKey;
4849
Export(path, content);
4950
}
5051

@@ -65,16 +66,15 @@ internal void ExportToExcel(string path)
6566
{
6667
ExportDelimiter(path, ";");
6768
}
68-
69+
6970
/// <summary>
7071
/// Export the KeyInfo object to a storage device in JSON format
7172
/// </summary>
7273
/// <param name="path">The path where the KeyInfo object should be stored in JSON format</param>
7374
internal void ExportToJson(string path)
7475
{
75-
string content = "{\"productName\":\"" + _keyInfo.GetProductName() + "\",\"productKey\":\"" +
76-
_keyInfo.GetProductKey() + "\"}";
77-
Export(path, content);
76+
string output = JsonConvert.SerializeObject(_keyInfo);
77+
Export(path, output);
7878
}
7979

8080
/// <summary>
@@ -85,7 +85,7 @@ internal void ExportToJson(string path)
8585
private void ExportDelimiter(string path, string delimiter)
8686
{
8787
string content = "Product name" + delimiter + "Product key" + Environment.NewLine +
88-
_keyInfo.GetProductName() + delimiter + _keyInfo.GetProductKey();
88+
_keyInfo.ProductName + delimiter + _keyInfo.ProductKey;
8989
Export(path, content);
9090
}
9191

@@ -94,9 +94,9 @@ private void ExportDelimiter(string path, string delimiter)
9494
/// </summary>
9595
/// <param name="path">The path where the KeyInfo object should be stored in HTML format</param>
9696
internal void ExportToHtml(string path)
97-
{
97+
{
9898
string content = "<html><head><meta charset=\"UTF-8\"><title>PK Finder</title></head><body><table border='1'><tbody><tr><th>Product name</th><th>Product key</th></tr><tr><td>" +
99-
_keyInfo.GetProductName() + "</td><td>" + _keyInfo.GetProductKey() + "</td></tr></tbody></table></body></html>";
99+
_keyInfo.ProductName + "</td><td>" + _keyInfo.ProductKey + "</td></tr></tbody></table></body></html>";
100100
Export(path, content);
101101
}
102102
}

PK Finder/Classes/KeyInfo.cs

Lines changed: 9 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,65 +3,27 @@
33
/// <summary>
44
/// Internal logic for handling Windows product information
55
/// </summary>
6-
internal sealed class KeyInfo
6+
public sealed class KeyInfo
77
{
8-
#region Variables
9-
8+
#region Properties
109
/// <summary>
11-
/// The product name
10+
/// Gets or sets the product name
1211
/// </summary>
13-
private string _productName;
12+
public string ProductName { get; set; }
1413

1514
/// <summary>
16-
/// The product key
15+
/// Gets or sets the product key
1716
/// </summary>
18-
private string _productKey;
19-
17+
public string ProductKey { get; set; }
2018
#endregion
2119

2220
/// <summary>
2321
/// Initialize a new KeyInfo object
2422
/// </summary>
25-
internal KeyInfo()
26-
{
27-
_productKey = "";
28-
_productName = "";
29-
}
30-
31-
/// <summary>
32-
/// Set the product name
33-
/// </summary>
34-
/// <param name="name">The name of the product</param>
35-
internal void SetProductName(string name)
36-
{
37-
_productName = name;
38-
}
39-
40-
/// <summary>
41-
/// Get the current product name
42-
/// </summary>
43-
/// <returns>The product name</returns>
44-
internal string GetProductName()
45-
{
46-
return _productName;
47-
}
48-
49-
/// <summary>
50-
/// Set the product key
51-
/// </summary>
52-
/// <param name="key">The product key</param>
53-
internal void SetProductKey(string key)
54-
{
55-
_productKey = key;
56-
}
57-
58-
/// <summary>
59-
/// Get the current product key
60-
/// </summary>
61-
/// <returns>The product key</returns>
62-
internal string GetProductKey()
23+
public KeyInfo()
6324
{
64-
return _productKey;
25+
ProductKey = "";
26+
ProductName = "";
6527
}
6628
}
6729
}

PK Finder/Classes/KeyManager.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@ internal static KeyInfo GetWindowsProductInformation()
1919
RegistryKey key = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Default);
2020
const string keyPath = @"Software\Microsoft\Windows NT\CurrentVersion";
2121
RegistryKey openSubKey = key.OpenSubKey(keyPath);
22-
if (openSubKey == null) return null;
2322

24-
byte[] digitalProductId = (byte[]) openSubKey.GetValue("DigitalProductId");
23+
if (openSubKey == null)
24+
return null;
25+
26+
byte[] digitalProductId = (byte[])openSubKey.GetValue("DigitalProductId");
2527
bool isWin8OrUp = Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor >= 2 ||
2628
Environment.OSVersion.Version.Major > 6;
2729

2830
string productKey =
2931
isWin8OrUp ? DecodeProductKeyWin8AndUp(digitalProductId) : DecodeProductKey(digitalProductId);
30-
string productName = (string) openSubKey.GetValue("ProductName");
31-
32-
KeyInfo ki = new KeyInfo();
33-
34-
ki.SetProductKey(productKey);
35-
ki.SetProductName(productName);
3632

37-
return ki;
33+
return new KeyInfo
34+
{
35+
ProductKey = productKey,
36+
ProductName = System.Runtime.InteropServices.RuntimeInformation.OSDescription
37+
};
3838
}
3939

4040
/// <summary>
@@ -46,8 +46,8 @@ private static string DecodeProductKeyWin8AndUp(IList<byte> digitalProductId)
4646
{
4747
string key = string.Empty;
4848
const int keyOffset = 52;
49-
byte isWin8 = (byte) ((digitalProductId[66] / 6) & 1);
50-
digitalProductId[66] = (byte) ((digitalProductId[66] & 0xf7) | (isWin8 & 2) * 4);
49+
byte isWin8 = (byte)((digitalProductId[66] / 6) & 1);
50+
digitalProductId[66] = (byte)((digitalProductId[66] & 0xf7) | (isWin8 & 2) * 4);
5151

5252
const string digits = "BCDFGHJKMPQRTVWXY2346789";
5353
const string insert = "N";
@@ -60,7 +60,7 @@ private static string DecodeProductKeyWin8AndUp(IList<byte> digitalProductId)
6060
{
6161
current = current * 256;
6262
current = digitalProductId[j + keyOffset] + current;
63-
digitalProductId[j + keyOffset] = (byte) (current / 24);
63+
digitalProductId[j + keyOffset] = (byte)(current / 24);
6464
current = current % 24;
6565
last = current;
6666
}
@@ -113,8 +113,8 @@ private static string DecodeProductKey(IReadOnlyList<byte> digitalProductId)
113113
int digitMapIndex = 0;
114114
for (int j = decodeStringLength - 1; j >= 0; j--)
115115
{
116-
int byteValue = (digitMapIndex << 8) | (byte) hexPid[j];
117-
hexPid[j] = (byte) (byteValue / 24);
116+
int byteValue = (digitMapIndex << 8) | (byte)hexPid[j];
117+
hexPid[j] = (byte)(byteValue / 24);
118118
digitMapIndex = byteValue % 24;
119119
decodedChars[i] = digits[digitMapIndex];
120120
}

PK Finder/Classes/StyleManager.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22
using System.Windows;
3-
using System.Windows.Media;
3+
using Syncfusion.SfSkinManager;
44
using Syncfusion.Windows.Shared;
55

66
namespace PK_Finder.Classes
@@ -18,13 +18,11 @@ internal static void ChangeStyle(DependencyObject o)
1818
{
1919
try
2020
{
21-
SkinStorage.SetVisualStyle(o, Properties.Settings.Default.VisualStyle);
22-
SkinStorage.SetMetroBrush(o, new SolidColorBrush(Properties.Settings.Default.MetroColor));
23-
if (!(o is ChromelessWindow window)) return;
24-
window.BorderThickness = new Thickness(Properties.Settings.Default.BorderThickness);
25-
window.CornerRadius = new CornerRadius(0, 0, 0, 0);
26-
window.Opacity = Properties.Settings.Default.WindowOpacity / 100;
27-
window.ResizeBorderThickness = new Thickness(Properties.Settings.Default.WindowResizeBorder);
21+
SfSkinManager.ApplyStylesOnApplication = true;
22+
Enum.TryParse(Properties.Settings.Default.VisualStyle, out VisualStyles styles);
23+
24+
SfSkinManager.SetVisualStyle(o, styles);
25+
SfSkinManager.SetTheme(o, new Theme(Properties.Settings.Default.VisualStyle));
2826
}
2927
catch (Exception ex)
3028
{

0 commit comments

Comments
 (0)