Skip to content

Commit 3282d36

Browse files
committed
v2.2.2
1 parent aac4783 commit 3282d36

16 files changed

+192
-163
lines changed

.vs/QuickLibrary/v16/.suo

-12.5 KB
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.

QuickLibrary/DownloadForm.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ public DownloadForm(string url, bool darkMode)
3232

3333
if (darkMode)
3434
{
35-
this.BackColor = ThemeManager.DarkBackColor;
36-
this.ForeColor = Color.White;
35+
DarkMode = darkMode;
3736

3837
cancelButton.BackColor = ThemeManager.DarkSecondColor;
3938
updateButton.BackColor = ThemeManager.DarkSecondColor;

QuickLibrary/QlibFixedForm.cs

+99-32
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,103 @@
11
using System;
22
using System.Collections.Generic;
33
using System.ComponentModel;
4+
using System.Drawing;
45
using System.Windows.Forms;
56

67
namespace QuickLibrary
78
{
89
public class QlibFixedForm : Form
910
{
10-
// LOCKED VARIABLES
11+
// PRIVATE FIELDS
1112

12-
[Browsable(false), Obsolete("Don't use this! (FormBorderStyle = None)", true), EditorBrowsable(EditorBrowsableState.Never)]
13-
public new enum FormBorderStyle { };
13+
private bool darkMode = false;
14+
private bool alternativeAppearance = false;
1415

15-
[Browsable(false), Obsolete("Don't use this! (AutoScaleMode = Dpi)", true), EditorBrowsable(EditorBrowsableState.Never)]
16-
public new enum AutoScaleMode { };
16+
// HIDDEN PROPS
1717

18-
[Browsable(false), Obsolete("Don't use this! (HelpButton = false)", true), EditorBrowsable(EditorBrowsableState.Never)]
19-
public new enum HelpButton { };
20-
[Browsable(false), Obsolete("Don't use this! (AutoScroll = false)", true), EditorBrowsable(EditorBrowsableState.Never)]
21-
public new enum AutoScroll { };
18+
[Browsable(false)]
19+
public new FormBorderStyle FormBorderStyle => base.FormBorderStyle;
2220

23-
[Browsable(false), Obsolete("Don't use this! (AutoScrollMargin = [0, 0])", true), EditorBrowsable(EditorBrowsableState.Never)]
24-
public new enum AutoScrollMargin { };
21+
[Browsable(false)]
22+
public new AutoScaleMode AutoScaleMode => base.AutoScaleMode;
2523

26-
[Browsable(false), Obsolete("Don't use this! (AutoScrollMinSize = [0, 0])", true), EditorBrowsable(EditorBrowsableState.Never)]
27-
public new enum AutoScrollMinSize { };
24+
[Browsable(false)]
25+
public new bool HelpButton => base.HelpButton;
2826

29-
[Browsable(false), Obsolete("Don't use this! (AutoSize = false)", true), EditorBrowsable(EditorBrowsableState.Never)]
30-
public new enum AutoSize { };
27+
[Browsable(false)]
28+
public new bool AutoScroll => base.AutoScroll;
3129

32-
[Browsable(false), Obsolete("Don't use this! (AutoSizeMode = GrowAndShrink)", true), EditorBrowsable(EditorBrowsableState.Never)]
33-
public new enum AutoSizeMode { };
30+
[Browsable(false)]
31+
public new Size AutoScrollMargin => base.AutoScrollMargin;
3432

35-
[Browsable(false), Obsolete("Don't use this! (BackgroundImage = None)", true), EditorBrowsable(EditorBrowsableState.Never)]
36-
public new enum BackgroundImage { };
33+
[Browsable(false)]
34+
public new Size AutoScrollMinSize => base.AutoScrollMinSize;
3735

38-
[Browsable(false), Obsolete("Don't use this! (BackgroundImageLayout = Tile)", true), EditorBrowsable(EditorBrowsableState.Never)]
39-
public new enum BackgroundImageLayout { };
36+
[Browsable(false)]
37+
public new bool AutoSize => base.AutoSize;
4038

41-
[Browsable(false), Obsolete("Don't use this! (Font = ThemeManager.DefaultFont)", true), EditorBrowsable(EditorBrowsableState.Never)]
42-
public new enum Font { };
39+
[Browsable(false)]
40+
public new AutoSizeMode AutoSizeMode => base.AutoSizeMode;
4341

44-
// CUSTOM VARIABLES
42+
[Browsable(false)]
43+
public new Image BackgroundImage => base.BackgroundImage;
4544

46-
[Category("Qlib Options"), Browsable(true), Description("Draggable form")]
45+
[Browsable(false)]
46+
public new ImageLayout BackgroundImageLayout => base.BackgroundImageLayout;
47+
48+
[Browsable(false)]
49+
public new Font Font => base.Font;
50+
51+
[Browsable(false)]
52+
public new Color ForeColor => base.ForeColor;
53+
54+
[Browsable(false)]
55+
public new Color BackColor => base.BackColor;
56+
57+
[Browsable(false)]
58+
public new RightToLeft RightToLeft => base.RightToLeft;
59+
60+
[Browsable(false)]
61+
public new bool RightToLeftLayout => base.RightToLeftLayout;
62+
63+
// PUBLIC PROPS
64+
65+
[Category("Qlib props"), Browsable(true), Description("Draggable form")]
4766
public bool Draggable { get; set; } = false;
4867

49-
[Category("Qlib Options"), Browsable(true), Description("Title label")]
68+
[Category("Qlib props"), Browsable(true), Description("Title label")]
5069
public Label TitleLabel { get; set; } = null;
5170

71+
[Category("Qlib props"), Browsable(true), Description("Dark mode")]
72+
public bool DarkMode
73+
{
74+
get { return darkMode; }
75+
set { SetDarkMode(value, alternativeAppearance); }
76+
}
77+
78+
[Category("Qlib props"), Browsable(true), Description("Alternative appearance")]
79+
80+
public bool AlternativeAppearance
81+
{
82+
get { return alternativeAppearance; }
83+
set { SetDarkMode(darkMode, value); }
84+
}
85+
5286
public QlibFixedForm()
5387
{
54-
base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
55-
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
88+
base.FormBorderStyle = FormBorderStyle.None;
89+
base.AutoScaleMode = AutoScaleMode.Dpi;
5690
base.HelpButton = false;
5791
base.AutoScroll = false;
58-
base.AutoScrollMargin = new System.Drawing.Size(0, 0);
59-
base.AutoScrollMinSize = new System.Drawing.Size(0, 0);
92+
base.AutoScrollMargin = new Size(0, 0);
93+
base.AutoScrollMinSize = new Size(0, 0);
6094
base.AutoSize = false;
61-
base.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
95+
base.AutoSizeMode = AutoSizeMode.GrowAndShrink;
6296
base.BackgroundImage = null;
6397
base.BackgroundImageLayout = ImageLayout.Tile;
6498
base.Font = ThemeManager.DefaultFont;
6599

66-
this.TextChanged += QlibFixedForm_TextChanged;
100+
TextChanged += QlibFixedForm_TextChanged;
67101
}
68102

69103
protected override void OnHandleCreated(EventArgs e)
@@ -112,5 +146,38 @@ private void GoDrag()
112146
NativeMethodsManager.ReleaseCapture();
113147
NativeMethodsManager.SendMessage(Handle, 0xA1, 0x2, 0);
114148
}
149+
150+
private void SetDarkMode(bool dark, bool alternative)
151+
{
152+
darkMode = dark;
153+
alternativeAppearance = alternative;
154+
155+
if (dark)
156+
{
157+
base.ForeColor = Color.White;
158+
159+
if (alternative)
160+
{
161+
base.BackColor = ThemeManager.DarkMainColor;
162+
}
163+
else
164+
{
165+
base.BackColor = ThemeManager.DarkBackColor;
166+
}
167+
}
168+
else
169+
{
170+
base.ForeColor = Color.Black;
171+
172+
if (alternative)
173+
{
174+
base.BackColor = ThemeManager.LightMainColor;
175+
}
176+
else
177+
{
178+
base.BackColor = ThemeManager.LightBackColor;
179+
}
180+
}
181+
}
115182
}
116183
}

