-
Notifications
You must be signed in to change notification settings - Fork 2
/
ColorAppearanceSetting.cs
71 lines (58 loc) · 2.04 KB
/
ColorAppearanceSetting.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
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AdvancedWindowsAppearence
{
public class ColorAppearanceSetting : AppearanceSetting
{
public readonly string SizeRegistryKey;
public ColorAppearanceSetting(string _name, string _regeditPath, string _colorRegistryPath)
{
Name = _name;
SizeRegistryKey = _regeditPath;
ColorRegistryPath = _colorRegistryPath;
LoadColorValues();
}
void LoadColorValues()
{
Size = GetSizeFromRegistry(SizeRegistryKey);
ItemColor = GetColorFromRegistry(ColorRegistryPath);
IsEdited = false;
}
int? GetSizeFromRegistry(string registrypath)
{
if (registrypath == null || registrypath == "") return null;
RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop\WindowMetrics");
if (registryKey == null) return null;
var sizeReg = registryKey.GetValue(registrypath);
registryKey.Close();
if (sizeReg == null) return null;
int intsize = int.Parse(sizeReg.ToString());
if (registrypath != "Shell Icon Size")
intsize = intsize / (-15);
return intsize;
}
void SaveSizeToRegistry()
{
if (!Size.HasValue) return;
var key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop\WindowMetrics", true);
float sizeTemp = -15;
if (SizeRegistryKey == "Shell Icon Size")
sizeTemp = Size.Value;
else
sizeTemp = -15 * Size.Value;
key.SetValue(SizeRegistryKey, sizeTemp, RegistryValueKind.String);
key.Close();
}
public void SaveToRegistry()
{
base.SaveColorToRegistry();
SaveSizeToRegistry();
IsEdited = false;
}
}
}