Skip to content

Commit 1e8a1c2

Browse files
committed
v2.0.0 initial commit
1 parent 1306a83 commit 1e8a1c2

26 files changed

+407
-50
lines changed

.vs/QuickLibrary/v16/.suo

-15.5 KB
Binary file not shown.
80 KB
Binary file not shown.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using System;
2+
using System.Runtime.InteropServices;
3+
4+
5+
namespace QuickLibrary
6+
{
7+
public static class NativeMethodsManager
8+
{
9+
public const int WM_NCLBUTTONDOWN = 0xA1;
10+
public const int HT_CAPTION = 0x2;
11+
public const int GWL_HWNDPARENT = -8;
12+
13+
public enum ScrollBarType : uint
14+
{
15+
SbHorz = 0,
16+
SbVert = 1,
17+
SbCtl = 2,
18+
SbBoth = 3
19+
}
20+
21+
public enum Message : uint
22+
{
23+
WM_VSCROLL = 0x0115
24+
}
25+
26+
public enum ScrollBarCommands : uint
27+
{
28+
SB_LINEDOWN = 1,
29+
SB_THUMBPOSITION = 4
30+
}
31+
32+
[DllImport("user32.dll")]
33+
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
34+
35+
[DllImport("User32.dll")]
36+
public extern static int SendMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
37+
38+
[DllImport("user32.dll")]
39+
public static extern bool ReleaseCapture();
40+
41+
[DllImport("user32.dll", SetLastError = true)]
42+
public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
43+
44+
[DllImport("user32.dll", SetLastError = true)]
45+
public static extern IntPtr FindWindowEx(IntPtr hP, IntPtr hC, string sC, string sW);
46+
47+
[DllImport("user32.dll", SetLastError = true)]
48+
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
49+
50+
[DllImport("user32.dll", SetLastError = true)]
51+
public static extern IntPtr FindWindow(string lpWindowClass, string lpWindowName);
52+
53+
[DllImport("User32.dll")]
54+
public extern static int GetScrollPos(IntPtr hWnd, int nBar);
55+
}
56+
}

QuickLibrary/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.0")]
36-
[assembly: AssemblyFileVersion("1.0.0")]
35+
[assembly: AssemblyVersion("2.0.0")]
36+
[assembly: AssemblyFileVersion("2.0.0")]
3737
[assembly: NeutralResourcesLanguage("en")]

QuickLibrary/QlibCheckBox.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ protected override void OnPaint(PaintEventArgs e)
9090
}
9191
else
9292
{
93-
ControlPaint.DrawBorder(e.Graphics, new Rectangle(0, 2, 13, 13), ThemeManager.BorderColor, ButtonBorderStyle.Solid);
93+
//ControlPaint.DrawBorder(e.Graphics, new Rectangle(0, 2, 13, 13), ThemeManager.BorderColor, ButtonBorderStyle.Solid);
9494
}
9595

9696
if (this.Checked)
@@ -109,7 +109,7 @@ protected override void OnPaint(PaintEventArgs e)
109109
}
110110
}
111111

112-
e.Graphics.TextRenderingHint = TextRenderingHint.SystemDefault;
112+
e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
113113
if (this.Enabled)
114114
{
115115
e.Graphics.DrawString(darkText, this.Font, new SolidBrush(this.ForeColor), 17, 0);

QuickLibrary/QlibComboBox.cs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Drawing;
2+
using System.Drawing.Drawing2D;
23
using System.Drawing.Text;
34
using System.Windows.Forms;
45

@@ -45,7 +46,7 @@ protected override void OnPaint(PaintEventArgs e)
4546
{
4647
if (darkMode)
4748
{
48-
e.Graphics.Clear(ThemeManager.DarkBackColor);
49+
e.Graphics.Clear(ThemeManager.DarkSecondColor);
4950
}
5051
else
5152
{
@@ -56,38 +57,31 @@ protected override void OnPaint(PaintEventArgs e)
5657
{
5758
if (darkMode)
5859
{
59-
e.Graphics.FillRectangle(new SolidBrush(ThemeManager.DarkHoverColor), 0, 0, this.Width, this.Height - 2);
60+
e.Graphics.Clear(ThemeManager.DarkHoverColor);
6061
}
6162
else
6263
{
63-
e.Graphics.FillRectangle(new SolidBrush(ThemeManager.LightHoverColor), 0, 0, this.Width, this.Height - 2);
64+
e.Graphics.Clear(ThemeManager.LightHoverColor);
6465
}
6566
}
66-
else
67-
{
68-
e.Graphics.FillRectangle(new SolidBrush(this.BackColor), 0, 0, this.Width, this.Height - 2);
69-
}
70-
71-
Rectangle newBounds = new Rectangle(this.ClientRectangle.X, this.ClientRectangle.Y, this.ClientRectangle.Width, this.ClientRectangle.Height - 1);
72-
ControlPaint.DrawBorder(e.Graphics, newBounds, ThemeManager.BorderColor, ButtonBorderStyle.Solid);
7367

74-
e.Graphics.DrawLine(new Pen(ThemeManager.BorderColor), this.Width - 18, 0, this.Width - 18, this.Height - 2);
7568
e.Graphics.FillPolygon(new SolidBrush(this.ForeColor), new PointF[]
7669
{
77-
new PointF(this.Width - 13, 10),
78-
new PointF(this.Width - 9, 14),
79-
new PointF(this.Width - 5, 10)
70+
new PointF(this.Width - 19, 14),
71+
new PointF(this.Width - 15, 18),
72+
new PointF(this.Width - 11, 14)
8073
});
8174

82-
e.Graphics.TextRenderingHint = TextRenderingHint.SystemDefault;
83-
e.Graphics.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), 3, 3);
75+
e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
76+
e.Graphics.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), 12, 7);
8477
}
8578