QuickLibrary/QlibNumericBox.cs

+78-44
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.ComponentModel;
33
using System.Drawing;
4+
using System.Drawing.Drawing2D;
45
using System.Windows.Forms;
56

67
namespace QuickLibrary
@@ -10,9 +11,15 @@ public class QlibNumericBox : Panel
1011
// PRIVATE FIELDS
1112

1213
private InternalNumericUpDown numeric;
14+
private Button upBtn;
15+
private Button downBtn;
16+
private bool darkMode = false;
1317

1418
// HIDDEN PROPS
1519

20+
[Browsable(false)]
21+
public new string Text => base.Text;
22+
1623
[Browsable(false)]
1724
public new Image BackgroundImage => base.BackgroundImage;
1825

@@ -72,18 +79,45 @@ public decimal Minimum
7279
set { numeric.Minimum = value; }
7380
}
7481

82+
[Category("Qlib props"), Browsable(true), Description("Dark mode")]
83+
public bool DarkMode
84+
{
85+
get { return darkMode; }
86+
set { SetDarkMode(value); }
87+
}
88+
7589
// CONSTRUCTOR
7690

7791
public QlibNumericBox()
7892
{
7993
numeric = new InternalNumericUpDown();
80-
8194
numeric.Location = new Point(7, 7);
8295
numeric.BorderStyle = BorderStyle.None;
8396
numeric.BackColor = BackColor;
84-
8597
Controls.Add(numeric);
8698

99+
upBtn = new Button();
100+
upBtn.Size = new Size(21, 16);
101+
upBtn.BackColor = BackColor;
102+
upBtn.FlatStyle = FlatStyle.Flat;
103+
upBtn.FlatAppearance.BorderSize = 0;
104+
upBtn.Cursor = Cursors.Default;
105+
upBtn.ImageAlign = ContentAlignment.MiddleCenter;
106+
upBtn.Padding = Padding.Empty;
107+
upBtn.Click += UpBtn_Click;
108+
Controls.Add(upBtn);
109+
110+
downBtn = new Button();
111+
downBtn.Size = new Size(21, 16);
112+
downBtn.BackColor = BackColor;
113+
downBtn.FlatStyle = FlatStyle.Flat;
114+
downBtn.FlatAppearance.BorderSize = 0;
115+
downBtn.Cursor = Cursors.Default;
116+
downBtn.Click += DownBtn_Click;
117+
Controls.Add(downBtn);
118+
119+
numeric.SendToBack();
120+
87121
base.Cursor = Cursors.IBeam;
88122

89123
SizeChanged += QlibNumericBox_SizeChanged;
@@ -93,6 +127,16 @@ public QlibNumericBox()
93127
numeric.ValueChanged += Numeric_ValueChanged;
94128
}
95129

