forked from tomasr/VSColorsToSQL
/
Program.cs
155 lines (126 loc) · 5.77 KB
/
Program.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
//
// Program.cs
//
// Author:
// Tomas Restrepo (tomas@winterdom.com)
//
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32;
namespace Winterdom.Utilities.VSColorsToSql
{
class ColorImporter
{
private const string SRC_KEY = @"Software\Microsoft\VisualStudio\8.0\FontAndColors\{A27B4E24-A735-4D1D-B8E7-9716E1E3D8E0}";
private const string DST_KEY = @"Software\Microsoft\Microsoft SQL Server\90\Tools\Shell\FontAndColors\{A27B4E24-A735-4D1D-B8E7-9716E1E3D8E0}";
private IDictionary<string, string> _map;
private IList<string> _ignorePrefixes;
public ColorImporter()
{
_map = new Dictionary<string, string>();
#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
_ignorePrefixes = new string[] {
"CSS ", "Disassembly ", "HTML ", "Refactoring ", "XML Doc "
};
}
public void Copy()
{
RegistryKey src = Registry.CurrentUser.OpenSubKey(SRC_KEY);
RegistryKey dst = Registry.CurrentUser.OpenSubKey(DST_KEY, 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;
}
}
class Program
{
static void Main(string[] args)
{
try
{
ColorImporter importer = new ColorImporter();
importer.Copy();
Console.WriteLine("Completed successfully");
} catch ( Exception ex )
{
Console.WriteLine(ex.ToString());
}
}
}
}