-
Notifications
You must be signed in to change notification settings - Fork 0
/
OptionsPage.cs
156 lines (137 loc) · 4.8 KB
/
OptionsPage.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
156
using System;
using System.ComponentModel.Composition;
using System.Runtime.InteropServices;
using EnvDTE;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio;
using System.ComponentModel;
namespace ProgressiveScroll
{
public class OptionNames
{
public const string PageCategoryName = "Progressive Scroll";
public const string PageName = "General";
public const string ScrollBarWidth = "ScrollBarWidth";
public const string RenderTextEnabled = "RenderTextEnabled";
public const string CursorOpacity = "CursorOpacity";
public const string CursorBorderEnabled = "CursorBorderEnabled";
public const string SplitterEnabled = "SplitterEnabled";
public const string ErrorsEnabled = "ErrorsEnabled";
public const string AltHighlight = "AltHighlight";
}
[ClassInterface(ClassInterfaceType.AutoDual)]
[System.ComponentModel.DesignerCategory("")] // Prevents this file from being opened in design mode.
[ComVisible(true)]
public class OptionsPage : DialogPage
{
private int _scrollBarWidth = 128;
private bool _renderTextEnabled = true;
private double _cursorOpacity = 0.125;
private bool _cursorBorderEnabled = false;
private bool _splitterEnabled = false;
private bool _errorsEnabled = false;
private bool _altHighlight = false;
[Category("General")]
[DisplayName("Width")]
[Description("Width of the scrollbar")]
public int ScrollBarWidth
{
get { return _scrollBarWidth; }
set { _scrollBarWidth = Math.Min(Math.Max(value, 16), 512); }
}
[Category("General")]
[DisplayName("Display Code")]
[Description("Displays the code in the scrollbar.")]
public bool RenderTextEnabled
{
get { return _renderTextEnabled; }
set { _renderTextEnabled = value; }
}
[Category("General")]
[DisplayName("Visible Region Opacity")]
[Description("Opacity of the visible region.")]
public double CursorOpacity
{
get { return _cursorOpacity; }
set { _cursorOpacity = Math.Min(Math.Max(value, 0.0), 1.0); }
}
[Category("General")]
[DisplayName("Display Border")]
[Description("Displays a border around the visible region.")]
public bool CursorBorderEnabled
{
get { return _cursorBorderEnabled; }
set { _cursorBorderEnabled = value; }
}
[Category("General")]
[DisplayName("Display Splitter")]
[Description("Displays the splitter control.")]
public bool SplitterEnabled
{
get { return _splitterEnabled; }
set { _splitterEnabled = value; }
}
[Category("General")]
[DisplayName("Display Error Marks")]
[Description("Displays marks for errors in the scrollbar.")]
public bool ErrorsEnabled
{
get { return _errorsEnabled; }
set { _errorsEnabled = value; }
}
[Category("General")]
[DisplayName("Alt highlight")]
[Description("Requires the user to hold Alt to highlight text.")]
public bool AltHighlight
{
get { return _altHighlight; }
set { _altHighlight = value; }
}
protected override void OnApply(PageApplyEventArgs e)
{
base.OnApply(e);
if (e.ApplyBehavior == ApplyKind.Apply)
{
// Update all ProgressiveScroll objects
Options.ScrollBarWidth = _scrollBarWidth;
Options.RenderTextEnabled = _renderTextEnabled;
Options.CursorOpacity = _cursorOpacity;
Options.CursorBorderEnabled = _cursorBorderEnabled;
Options.SplitterEnabled = _splitterEnabled;
Options.ErrorsEnabled = _errorsEnabled;
Options.AltHighlight = _altHighlight;
ProgressiveScroll.SettingsChanged();
}
}
}
[PackageRegistration(UseManagedResourcesOnly = true)]
[Guid("3E81D486-9A46-458A-BB83-7655DD0E18A4")]
[ProvideOptionPage(typeof(OptionsPage), OptionNames.PageCategoryName, OptionNames.PageName, 0, 0, true)]
//Microsoft.VisualStudio.VSConstants.UICONTEXT_NoSolution
[ProvideAutoLoad("ADFC4E64-0397-11D1-9F4E-00A0C911004F")]
public sealed class Options : Package
{
public static bool IsVS10;
public static int ScrollBarWidth;
public static bool RenderTextEnabled;
public static double CursorOpacity;
public static bool CursorBorderEnabled;
public static bool SplitterEnabled;
public static bool ErrorsEnabled;
public static bool AltHighlight;
protected override void Initialize()
{
base.Initialize();
DTE dte = (DTE)GetService(typeof(DTE));
IsVS10 = (dte.Version == "10.0");
EnvDTE.Properties props = dte.get_Properties(OptionNames.PageCategoryName, OptionNames.PageName);
ScrollBarWidth = (int)props.Item(OptionNames.ScrollBarWidth).Value;
RenderTextEnabled = (bool)props.Item(OptionNames.RenderTextEnabled).Value;
CursorOpacity = (double)props.Item(OptionNames.CursorOpacity).Value;
CursorBorderEnabled = (bool)props.Item(OptionNames.CursorBorderEnabled).Value;
SplitterEnabled = (bool)props.Item(OptionNames.SplitterEnabled).Value;
ErrorsEnabled = (bool)props.Item(OptionNames.ErrorsEnabled).Value;
AltHighlight = (bool)props.Item(OptionNames.AltHighlight).Value;
}
}
}