130+
private void DownBtn_Click(object sender, EventArgs e)
131+
{
132+
numeric.DownButton();
133+
}
134+
135+
private void UpBtn_Click(object sender, EventArgs e)
136+
{
137+
numeric.UpButton();
138+
}
139+
96140
// PRIVATE BODY
97141

98142
private void Numeric_ValueChanged(object sender, EventArgs e)
@@ -113,6 +157,8 @@ private void QlibNumericBox_GotFocus(object sender, EventArgs e)
113157
private void QlibNumericBox_SizeChanged(object sender, EventArgs e)
114158
{
115159
numeric.Size = new Size(Size.Width - 14, numeric.Size.Height);
160+
upBtn.Location = new Point(Size.Width - 21, 0);
161+
downBtn.Location = new Point(Size.Width - 21, 16);
116162
}
117163

118164
internal class InternalNumericUpDown : NumericUpDown
@@ -126,54 +172,15 @@ public InternalNumericUpDown()
126172
protected override void OnPaint(PaintEventArgs e)
127173
{
128174
e.Graphics.Clear(BackColor);
129-
130-
Brush arrowsBrush = new SolidBrush(ForeColor);
131-
if (!Enabled)
132-
{
133-
arrowsBrush = new SolidBrush(ThemeManager.BorderColor);
134-
}
135-
136-
e.Graphics.FillPolygon(arrowsBrush, new PointF[]
137-
{
138-
new PointF(Width - 14, 15),
139-
new PointF(Width - 10, 19),
140-
new PointF(Width - 6, 15)
141-
});
142-
e.Graphics.FillPolygon(arrowsBrush, new PointF[]
143-
{
144-
new PointF(Width - 15, 10),
145-
new PointF(Width - 10, 5),
146-
new PointF(Width - 6, 10)
147-
});
148-
}
149-
150-
protected override void OnMouseClick(MouseEventArgs e)
151-
{
152-
if (e.X > Width - 18)
153-
{
154-
Focus();
155-
if (e.Y > Height / 2)
156-
{
157-
if (Value > Minimum)
158-
{
159-
Value--;
160-
}
161-
}
162-
else
163-
{
164-
if (Value < Maximum)
165-
{
166-
Value++;
167-
}
168-
}
169-
}
170175
}
171176
}
172177

173178
// PUBLIC METHODS
174179

175-
public void SetDarkMode(bool dark)
180+
private void SetDarkMode(bool dark)
176181
{
182+
darkMode = dark;
183+
177184
if (dark)
178185
{
179186
base.BackColor = ThemeManager.DarkSecondColor;
@@ -184,7 +191,34 @@ public void SetDarkMode(bool dark)
184191
base.BackColor = ThemeManager.LightSecondColor;
185192
numeric.ForeColor = Color.Black;
186193
}
194+
195+
Bitmap upArrowBmp = new Bitmap(8, 8);
196+
using (Graphics g = Graphics.FromImage(upArrowBmp))
197+
{
198+
g.FillPolygon(new SolidBrush(ForeColor), new PointF[]
199+
{
200+
new PointF(-1, 6),
201+
new PointF(8, 6),
202+
new PointF(3, 1)
203+
});
204+
}
205+
upBtn.Image = upArrowBmp;
206+
207+
Bitmap downArrowBmp = new Bitmap(8, 8);
208+
using (Graphics g = Graphics.FromImage(downArrowBmp))
209+
{
210+
g.FillPolygon(new SolidBrush(ForeColor), new PointF[]
211+
{
212+
new PointF(0, 0),
213+
new PointF(7, 0),
214+
new PointF(3, 4)
215+
});
216+
}
217+
downBtn.Image = downArrowBmp;
218+
187219
numeric.BackColor = ThemeManager.DarkSecondColor;
220+
upBtn.BackColor = ThemeManager.DarkSecondColor;
221+
downBtn.BackColor = ThemeManager.DarkSecondColor;
188222
}
189223

190224
// EVENTS

0 commit comments

Comments
 (0)