Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathVisualStudioModule.cs
More file actions
Latest commit
79 lines (70 loc) · 3.05 KB
/
Copy pathVisualStudioModule.cs
File metadata and controls
79 lines (70 loc) · 3.05 KB
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
usingEnvDTE;
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Threading.Tasks;
usingSystem.Windows.Media;
namespaceCodeConnect.Touch
{
/// <summary>
/// Exposes Visual Studio APIs to this package
/// </summary>
publicstaticclassVisualStudioModule
{
privatestaticDTEenvDte;
publicstaticSolidColorBrushForegroundBrush{get;privateset;}
publicstaticSolidColorBrushBackgroundBrush{get;privateset;}
publicstaticSolidColorBrushBackgroundHighlightTransparentBrush{get;privateset;}
publicstaticSolidColorBrushBackgroundTransparentBrush{get;privateset;}
publicstaticSolidColorBrushHyperlinkBrush{get;privateset;}
publicstaticvoidInitialize(DTEdte)
{
envDte=dte;
initializeBrushes();
}
publicstaticvoidExecuteCommand(stringcommandName,stringcommandArgs="")
{
vartest=commandName;
try
{
envDte.ExecuteCommand(commandName,commandArgs);
}
catch(Exceptionex)
{
envDte.StatusBar.Text=$"Error executing {commandName}";
}
}
privatestaticvoidinitializeBrushes()
{
conststringCATEGORY_FONTS_AND_COLORS="FontsAndColors";
conststringPAGE_TEXT_EDITOR="TextEditor";
varfontsAndColors=envDte.Properties[CATEGORY_FONTS_AND_COLORS,PAGE_TEXT_EDITOR];
varfontsAndColorsItems=(FontsAndColorsItems)fontsAndColors.Item(nameof(FontsAndColorsItems)).Object;
varbackgroundBrush=GetBrush(fontsAndColorsItems.Item("Plain Text").Background);
backgroundBrush.Freeze();
varforegroundBrush=GetBrush(fontsAndColorsItems.Item("Plain Text").Foreground);
foregroundBrush.Freeze();
varbackgroundTransparentBrush=GetBrush(fontsAndColorsItems.Item("Plain Text").Background,210);
backgroundBrush.Freeze();
varbackgroundHighlightTransparentBrush=GetBrush(fontsAndColorsItems.Item("urlformat").Foreground,170);
foregroundBrush.Freeze();
varhyperlinkBrush=GetBrush(fontsAndColorsItems.Item("urlformat").Foreground);// also "HTML Element Name"
hyperlinkBrush.Freeze();
BackgroundBrush=backgroundBrush;
ForegroundBrush=foregroundBrush;
BackgroundTransparentBrush=backgroundTransparentBrush;
BackgroundHighlightTransparentBrush=backgroundHighlightTransparentBrush;
HyperlinkBrush=hyperlinkBrush;
}
privatestaticSolidColorBrushGetBrush(uintcolor,byteopacity=255)
{
intintColor=Convert.ToInt32(color);
returnnewSolidColorBrush(Color.FromArgb(
opacity,
(byte)((intColor)&0xFF),
(byte)((intColor>>8)&0xFF),
(byte)((intColor>>16)&0xFF)));
}
}
}