-
Notifications
You must be signed in to change notification settings - Fork 0
/
ColorImporter.cs
136 lines (107 loc) · 5.66 KB
/
ColorImporter.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
126
127
128
129
130
131
132
133
134
135
136
/*
* Based on http://winterdom.com/2007/10/colorschemesinsql2005managementstudio
*/
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32;
namespace Winterdom.Utilities.VSColorsToSql {
class ColorImporter {
private IDictionary<string, string> _src = new Dictionary<string, string>();
private IDictionary<string, string> _dst = new Dictionary<string, string>();
private IDictionary<string, string> _map = new Dictionary<string, string>();
private IList<string> _ignorePrefixes;
public ColorImporter() {
#region values we map from one to the other
_map.Add("String Background", "SQL String Background");
_map.Add("String FontFlags", "SQL String FontFlags");
_map.Add("String Foreground", "SQL String Foreground");
_map.Add("Operator Foreground", "SQL Operator Foreground");
_map.Add("Operator Background", "SQL Operator Background");
_map.Add("Operator FontFlags", "SQL Operator FontFlags");
_map.Add("User Types Foreground", "SQL Stored Procedure Foreground");
_map.Add("User Types Background", "SQL Stored Procedure Background");
_map.Add("User Types FontFlags", "SQL Stored Procedure FontFlags");
_map.Add("User Types (Interfaces) Foreground", "SQL System Function Foreground");
_map.Add("User Types (Interfaces) Background", "SQL System Function Background");
_map.Add("User Types (Interfaces) FontFlags", "SQL System Function FontFlags");
_map.Add("User Types (Value types) Foreground", "SQL System Table Foreground");
_map.Add("User Types (Value types) Background", "SQL System Table Background");
_map.Add("User Types (Value types) FontFlags", "SQL System Table FontFlags");
_map.Add("XML Attribute Foreground", "XmlAttribute Foreground");
_map.Add("XML Attribute Background", "XmlAttribute Background");
_map.Add("XML Attribute FontFlags", "XmlAttribute FontFlags");
_map.Add("XML Attribute Quotes Foreground", "XmlAttributeQuotes Foreground");
_map.Add("XML Attribute Quotes Background", "XmlAttributeQuotes Background");
_map.Add("XML Attribute Quotes FontFlags", "XmlAttributeQuotes FontFlags");
_map.Add("XML CData Section Foreground", "XmlCData Foreground");
_map.Add("XML CData Section Background", "XmlCData Background");
_map.Add("XML CData Section FontFlags", "XmlCData FontFlags");
_map.Add("XML Comment Foreground", "XmlComment Foreground");
_map.Add("XML Comment Background", "XmlComment Background");
_map.Add("XML Comment FontFlags", "XmlComment FontFlags");
_map.Add("XML Delimiter Foreground", "XmlDelimiter Foreground");
_map.Add("XML Delimiter Background", "XmlDelimiter Background");
_map.Add("XML Delimiter FontFlags", "XmlDelimiter FontFlags");
_map.Add("XML Keyword Foreground", "XmlKeyword Foreground");
_map.Add("XML Keyword Background", "XmlKeyword Background");
_map.Add("XML Keyword FontFlags", "XmlKeyword FontFlags");
_map.Add("XML Name Foreground", "XmlName Foreground");
_map.Add("XML Name Background", "XmlName Background");
_map.Add("XML Name FontFlags", "XmlName FontFlags");
_map.Add("XML Processing Instruction Foreground", "XmlProcessingInstruction Foreground");
_map.Add("XML Processing Instruction Background", "XmlProcessingInstruction Background");
_map.Add("XML Processing Instruction FontFlags", "XmlProcessingInstruction FontFlags");
_map.Add("XML Text Foreground", "XmlText Foreground");
_map.Add("XML Text Background", "XmlText Background");
_map.Add("XML Text FontFlags", "XmlText FontFlags");
_map.Add("XSLT Keyword Foreground", "XsltKeyword Foreground");
_map.Add("XSLT Keyword Background", "XsltKeyword Background");
_map.Add("XSLT Keyword FontFlags", "XsltKeyword FontFlags");
#endregion
_src.Add("2005", @"Software\Microsoft\VisualStudio\8.0\FontAndColors\{A27B4E24-A735-4D1D-B8E7-9716E1E3D8E0}");
_src.Add("2008", @"Software\Microsoft\VisualStudio\9.0\FontAndColors\{A27B4E24-A735-4D1D-B8E7-9716E1E3D8E0}");
_src.Add("2010", @"Software\Microsoft\VisualStudio\10.0\FontAndColors\{A27B4E24-A735-4D1D-B8E7-9716E1E3D8E0}");
_dst.Add("2005", @"Software\Microsoft\Microsoft SQL Server\90\Tools\Shell\FontAndColors\{A27B4E24-A735-4D1D-B8E7-9716E1E3D8E0}");
_dst.Add("2008", @"Software\Microsoft\Microsoft SQL Server\100\Tools\Shell\FontAndColors\{A27B4E24-A735-4D1D-B8E7-9716E1E3D8E0}");
_ignorePrefixes = new string[] { "CSS ", "Disassembly ", "HTML ", "Refactoring ", "XML Doc " };
}
public void Copy(String sourceVersion, String destinationVersion) {
RegistryKey src = Registry.CurrentUser.OpenSubKey(_src[sourceVersion]);
RegistryKey dst = Registry.CurrentUser.OpenSubKey(_dst[destinationVersion], true);
string[] values = src.GetValueNames();
foreach (string valname in values) {
CopyValue(valname, src, dst);
}
}
private void CopyValue(string valname, RegistryKey src, RegistryKey dst) {
if (!Ignore(valname)) {
string rv = valname;
if (_map.ContainsKey(valname))
rv = _map[valname];
dst.SetValue(rv, src.GetValue(valname));
// hack: we also copy the Identifier ones over to plain text
if (valname.StartsWith("Identifier") && !valname.Contains("Background")) {
dst.SetValue(valname.Replace("Identifier", "Plain Text"), src.GetValue(valname));
}
}
}
private bool Ignore(string valname) {
foreach (string prefix in _ignorePrefixes)
if (valname.StartsWith(prefix))
return true;
return false;
}
static void Main(string[] args) {
string source = args.Length > 0 ? args[0] : "2008";
string destination = args.Length > 1 ? args[1] : "2008";
try {
ColorImporter ic = new ColorImporter();
ic.Copy(source, destination);
}
catch (Exception ex) {
Console.WriteLine(ex.ToString());
}
}
}
}