@@ -22,27 +22,27 @@ public class ScrollBarEx : Control
22
22
23
23
public delegate void SettingsChangedEventHandler ( ScrollBarMode value ) ;
24
24
public static event SettingsChangedEventHandler SettingsChanged ;
25
-
26
- private static ScrollBarMode settingsMode = ScrollBarMode . Auto ;
27
-
25
+
28
26
public static ScrollBarMode SettingsMode
29
27
{
30
- get { return settingsMode ; }
28
+ get { return PluginBase . MainForm . Settings . UseCustomScrollBar ; }
29
+ }
30
+
31
+ public static bool UseCustom
32
+ {
33
+ get { return PluginBase . MainForm . GetThemeValue ( "ScrollBar.UseCustom" , "false" ) . ToLower ( ) == "true" ; }
31
34
}
32
35
33
36
public static void NotifySettingsChanged ( ScrollBarMode value )
34
37
{
35
- settingsMode = value ;
36
- if ( SettingsChanged != null ) SettingsChanged . Invoke ( settingsMode ) ;
38
+ if ( SettingsChanged != null ) SettingsChanged . Invoke ( value ) ;
37
39
}
38
40
39
41
#endregion
40
42
41
43
#region drawing
42
44
43
45
private Color curPosColor /* = Color.DarkBlue*/ ;
44
- private Color borderColor /* = SystemColors.ActiveBorder*/ ;
45
- private Color borderColorDisabled /* = SystemColors.Control*/ ;
46
46
private Color foreColor /* = SystemColors.ControlDarkDark*/ ;
47
47
private Color foreColorHot ;
48
48
private Color foreColorPressed /* = SystemColors.Highlight*/ ;
@@ -51,25 +51,26 @@ public static void NotifySettingsChanged(ScrollBarMode value)
51
51
private Color arrowColorPressed ;
52
52
private Color backColor /* = SystemColors.ActiveBorder*/ ;
53
53
private Color backColorDisabled /* = SystemColors.ControlLight*/ ;
54
-
54
+ private Color borderColor /* = SystemColors.ActiveBorder*/ ;
55
+ private Color borderColorDisabled /* = SystemColors.Control*/ ;
55
56
private bool colorsInvalidated ;
56
57
57
58
/// <summary>
58
59
/// Resets the component colors to default values.
59
60
/// </summary>
60
61
private void InitializeColors ( )
61
62
{
62
- curPosColor = Color . DarkBlue ;
63
- borderColor = SystemColors . ActiveBorder ;
64
- borderColorDisabled = SystemColors . InactiveBorder ;
65
- foreColor = SystemColors . ScrollBar ;
66
- foreColorHot = SystemColors . ControlDark ;
67
- foreColorPressed = SystemColors . ControlDarkDark ;
68
- arrowColor = SystemColors . ControlDark ;
69
- arrowColorHot = SystemColors . Highlight ;
70
- arrowColorPressed = SystemColors . HotTrack ;
71
- backColor = SystemColors . Control ;
72
- backColorDisabled = SystemColors . ControlLight ;
63
+ if ( curPosColor . IsEmpty ) curPosColor = Color . FromArgb ( 0 , 0 , 205 ) ; //#0000CD
64
+ if ( foreColor . IsEmpty ) foreColor = Color . FromArgb ( 208 , 209 , 215 ) ; //#D0D1D7
65
+ if ( ! colorsInvalidated ) foreColorHot = Color . FromArgb ( 136 , 136 , 136 ) ; //#888888
66
+ if ( foreColorPressed . IsEmpty ) foreColorPressed = Color . FromArgb ( 106 , 106 , 106 ) ; //#6A6A6A
67
+ if ( ! colorsInvalidated ) arrowColor = Color . FromArgb ( 134 , 137 , 153 ) ; //#868999
68
+ if ( ! colorsInvalidated ) arrowColorHot = Color . FromArgb ( 28 , 151 , 234 ) ; //#1C97EA
69
+ if ( ! colorsInvalidated ) arrowColorPressed = Color . FromArgb ( 0 , 122 , 204 ) ; //#007ACC
70
+ if ( backColor . IsEmpty ) backColor = Color . FromArgb ( 232 , 232 , 236 ) ; //#E8E8EC
71
+ if ( backColorDisabled . IsEmpty ) backColorDisabled = Color . FromArgb ( 192 , 192 , 192 ) ; //#C0C0C0
72
+ if ( borderColor . IsEmpty ) borderColor = Color . FromArgb ( 232 , 232 , 236 ) ; //#E8E8EC
73
+ if ( borderColorDisabled . IsEmpty ) borderColorDisabled = Color . FromArgb ( 136 , 136 , 136 ) ; //#888888
73
74
colorsInvalidated = false ;
74
75
Invalidate ( ) ;
75
76
}
@@ -82,25 +83,17 @@ private void InitializeColors()
82
83
/// </summary>
83
84
public void ValidateColors ( )
84
85
{
85
- if ( ! colorsInvalidated )
86
- {
87
- // No colors defined explicitly -> Reset colors to default.
88
- InitializeColors ( ) ;
89
- return ;
90
- }
86
+ // Reset any unassigned colors to default.
87
+ InitializeColors ( ) ;
88
+
89
+ // If no colors are explicitly defined, not fallback colors are required.
90
+ if ( ! colorsInvalidated ) return ;
91
91
92
- if ( curPosColor . IsEmpty ) curPosColor = Color . DarkBlue ;
93
- if ( borderColor . IsEmpty ) borderColor = SystemColors . ActiveBorder ;
94
- if ( borderColorDisabled . IsEmpty ) borderColorDisabled = SystemColors . InactiveBorder ;
95
- if ( foreColor . IsEmpty ) foreColor = SystemColors . ScrollBar ;
96
- if ( foreColorPressed . IsEmpty ) foreColorPressed = SystemColors . ControlDarkDark ;
97
- if ( backColor . IsEmpty ) backColor = SystemColors . Control ;
98
- if ( backColorDisabled . IsEmpty ) backColorDisabled = SystemColors . ControlLight ;
99
- // Newly introduced color options - do not assign default colors. Instead fall back to associated colors
100
- if ( foreColorHot . IsEmpty ) foreColorHot = foreColor ;
101
- if ( arrowColor . IsEmpty ) arrowColor = foreColor ;
102
- if ( arrowColorHot . IsEmpty ) arrowColorHot = foreColorHot ;
103
- if ( arrowColorPressed . IsEmpty ) arrowColorPressed = foreColorPressed ;
92
+ // Newly introduced color options - do not assign default colors. Instead fall back to associated colors.
93
+ foreColorHot = PluginBase . MainForm . GetThemeColor ( "ScrollBar.HotForeColor" , foreColor ) ;
94
+ arrowColor = PluginBase . MainForm . GetThemeColor ( "ScrollBar.ArrowColor" , foreColor ) ;
95
+ arrowColorHot = PluginBase . MainForm . GetThemeColor ( "ScrollBar.HotArrowColor" , arrowColor ) ;
96
+ arrowColorPressed = PluginBase . MainForm . GetThemeColor ( "ScrollBar.ActiveArrowColor" , foreColorPressed ) ;
104
97
105
98
colorsInvalidated = false ;
106
99
}
@@ -267,14 +260,13 @@ private void DrawBackgroundHorizontal(Graphics g, Rectangle rect)
267
260
/// <param name="g">The <see cref="Graphics"/> used to paint.</param>
268
261
/// <param name="rect">The rectangle in which to paint.</param>
269
262
/// <param name="color">The color to draw the thumb with.</param>
270
- private void DrawThumbVertical ( Graphics g , Rectangle rect , Color color )
263
+ private static void DrawThumbVertical ( Graphics g , Rectangle rect , Color color )
271
264
{
272
265
var innerRect = new Rectangle ( rect . Left + ScaleHelper . Scale ( 2 ) , rect . Top , rect . Width - ScaleHelper . Scale ( 4 ) , rect . Height ) ;
273
266
using ( Brush brush = new SolidBrush ( color ) )
274
267
{
275
268
g . FillRectangle ( brush , innerRect ) ;
276
269
}
277
-
278
270
}
279
271
280
272
/// <summary>
@@ -283,7 +275,7 @@ private void DrawThumbVertical(Graphics g, Rectangle rect, Color color)
283
275
/// <param name="g">The <see cref="Graphics"/> used to paint.</param>
284
276
/// <param name="rect">The rectangle in which to paint.</param>
285
277
/// <param name="color">The color to draw the thumb with.</param>
286
- private void DrawThumbHorizontal ( Graphics g , Rectangle rect , Color color )
278
+ private static void DrawThumbHorizontal ( Graphics g , Rectangle rect , Color color )
287
279
{
288
280
var innerRect = new Rectangle ( rect . Left , rect . Top + ScaleHelper . Scale ( 2 ) , rect . Width , rect . Height - ScaleHelper . Scale ( 4 ) ) ;
289
281
using ( Brush brush = new SolidBrush ( color ) )
@@ -299,19 +291,19 @@ private void DrawThumbHorizontal(Graphics g, Rectangle rect, Color color)
299
291
/// <param name="rect">The rectangle in which to paint.</param>
300
292
/// <param name="color">The color to draw the arrow buttons with.</param>
301
293
/// <param name="arrowUp">true for an up arrow, false otherwise.</param>
302
- private void DrawArrowButtonVertical ( Graphics g , Rectangle rect , Color color , bool arrowUp )
294
+ private static void DrawArrowButtonVertical ( Graphics g , Rectangle rect , Color color , bool arrowUp )
303
295
{
304
296
using ( Brush brush = new SolidBrush ( color ) )
305
297
{
306
298
Point [ ] arrow ;
307
- Int32 pad = 0 ;
299
+ Int32 pad ;
308
300
Point middle = new Point ( rect . Left + rect . Width / 2 , ( rect . Top + rect . Height / 2 ) ) ;
309
301
switch ( arrowUp )
310
302
{
311
303
case true :
312
304
pad = ScaleHelper . Scale ( 4 ) ;
313
305
middle . Y += ScaleHelper . Scale ( 2 ) ;
314
- arrow = new [ ]
306
+ arrow = new Point [ ]
315
307
{
316
308
new Point ( middle . X - pad , middle . Y + 1 ) ,
317
309
new Point ( middle . X + pad + 1 , middle . Y + 1 ) ,
@@ -321,7 +313,7 @@ private void DrawArrowButtonVertical(Graphics g, Rectangle rect, Color color, bo
321
313
default :
322
314
pad = ScaleHelper . Scale ( 3 ) ;
323
315
middle . Y -= ScaleHelper . Scale ( 1 ) ;
324
- arrow = new [ ]
316
+ arrow = new Point [ ]
325
317
{
326
318
new Point ( middle . X - pad , middle . Y - 1 ) ,
327
319
new Point ( middle . X + pad + 1 , middle . Y - 1 ) ,
@@ -341,18 +333,18 @@ private void DrawArrowButtonVertical(Graphics g, Rectangle rect, Color color, bo
341
333
/// <param name="rect">The rectangle in which to paint.</param>
342
334
/// <param name="color">The color to draw the arrow buttons with.</param>
343
335
/// <param name="arrowUp">true for an up arrow, false otherwise.</param>
344
- private void DrawArrowButtonHorizontal ( Graphics g , Rectangle rect , Color color , bool arrowUp )
336
+ private static void DrawArrowButtonHorizontal ( Graphics g , Rectangle rect , Color color , bool arrowUp )
345
337
{
346
338
using ( Brush brush = new SolidBrush ( color ) )
347
339
{
348
340
Point [ ] arrow ;
349
- Int32 pad = 0 ;
341
+ Int32 pad ;
350
342
Point middle = new Point ( rect . Left + rect . Width / 2 , rect . Top + rect . Height / 2 ) ;
351
343
switch ( arrowUp )
352
344
{
353
345
case true :
354
346
pad = ScaleHelper . Scale ( 2 ) ;
355
- arrow = new [ ]
347
+ arrow = new Point [ ]
356
348
{
357
349
new Point ( middle . X + pad , middle . Y - 2 * pad ) ,
358
350
new Point ( middle . X + pad , middle . Y + 2 * pad ) ,
@@ -361,7 +353,7 @@ private void DrawArrowButtonHorizontal(Graphics g, Rectangle rect, Color color,
361
353
break ;
362
354
default :
363
355
pad = ScaleHelper . Scale ( 2 ) ;
364
- arrow = new [ ]
356
+ arrow = new Point [ ]
365
357
{
366
358
new Point ( middle . X - pad , middle . Y - 2 * pad ) ,
367
359
new Point ( middle . X - pad , middle . Y + 2 * pad ) ,
0 commit comments