8679
protected override void OnDrawItem(DrawItemEventArgs e)
8780
{
8881
e.DrawBackground();
8982
if (e.Index != -1)
9083
{
84+
e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
9185
if (!darkMode && (e.State & DrawItemState.Selected) == DrawItemState.Selected)
9286
{
9387
e.Graphics.DrawString(this.Items[e.Index].ToString(), this.Font, Brushes.White, e.Bounds.X, e.Bounds.Y);

QuickLibrary/QlibFixedForm.cs

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Windows.Forms;
5+
6+
namespace QuickLibrary
7+
{
8+
public class QlibFixedForm : Form
9+
{
10+
public bool draggable = false;
11+
12+
[Browsable(false), Obsolete("Don't use this! (FormBorderStyle = None)", true), EditorBrowsable(EditorBrowsableState.Never)]
13+
public new enum FormBorderStyle { };
14+
15+
[Browsable(false), Obsolete("Don't use this! (AutoScaleMode = Dpi)", true), EditorBrowsable(EditorBrowsableState.Never)]
16+
public new enum AutoScaleMode { };
17+
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 { };
22+
23+
[Browsable(false), Obsolete("Don't use this! (AutoScrollMargin = [0, 0])", true), EditorBrowsable(EditorBrowsableState.Never)]
24+
public new enum AutoScrollMargin { };
25+
26+
[Browsable(false), Obsolete("Don't use this! (AutoScrollMinSize = [0, 0])", true), EditorBrowsable(EditorBrowsableState.Never)]
27+
public new enum AutoScrollMinSize { };
28+
29+
[Browsable(false), Obsolete("Don't use this! (AutoSize = false)", true), EditorBrowsable(EditorBrowsableState.Never)]
30+
public new enum AutoSize { };
31+
32+
[Browsable(false), Obsolete("Don't use this! (AutoSizeMode = GrowAndShrink)", true), EditorBrowsable(EditorBrowsableState.Never)]
33+
public new enum AutoSizeMode { };
34+
35+
[Browsable(false), Obsolete("Don't use this! (BackgroundImage = None)", true), EditorBrowsable(EditorBrowsableState.Never)]
36+
public new enum BackgroundImage { };
37+
38+
[Browsable(false), Obsolete("Don't use this! (BackgroundImageLayout = Tile)", true), EditorBrowsable(EditorBrowsableState.Never)]
39+
public new enum BackgroundImageLayout { };
40+
41+
[Browsable(false), Obsolete("Don't use this! (Font = ThemeManager.DefaultFont)", true), EditorBrowsable(EditorBrowsableState.Never)]
42+
public new enum Font { };
43+
44+
protected override CreateParams CreateParams
45+
{
46+
get
47+
{
48+
const int CS_DROPSHADOW = 0x20000;
49+
CreateParams cp = base.CreateParams;
50+
cp.ClassStyle |= CS_DROPSHADOW;
51+
return cp;
52+
}
53+
}
54+
55+
public QlibFixedForm()
56+
{
57+
base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
58+
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
59+
base.HelpButton = false;
60+
base.AutoScroll = false;
61+
base.AutoScrollMargin = new System.Drawing.Size(0, 0);
62+
base.AutoScrollMinSize = new System.Drawing.Size(0, 0);
63+
base.AutoSize = false;
64+
base.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
65+
base.BackgroundImage = null;
66+
base.BackgroundImageLayout = ImageLayout.Tile;
67+
base.Font = ThemeManager.DefaultFont;
68+
}
69+
70+
public void SetDraggableControls(List<Control> controls)
71+
{
72+
foreach (Control control in controls)
73+
{
74+
control.MouseDown += Control_MouseDown;
75+
}
76+
}
77+
78+
private void Control_MouseDown(object sender, MouseEventArgs e)
79+
{
80+
if (e.Button == MouseButtons.Left)
81+
{
82+
GoDrag();
83+
}
84+
}
85+
86+
protected override void OnMouseDown(MouseEventArgs e)
87+
{
88+
base.OnMouseDown(e);
89+
90+
if (draggable && e.Button == MouseButtons.Left)
91+
{
92+
GoDrag();
93+
}
94+
}
95+
96+
private void GoDrag()
97+
{
98+
Cursor.Current = Cursors.SizeAll;
99+
NativeMethodsManager.ReleaseCapture();
100+
NativeMethodsManager.SendMessage(Handle, 0xA1, 0x2, 0);
101+
}
102+
}
103+
}

QuickLibrary/QlibGroupBox.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void PaintDarkGroupBox(object sender, PaintEventArgs p)
2929

3030
p.Graphics.Clear(ThemeManager.DarkBackColor);
3131

32-
p.Graphics.TextRenderingHint = TextRenderingHint.SystemDefault;
32+
p.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
3333
p.Graphics.DrawString(box.Text, box.Font, Brushes.White, -2, -3);
3434

3535
p.Graphics.DrawLine(pen, 0, 20, 0, box.Height - 2); //left border

QuickLibrary/QlibMenuSeparator.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.Windows.Forms;
2+
using System.Drawing;
3+
4+
namespace QuickLibrary
5+
{
6+
public class QlibMenuSeparator : ToolStripSeparator
7+
{
8+
public QlibMenuSeparator() { }
9+
10+
protected override void OnPaint(PaintEventArgs e)
11+
{
12+
int y = e.ClipRectangle.Y + (e.ClipRectangle.Height / 2) - 1;
13+
e.Graphics.DrawLine(new Pen(ThemeManager.BorderColor), e.ClipRectangle.X + 4, y, e.ClipRectangle.Width - 5, y);
14+
}
15+
}
16+
}

QuickLibrary/QlibNumericBox.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace QuickLibrary
55
{
66
public class QlibNumericBox : NumericUpDown
77
{
8-
private bool darkMode = false;
8+
//private bool darkMode = false;
99

1010
public QlibNumericBox()
1111
{
@@ -15,7 +15,7 @@ public QlibNumericBox()
1515

1616
public void SetDarkMode(bool dark)
1717
{
18-
this.darkMode = dark;
18+
//this.darkMode = dark;
1919

2020
if (dark)
2121
{
@@ -27,10 +27,10 @@ public void SetDarkMode(bool dark)
2727
protected override void OnPaint(PaintEventArgs e)
2828
{
2929
e.Graphics.Clear(this.BackColor);
30-
ControlPaint.DrawBorder(e.Graphics, this.ClientRectangle, ThemeManager.BorderColor, ButtonBorderStyle.Solid);
30+
//ControlPaint.DrawBorder(e.Graphics, this.ClientRectangle, ThemeManager.BorderColor, ButtonBorderStyle.Solid);
3131

32-
e.Graphics.DrawLine(new Pen(ThemeManager.BorderColor), this.Width - 18, 0, this.Width - 18, this.Height);
33-
e.Graphics.DrawLine(new Pen(ThemeManager.BorderColor), this.Width - 18, this.Height / 2, this.Width, this.Height / 2);
32+
//e.Graphics.DrawLine(new Pen(ThemeManager.BorderColor), this.Width - 18, 0, this.Width - 18, this.Height);
33+
//e.Graphics.DrawLine(new Pen(ThemeManager.BorderColor), this.Width - 18, this.Height / 2, this.Width, this.Height / 2);
3434

3535
Brush arrowsBrush = new SolidBrush(this.ForeColor);
3636
if (!this.Enabled)
@@ -40,15 +40,15 @@ protected override void OnPaint(PaintEventArgs e)
4040

4141
e.Graphics.FillPolygon(arrowsBrush, new PointF[]
4242
{
43-
new PointF(this.Width - 13, 15),
44-
new PointF(this.Width - 9, 19),
45-
new PointF(this.Width - 5, 15)
43+
new PointF(this.Width - 14, 15),
44+
new PointF(this.Width - 10, 19),
45+
new PointF(this.Width - 6, 15)
4646
});
4747
e.Graphics.FillPolygon(arrowsBrush, new PointF[]
4848
{
49-
new PointF(this.Width - 14, 8),
50-
new PointF(this.Width - 9, 3),
51-
new PointF(this.Width - 5, 8)
49+
new PointF(this.Width - 15, 10),
50+
new PointF(this.Width - 10, 5),
51+
new PointF(this.Width - 6, 10)
5252
});
5353
}
5454

0 commit comments

Comments
 (0)