forked from fdorg/flashdevelop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScrollBarEx.cs
More file actions
2157 lines (2001 loc) · 76.6 KB
/
Copy pathScrollBarEx.cs
File metadata and controls
2157 lines (2001 loc) · 76.6 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
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using System.Runtime.InteropServices;
using System.ComponentModel;
using PluginCore.Helpers;
using PluginCore.Managers;
namespace PluginCore.Controls
{
/// <summary>
/// A custom scrollbar control, modified for FD:
/// http://www.codeproject.com/Articles/41869/Custom-Drawn-Scrollbar
/// </summary>
[Designer(typeof(ScrollBarDesigner))]
[DefaultEvent("Scroll")]
[DefaultProperty("Value")]
public class ScrollBarEx : Control
{
#region drawing
private Color curPosColor = Color.DarkBlue;
private Color borderColor = SystemColors.ActiveBorder;
private Color borderColorDisabled = SystemColors.Control;
private Color foreColor = SystemColors.ControlDarkDark;
private Color foreColorActive = SystemColors.Highlight;
private Color backColor = SystemColors.ActiveBorder;
private Color backColorDisabled = SystemColors.ControlLight;
/// <summary>
/// Draws the background.
/// </summary>
/// <param name="g">The <see cref="Graphics"/> used to paint.</param>
/// <param name="rect">The rectangle in which to paint.</param>
/// <param name="orientation">The <see cref="ScrollBarOrientation"/>.</param>
private void DrawBackground(Graphics g, Rectangle rect, ScrollBarOrientation orientation)
{
if (g == null)
{
throw new ArgumentNullException("g");
}
if (rect.IsEmpty || g.IsVisibleClipEmpty || !g.VisibleClipBounds.IntersectsWith(rect))
{
return;
}
if (orientation == ScrollBarOrientation.Vertical)
{
DrawBackgroundVertical(g, rect);
}
else
{
DrawBackgroundHorizontal(g, rect);
}
}
/// <summary>
/// Draws the thumb.
/// </summary>
/// <param name="g">The <see cref="Graphics"/> used to paint.</param>
/// <param name="rect">The rectangle in which to paint.</param>
/// <param name="state">The <see cref="ScrollBarState"/> of the thumb.</param>
/// <param name="orientation">The <see cref="ScrollBarOrientation"/>.</param>
private void DrawThumb(Graphics g, Rectangle rect, ScrollBarState state, ScrollBarOrientation orientation)
{
if (g == null)
{
throw new ArgumentNullException("g");
}
if (rect.IsEmpty || g.IsVisibleClipEmpty || !g.VisibleClipBounds.IntersectsWith(rect) || state == ScrollBarState.Disabled)
{
return;
}
if (orientation == ScrollBarOrientation.Vertical)
{
DrawThumbVertical(g, rect, state);
}
else
{
DrawThumbHorizontal(g, rect, state);
}
}
/// <summary>
/// Draws an arrow button.
/// </summary>
/// <param name="g">The <see cref="Graphics"/> used to paint.</param>
/// <param name="rect">The rectangle in which to paint.</param>
/// <param name="state">The <see cref="ScrollBarArrowButtonState"/> of the arrow button.</param>
/// <param name="arrowUp">true for an up arrow, false otherwise.</param>
/// <param name="orientation">The <see cref="ScrollBarOrientation"/>.</param>
private void DrawArrowButton(Graphics g, Rectangle rect, ScrollBarArrowButtonState state, bool arrowUp, ScrollBarOrientation orientation)
{
if (g == null)
{
throw new ArgumentNullException("g");
}
if (rect.IsEmpty || g.IsVisibleClipEmpty || !g.VisibleClipBounds.IntersectsWith(rect))
{
return;
}
if (orientation == ScrollBarOrientation.Vertical)
{
DrawArrowButtonVertical(g, rect, state, arrowUp);
}
else
{
DrawArrowButtonHorizontal(g, rect, state, arrowUp);
}
}
/// <summary>
/// Draws the background.
/// </summary>
/// <param name="g">The <see cref="Graphics"/> used to paint.</param>
/// <param name="rect">The rectangle in which to paint.</param>
private void DrawBackgroundVertical(Graphics g, Rectangle rect)
{
using (SolidBrush brush = new SolidBrush(this.Enabled ? backColor : backColorDisabled))
{
g.FillRectangle(brush, rect);
}
}
/// <summary>
/// Draws the background.
/// </summary>
/// <param name="g">The <see cref="Graphics"/> used to paint.</param>
/// <param name="rect">The rectangle in which to paint.</param>
private void DrawBackgroundHorizontal(Graphics g, Rectangle rect)
{
using (SolidBrush brush = new SolidBrush(this.Enabled ? backColor : backColorDisabled))
{
g.FillRectangle(brush, rect);
}
}
/// <summary>
/// Draws the thumb.
/// </summary>
/// <param name="g">The <see cref="Graphics"/> used to paint.</param>
/// <param name="rect">The rectangle in which to paint.</param>
/// <param name="state">The <see cref="ScrollBarState"/> of the thumb.</param>
private void DrawThumbVertical(Graphics g, Rectangle rect, ScrollBarState state)
{
Color color = foreColor;
switch (state)
{
case ScrollBarState.Pressed:
{
color = foreColorActive;
break;
}
}
var innerRect = new Rectangle(rect.Left + ScaleHelper.Scale(2), rect.Top, rect.Width - ScaleHelper.Scale(4), rect.Height);
using (Brush brush = new SolidBrush(color))
{
g.FillRectangle(brush, innerRect);
}
}
/// <summary>
/// Draws the thumb.
/// </summary>
/// <param name="g">The <see cref="Graphics"/> used to paint.</param>
/// <param name="rect">The rectangle in which to paint.</param>
/// <param name="state">The <see cref="ScrollBarState"/> of the thumb.</param>
private void DrawThumbHorizontal(Graphics g, Rectangle rect, ScrollBarState state)
{
Color color = foreColor;
switch (state)
{
case ScrollBarState.Pressed:
{
color = foreColorActive;
break;
}
}
var innerRect = new Rectangle(rect.Left, rect.Top + ScaleHelper.Scale(2), rect.Width, rect.Height - ScaleHelper.Scale(4));
using (Brush brush = new SolidBrush(color))
{
g.FillRectangle(brush, innerRect);
}
}
/// <summary>
/// Draws an arrow button.
/// </summary>
/// <param name="g">The <see cref="Graphics"/> used to paint.</param>
/// <param name="rect">The rectangle in which to paint.</param>
/// <param name="state">The <see cref="ScrollBarArrowButtonState"/> of the arrow button.</param>
/// <param name="arrowUp">true for an up arrow, false otherwise.</param>
private void DrawArrowButtonVertical(Graphics g, Rectangle rect, ScrollBarArrowButtonState state, bool arrowUp)
{
var pressed = state == ScrollBarArrowButtonState.DownPressed || state == ScrollBarArrowButtonState.UpPressed;
using (Brush brush = new SolidBrush(pressed ? foreColorActive : foreColor))
{
Point[] arrow;
Int32 pad = 0;
Point middle = new Point(rect.Left + rect.Width / 2, (rect.Top + rect.Height / 2));
switch (arrowUp)
{
case true:
pad = ScaleHelper.Scale(4);
middle.Y += ScaleHelper.Scale(2);
arrow = new Point[]
{
new Point(middle.X - pad , middle.Y + 1),
new Point(middle.X + pad + 1, middle.Y + 1),
new Point(middle.X, middle.Y - pad)
};
break;
default:
pad = ScaleHelper.Scale(3);
middle.Y -= ScaleHelper.Scale(1);
arrow = new Point[]
{
new Point(middle.X - pad, middle.Y - 1),
new Point(middle.X + pad + 1, middle.Y - 1),
new Point(middle.X, middle.Y + pad)
};
break;
}
g.FillPolygon(brush, arrow);
}
}
/// <summary>
/// Draws an arrow button.
/// </summary>
/// <param name="g">The <see cref="Graphics"/> used to paint.</param>
/// <param name="rect">The rectangle in which to paint.</param>
/// <param name="state">The <see cref="ScrollBarArrowButtonState"/> of the arrow button.</param>
/// <param name="arrowUp">true for an up arrow, false otherwise.</param>
private void DrawArrowButtonHorizontal(Graphics g, Rectangle rect, ScrollBarArrowButtonState state, bool arrowUp)
{
var pressed = state == ScrollBarArrowButtonState.DownPressed || state == ScrollBarArrowButtonState.UpPressed;
using (Brush brush = new SolidBrush(pressed ? foreColorActive : foreColor))
{
Point[] arrow;
Int32 pad = 0;
Point middle = new Point(rect.Left + rect.Width / 2, rect.Top + rect.Height / 2);
switch (arrowUp)
{
case true:
pad = ScaleHelper.Scale(2);
arrow = new Point[]
{
new Point(middle.X + pad, middle.Y - 2 * pad),
new Point(middle.X + pad, middle.Y + 2 * pad),
new Point(middle.X - pad, middle.Y)
};
break;
default:
pad = ScaleHelper.Scale(2);
arrow = new Point[]
{
new Point(middle.X - pad, middle.Y - 2 * pad),
new Point(middle.X - pad, middle.Y + 2 * pad),
new Point(middle.X + pad, middle.Y)
};
break;
}
g.FillPolygon(brush, arrow);
}
}
#endregion
#region fields
/// <summary>
/// Indicates many changes to the scrollbar are happening, so stop painting till finished.
/// </summary>
private bool inUpdate;
/// <summary>
/// Highlights the current line if: value > -1
/// </summary>
private int curPos = -1;
/// <summary>
/// Is over scroll enabled? Follows large change value.
/// </summary>
private bool overScroll = false;
/// <summary>
/// The scrollbar orientation - horizontal / vertical.
/// </summary>
private ScrollBarOrientation orientation = ScrollBarOrientation.Vertical;
/// <summary>
/// The scroll orientation in scroll events.
/// </summary>
private ScrollOrientation scrollOrientation = ScrollOrientation.VerticalScroll;
/// <summary>
/// The clicked channel rectangle.
/// </summary>
private Rectangle clickedBarRectangle;
/// <summary>
/// The thumb rectangle.
/// </summary>
private Rectangle thumbRectangle;
/// <summary>
/// The top arrow rectangle.
/// </summary>
private Rectangle topArrowRectangle;
/// <summary>
/// The bottom arrow rectangle.
/// </summary>
private Rectangle bottomArrowRectangle;
/// <summary>
/// The channel rectangle.
/// </summary>
private Rectangle channelRectangle;
/// <summary>
/// Indicates if top arrow was clicked.
/// </summary>
private bool topArrowClicked;
/// <summary>
/// Indicates if bottom arrow was clicked.
/// </summary>
private bool bottomArrowClicked;
/// <summary>
/// Indicates if channel rectangle above the thumb was clicked.
/// </summary>
private bool topBarClicked;
/// <summary>
/// Indicates if channel rectangle under the thumb was clicked.
/// </summary>
private bool bottomBarClicked;
/// <summary>
/// Indicates if the thumb was clicked.
/// </summary>
private bool thumbClicked;
/// <summary>
/// The state of the thumb.
/// </summary>
private ScrollBarState thumbState = ScrollBarState.Normal;
/// <summary>
/// The state of the top arrow.
/// </summary>
private ScrollBarArrowButtonState topButtonState = ScrollBarArrowButtonState.UpNormal;
/// <summary>
/// The state of the bottom arrow.
/// </summary>
private ScrollBarArrowButtonState bottomButtonState = ScrollBarArrowButtonState.DownNormal;
/// <summary>
/// The scrollbar value minimum.
/// </summary>
private int minimum;
/// <summary>
/// The scrollbar value maximum.
/// </summary>
private int maximum = 100;
/// <summary>
/// The small change value.
/// </summary>
private int smallChange = 1;
/// <summary>
/// The large change value.
/// </summary>
private int largeChange = 10;
/// <summary>
/// The value of the scrollbar.
/// </summary>
private int value;
/// <summary>
/// The width of the thumb.
/// </summary>
private int thumbWidth = ScaleHelper.Scale(13);
/// <summary>
/// The height of the thumb.
/// </summary>
private int thumbHeight;
/// <summary>
/// The width of an arrow.
/// </summary>
private int arrowWidth = ScaleHelper.Scale(13);
/// <summary>
/// The height of an arrow.
/// </summary>
private int arrowHeight = ScaleHelper.Scale(13);
/// <summary>
/// The bottom limit for the thumb bottom.
/// </summary>
private int thumbBottomLimitBottom;
/// <summary>
/// The bottom limit for the thumb top.
/// </summary>
private int thumbBottomLimitTop;
/// <summary>
/// The top limit for the thumb top.
/// </summary>
private int thumbTopLimit;
/// <summary>
/// The current position of the thumb.
/// </summary>
private int thumbPosition;
/// <summary>
/// The track position.
/// </summary>
private int trackPosition;
/// <summary>
/// The progress timer for moving the thumb.
/// </summary>
private Timer progressTimer = new Timer();
/// <summary>
/// Context menu strip.
/// </summary>
private ContextMenuStrip contextMenu;
/// <summary>
/// Container for components.
/// </summary>
private IContainer components;
/// <summary>
/// Menu item.
/// </summary>
private ToolStripMenuItem tsmiScrollHere;
/// <summary>
/// Menu separator.
/// </summary>
private ToolStripSeparator toolStripSeparator1;
/// <summary>
/// Menu item.
/// </summary>
private ToolStripMenuItem tsmiTop;
/// <summary>
/// Menu item.
/// </summary>
private ToolStripMenuItem tsmiBottom;
/// <summary>
/// Menu separator.
/// </summary>
private ToolStripSeparator toolStripSeparator2;
/// <summary>
/// Menu item.
/// </summary>
private ToolStripMenuItem tsmiLargeUp;
/// <summary>
/// Menu item.
/// </summary>
private ToolStripMenuItem tsmiLargeDown;
/// <summary>
/// Menu separator.
/// </summary>
private ToolStripSeparator toolStripSeparator3;
/// <summary>
/// Menu item.
/// </summary>
private ToolStripMenuItem tsmiSmallUp;
/// <summary>
/// Menu item.
/// </summary>
private ToolStripMenuItem tsmiSmallDown;
#endregion
#region constructor
/// <summary>
/// Initializes a new instance of the <see cref="ScrollBarEx"/> class.
/// </summary>
public ScrollBarEx()
{
// sets the control styles of the control
SetStyle(ControlStyles.OptimizedDoubleBuffer
| ControlStyles.ResizeRedraw
| ControlStyles.Selectable
| ControlStyles.AllPaintingInWmPaint
| ControlStyles.UserPaint, true);
// initializes the context menu
this.InitializeComponent();
this.Width = ScaleHelper.Scale(17);
this.Height = ScaleHelper.Scale(200);
// sets the scrollbar up
this.SetUpScrollBar();
// timer for clicking and holding the mouse button
// over/below the thumb and on the arrow buttons
this.progressTimer.Interval = 20;
this.progressTimer.Tick += this.ProgressTimerTick;
this.ContextMenuStrip = this.contextMenu;
}
#endregion
#region events
/// <summary>
/// Occurs when the scrollbar scrolled.
/// </summary>
[Category("Behavior")]
[Description("Is raised, when the scrollbar was scrolled.")]
public event ScrollEventHandler Scroll;
#endregion
#region properties
/// <summary>
/// Gets or sets the current position.
/// </summary>
[Category("Behavior")]
[Description("Gets or sets the is over scroll is enabled.")]
[DefaultValue(false)]
public Boolean OverScroll
{
get
{
return this.overScroll;
}
set
{
// no change, return
if (this.overScroll == value)
{
return;
}
this.overScroll = value;
}
}
/// <summary>
/// Gets or sets the current position.
/// </summary>
[Category("Behavior")]
[Description("Gets or sets the current position.")]
[DefaultValue(-1)]
public int CurrentPosition
{
get
{
return this.curPos;
}
set
{
// no change, return
if (this.curPos == value)
{
return;
}
this.curPos = value;
this.Invalidate();
}
}
/// <summary>
/// Gets or sets the orientation.
/// </summary>
[Category("Layout")]
[Description("Gets or sets the orientation.")]
[DefaultValue(ScrollBarOrientation.Vertical)]
public ScrollBarOrientation Orientation
{
get
{
return this.orientation;
}
set
{
// no change - return
if (value == this.orientation)
{
return;
}
this.orientation = value;
// change text of context menu entries
this.ChangeContextMenuItems();
// save scroll orientation for scroll event
this.scrollOrientation = value == ScrollBarOrientation.Vertical ? ScrollOrientation.VerticalScroll : ScrollOrientation.HorizontalScroll;
// only in DesignMode switch width and height
if (this.DesignMode)
{
this.Size = new Size(this.Height, this.Width);
}
// sets the scrollbar up
this.SetUpScrollBar();
}
}
/// <summary>
/// Gets or sets the minimum value.
/// </summary>
[Category("Behavior")]
[Description("Gets or sets the minimum value.")]
[DefaultValue(0)]
public int Minimum
{
get
{
return this.minimum;
}
set
{
// no change or value invalid - return
if (this.minimum == value || value < 0 || value >= this.maximum)
{
return;
}
this.minimum = value;
// current value less than new minimum value - adjust
if (this.value < value)
{
this.value = value;
}
// is current large change value invalid - adjust
if (this.largeChange > this.maximum - this.minimum)
{
this.largeChange = this.maximum - this.minimum;
}
this.SetUpScrollBar();
// current value less than new minimum value - adjust
if (this.value < value)
{
this.Value = value;
}
else
{
// current value is valid - adjust thumb position
this.ChangeThumbPosition(this.GetThumbPosition());
this.Refresh();
}
}
}
/// <summary>
/// Gets or sets the maximum value.
/// </summary>
[Category("Behavior")]
[Description("Gets or sets the maximum value.")]
[DefaultValue(100)]
public int Maximum
{
get
{
return this.maximum;
}
set
{
// no change or new max. value invalid - return
if (value == this.maximum || value < 1 || value <= this.minimum)
{
return;
}
this.maximum = value;
// is large change value invalid - adjust
if (this.largeChange > this.maximum - this.minimum)
{
this.largeChange = this.maximum - this.minimum;
}
this.SetUpScrollBar();
// is current value greater than new maximum value - adjust
if (this.value > value)
{
this.Value = this.maximum;
}
else
{
// current value is valid - adjust thumb position
this.ChangeThumbPosition(this.GetThumbPosition());
this.Refresh();
}
}
}
/// <summary>
/// Gets or sets the small change amount.
/// </summary>
[Category("Behavior")]
[Description("Gets or sets the small change value.")]
[DefaultValue(1)]
public int SmallChange
{
get
{
return this.smallChange;
}
set
{
// no change or new small change value invalid - return
if (value == this.smallChange || value < 1 || value >= this.largeChange)
{
return;
}
this.smallChange = value;
this.SetUpScrollBar();
}
}
/// <summary>
/// Gets or sets the large change amount.
/// </summary>
[Category("Behavior")]
[Description("Gets or sets the large change value.")]
[DefaultValue(10)]
public int LargeChange
{
get
{
return this.largeChange;
}
set
{
// no change or new large change value is invalid - return
if (value == this.largeChange || value < this.smallChange || value < 2)
{
return;
}
// if value is greater than scroll area - adjust
if (value > this.maximum - this.minimum)
{
this.largeChange = this.maximum - this.minimum;
}
else
{
// set new value
this.largeChange = value;
}
this.SetUpScrollBar();
}
}
/// <summary>
/// Gets or sets the value.
/// </summary>
[Category("Behavior")]
[Description("Gets or sets the current value.")]
[DefaultValue(0)]
public int Value
{
get
{
return this.value;
}
set
{
// no change or invalid value - return
if (this.value == value || value < this.minimum || value > this.maximum)
{
return;
}
this.value = value;
// adjust thumb position
this.ChangeThumbPosition(this.GetThumbPosition());
// raise scroll event
this.OnScroll(new ScrollEventArgs(ScrollEventType.ThumbPosition, -1, this.value, this.scrollOrientation));
this.Refresh();
}
}
/// <summary>
/// Gets or sets the border color.
/// </summary>
[Category("Appearance")]
[Description("Gets or sets the border color.")]
[DefaultValue(typeof(SystemColors), "ActiveBorder")]
public Color BorderColor
{
get
{
return this.borderColor;
}
set
{
this.borderColor = value;
this.Invalidate();
}
}
/// <summary>
/// Gets or sets the border color in disabled state.
/// </summary>
[Category("Appearance")]
[Description("Gets or sets the border color in disabled state.")]
[DefaultValue(typeof(SystemColors), "Control")]
public Color DisabledBorderColor
{
get
{
return this.borderColorDisabled;
}
set
{
this.borderColorDisabled = value;
this.Invalidate();
}
}
/// <summary>
/// Gets or sets the back color.
/// </summary>
[Category("Appearance")]
[Description("Gets or sets the border color.")]
[DefaultValue(typeof(SystemColors), "ActiveBorder")]
public override Color BackColor
{
get
{
return this.backColor;
}
set
{
this.backColor = value;
this.Invalidate();
}
}
/// <summary>
/// Gets or sets the back color.
/// </summary>
[Category("Appearance")]
[Description("Gets or sets the disabled back color.")]
[DefaultValue(typeof(SystemColors), "ControlLight")]
public Color DisabledBackColor
{
get
{
return this.backColorDisabled;
}
set
{
this.backColorDisabled = value;
this.Invalidate();
}
}
/// <summary>
/// Gets or sets the fore color.
/// </summary>
[Category("Appearance")]
[Description("Gets or sets the foreground color on idle.")]
[DefaultValue(typeof(SystemColors), "ControlDarkDark")]
public override Color ForeColor
{
get
{
return this.foreColor;
}
set
{
this.foreColor = value;
this.Invalidate();
}
}
/// <summary>
/// Gets or sets the pressed fore color.
/// </summary>
[Category("Appearance")]
[Description("Gets or sets the foreground color when active.")]
[DefaultValue(typeof(SystemColors), "Highlight")]
public Color ActiveForeColor
{
get
{
return this.foreColorActive;
}
set
{
this.foreColorActive = value;
this.Invalidate();
}
}
/// <summary>
/// Gets or sets the pressed fore color.
/// </summary>
[Category("Appearance")]
[Description("Gets or sets the current position indic color.")]
[DefaultValue(typeof(Color), "DarkBlue")]
public Color CurrentPositionColor
{
get
{
return this.curPosColor;
}
set
{
this.curPosColor = value;
this.Invalidate();
}
}
/// <summary>
/// Gets or sets the opacity of the context menu (from 0 - 1).
/// </summary>
[Category("Appearance")]
[Description("Gets or sets the opacity of the context menu (from 0 - 1).")]
[DefaultValue(typeof(double), "1")]
public double Opacity
{
get
{
return this.contextMenu.Opacity;
}
set
{
// no change - return
if (value == this.contextMenu.Opacity)
{
return;
}
this.contextMenu.AllowTransparency = value != 1;
this.contextMenu.Opacity = value;
}
}
#endregion
#region methods
/// <summary>
/// Prevents the drawing of the control until <see cref="EndUpdate"/> is called.
/// </summary>
public void BeginUpdate()
{
Win32.SendMessage(this.Handle, Win32.WM_SETREDRAW, 0, 0);
this.inUpdate = true;
}
/// <summary>
/// Ends the updating process and the control can draw itself again.
/// </summary>
public void EndUpdate()
{
Win32.SendMessage(this.Handle, Win32.WM_SETREDRAW, 1, 0);
this.inUpdate = false;
this.SetUpScrollBar();
this.Refresh();
}
/// <summary>
/// Raises the <see cref="Scroll"/> event.
/// </summary>
/// <param name="e">The <see cref="ScrollEventArgs"/> that contains the event data.</param>
protected virtual void OnScroll(ScrollEventArgs e)
{
// if event handler is attached - raise scroll event
if (this.Scroll != null)
{
this.Scroll(this, e);
}
}
/// <summary>
/// Paints the background of the control.
/// </summary>
/// <param name="e">A <see cref="PaintEventArgs"/> that contains information about the control to paint.</param>
protected override void OnPaintBackground(PaintEventArgs e)
{
// no painting here
}
/// <summary>
/// Paints the control.
/// </summary>
/// <param name="e">A <see cref="PaintEventArgs"/> that contains information about the control to paint.</param>
protected override void OnPaint(PaintEventArgs e)