11using System ;
2+ using System . ComponentModel ;
23using System . Drawing ;
34using System . Drawing . Drawing2D ;
45using System . Drawing . Text ;
@@ -8,102 +9,167 @@ namespace QuickLibrary
89{
910 public class QlibCheckBox : CheckBox
1011 {
12+ // PRIVATE FIELDS
13+
1114 private bool darkMode = false ;
1215 private string darkText ;
1316 private bool hovered = false ;
1417 private bool pressed = false ;
1518
16- public string Text
17- {
18- get
19- {
20- if ( darkMode )
21- {
22- return darkText ;
23- }
24- else
25- {
26- return base . Text ;
27- }
28- }
19+ // HIDDEN PROPS
2920
30- set
31- {
32- if ( darkMode )
33- {
34- darkText = value ;
35- }
36- else
37- {
38- base . Text = value ;
39- }
40- }
21+ [ Browsable ( false ) ]
22+ public new Appearance Appearance => base . Appearance ;
23+
24+ [ Browsable ( false ) ]
25+ public new Color ForeColor => base . ForeColor ;
26+
27+ [ Browsable ( false ) ]
28+ public new Color BackColor => base . BackColor ;
29+
30+ [ Browsable ( false ) ]
31+ public new Image BackgroundImage => base . BackgroundImage ;
32+
33+ [ Browsable ( false ) ]
34+ public new ImageLayout BackgroundImageLayout => base . BackgroundImageLayout ;
35+
36+ [ Browsable ( false ) ]
37+ public new ContentAlignment CheckAlign => base . CheckAlign ;
38+
39+ [ Browsable ( false ) ]
40+ public new Image Image => base . Image ;
41+
42+ [ Browsable ( false ) ]
43+ public new Cursor Cursor => base . Cursor ;
44+
45+ [ Browsable ( false ) ]
46+ public new CheckState CheckState => base . CheckState ;
47+
48+ [ Browsable ( false ) ]
49+ public new FlatButtonAppearance FlatAppearance => base . FlatAppearance ;
50+
51+ [ Browsable ( false ) ]
52+ public new FlatStyle FlatStyle => base . FlatStyle ;
53+
54+ [ Browsable ( false ) ]
55+ public new ContentAlignment ImageAlign => base . ImageAlign ;
56+
57+ [ Browsable ( false ) ]
58+ public new int ImageIndex => base . ImageIndex ;
59+
60+ [ Browsable ( false ) ]
61+ public new string ImageKey => base . ImageKey ;
62+
63+ [ Browsable ( false ) ]
64+ public new Padding Padding => base . Padding ;
65+
66+ [ Browsable ( false ) ]
67+ public new RightToLeft RightToLeft => base . RightToLeft ;
68+
69+ [ Browsable ( false ) ]
70+ public new bool AutoSize => base . AutoSize ;
71+
72+ [ Browsable ( false ) ]
73+ public new DockStyle Dock => base . Dock ;
74+
75+ [ Browsable ( false ) ]
76+ public new Size MinimumSize => base . MinimumSize ;
77+
78+ [ Browsable ( false ) ]
79+ public new Size MaximumSize => base . MaximumSize ;
80+
81+ [ Browsable ( false ) ]
82+ public new bool ThreeState => base . ThreeState ;
83+
84+ [ Browsable ( false ) ]
85+ public new bool AutoCheck => base . AutoCheck ;
86+
87+ // PUBLIC PROPS
88+
89+ [ Category ( "Qlib props" ) , Browsable ( true ) , Description ( "Dark mode" ) ]
90+ public bool DarkMode
91+ {
92+ get { return darkMode ; }
93+ set { SetDarkMode ( value ) ; }
4194 }
4295
96+ // CONSTRUCTOR
97+
4398 public QlibCheckBox ( )
4499 {
45100 if ( darkMode )
46101 {
47- SetStyle ( ControlStyles . UserPaint , true ) ;
48- this . SetStyle ( ControlStyles . AllPaintingInWmPaint , true ) ;
49-
50- this . MouseEnter += CustomCheckBox_MouseEnter ;
51- this . MouseLeave += CustomCheckBox_MouseLeave ;
52- this . MouseDown += CustomCheckBox_MouseDown ;
53- this . MouseUp += CustomCheckBox_MouseUp ;
102+
54103 }
55104 }
56105
106+ // PRIVATE BODY
107+
57108 private void CustomCheckBox_MouseUp ( object sender , MouseEventArgs e )
58109 {
59110 pressed = false ;
60- this . Refresh ( ) ;
111+ Refresh ( ) ;
61112 }
62113
63114 private void CustomCheckBox_MouseDown ( object sender , MouseEventArgs e )
64115 {
65116 pressed = true ;
66- this . Refresh ( ) ;
117+ Refresh ( ) ;
67118 }
68119
69120 private void CustomCheckBox_MouseLeave ( object sender , EventArgs e )
70121 {
71122 hovered = false ;
72- this . Refresh ( ) ;
123+ Refresh ( ) ;
73124 }
74125
75126 private void CustomCheckBox_MouseEnter ( object sender , EventArgs e )
76127 {
77128 hovered = true ;
78- this . Refresh ( ) ;
129+ Refresh ( ) ;
79130 }
80131
81- public void SetDarkMode ( bool dark )
132+ private void SetDarkMode ( bool dark )
82133 {
83- this . darkMode = dark ;
134+ darkMode = dark ;
84135
85136 if ( dark )
86137 {
87- darkText = this . Text ;
88- this . Text = " " ;
138+ base . BackColor = ThemeManager . DarkBackColor ;
139+ base . ForeColor = Color . White ;
140+ darkText = Text ;
141+ //Text = " ";
142+
143+ SetStyle ( ControlStyles . UserPaint , true ) ;
144+ SetStyle ( ControlStyles . AllPaintingInWmPaint , true ) ;
145+
146+ MouseEnter += CustomCheckBox_MouseEnter ;
147+ MouseLeave += CustomCheckBox_MouseLeave ;
148+ MouseDown += CustomCheckBox_MouseDown ;
149+ MouseUp += CustomCheckBox_MouseUp ;
150+ }
151+ else
152+ {
153+ base . BackColor = ThemeManager . LightBackColor ;
154+ base . ForeColor = Color . Black ;
89155 }
90156 }
91157
92158 protected override void OnPaint ( PaintEventArgs e )
93159 {
94160 if ( darkMode )
95161 {
96- int top = ( this . Height / 2 ) - 8 ;
162+ int top = ( Height / 2 ) - 8 ;
97163
98- e . Graphics . Clear ( this . BackColor ) ;
164+ e . Graphics . Clear ( BackColor ) ;
99165
100- if ( this . pressed )
166+ if ( pressed )
101167 {
102168 e . Graphics . FillRectangle ( new SolidBrush ( ThemeManager . PressedColor ) , new Rectangle ( 0 , top + 2 , 13 , 13 ) ) ;
103169 }
104170 else
105171 {
106- if ( this . hovered )
172+ if ( hovered )
107173 {
108174 e . Graphics . FillRectangle ( new SolidBrush ( ThemeManager . DarkHoverColor ) , new Rectangle ( 0 , top + 2 , 13 , 13 ) ) ;
109175 }
@@ -113,19 +179,19 @@ protected override void OnPaint(PaintEventArgs e)
113179 }
114180 }
115181
116- if ( this . Focused )
182+ if ( Focused )
117183 {
118184 e . Graphics . DrawRectangle ( new Pen ( ThemeManager . BorderColor , 2 ) , new Rectangle ( 1 , top + 3 , 11 , 11 ) ) ;
119185 }
120186
121- if ( this . Checked )
187+ if ( Checked )
122188 {
123189 e . Graphics . SmoothingMode = SmoothingMode . AntiAlias ;
124190
125- if ( this . Enabled )
191+ if ( Enabled )
126192 {
127- e . Graphics . DrawLine ( new Pen ( this . ForeColor , 2 ) , 2 , top + 7 , 5 , top + 10 ) ;
128- e . Graphics . DrawLine ( new Pen ( this . ForeColor , 2 ) , 5 , top + 11 , 12 , top + 4 ) ;
193+ e . Graphics . DrawLine ( new Pen ( ForeColor , 2 ) , 2 , top + 7 , 5 , top + 10 ) ;
194+ e . Graphics . DrawLine ( new Pen ( ForeColor , 2 ) , 5 , top + 11 , 12 , top + 4 ) ;
129195 }
130196 else
131197 {
@@ -135,13 +201,13 @@ protected override void OnPaint(PaintEventArgs e)
135201 }
136202
137203 e . Graphics . TextRenderingHint = TextRenderingHint . ClearTypeGridFit ;
138- if ( this . Enabled )
204+ if ( Enabled )
139205 {
140- e . Graphics . DrawString ( darkText , this . Font , new SolidBrush ( this . ForeColor ) , 17 , top ) ;
206+ e . Graphics . DrawString ( Text , Font , new SolidBrush ( ForeColor ) , 17 , top ) ;
141207 }
142208 else
143209 {
144- e . Graphics . DrawString ( darkText , this . Font , new SolidBrush ( ThemeManager . BorderColor ) , 17 , top ) ;
210+ e . Graphics . DrawString ( Text , Font , new SolidBrush ( ThemeManager . BorderColor ) , 17 , top ) ;
145211 }
146212 }
147213 else
0 commit comments