-
Notifications
You must be signed in to change notification settings - Fork 2
/
AeroColorsViewModel.cs
53 lines (49 loc) · 1.84 KB
/
AeroColorsViewModel.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
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AdvancedWindowsAppearence
{
public class AeroColorsViewModel
{
public ObservableCollection<AeroColorRegistrySetting> AeroColors { get; set; } = new ObservableCollection<AeroColorRegistrySetting>();
public void Add(string name, string registrykey, Version winVer)
{
var registryPath = @"Software\Microsoft\Windows\DWM";
AddWithPath(name, registryPath, registrykey, winVer);
}
public void AddWithPath(string name, string registrypath, string registrykey, Version winVer)
{
if (winVer > Environment.OSVersion.Version) return;
AeroColorRegistrySetting setting = new AeroColorRegistrySetting(name, registrypath, registrykey);
AeroColors.Add(setting);
}
public void RemoveFromRegistry(AeroColorRegistrySetting setting)
{
setting.RemoveFromRegistry();
}
public async Task SaveAll()
{
List<Task> tasks = new List<Task>();
foreach (AeroColorRegistrySetting setting in AeroColors)
{
if (setting == null) continue;
if (!setting.Enabled) RemoveFromRegistry(setting);
else
tasks.Add(Task.Run(() => setting.SaveToRegistry()));
}
await Task.WhenAll(tasks);
}
public string GetSettingsInReg()
{
string output = @"[HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM]";
foreach (var ac in AeroColors)
{
output += "\n\"" + ac.RegistryKey + "\"=dword:" + int.Parse(ac.ItemColorValue).ToString("X");
}
return output;
}
}
}