|
1 | 1 | using System;
|
2 | 2 | using System.Collections.Generic;
|
3 | 3 | using System.ComponentModel;
|
| 4 | +using System.Drawing; |
4 | 5 | using System.Windows.Forms;
|
5 | 6 |
|
6 | 7 | namespace QuickLibrary
|
7 | 8 | {
|
8 | 9 | public class QlibFixedForm : Form
|
9 | 10 | {
|
10 |
| - // LOCKED VARIABLES |
| 11 | + // PRIVATE FIELDS |
11 | 12 |
|
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; |
14 | 15 |
|
15 |
| - [Browsable(false), Obsolete("Don't use this! (AutoScaleMode = Dpi)", true), EditorBrowsable(EditorBrowsableState.Never)] |
16 |
| - public new enum AutoScaleMode { }; |
| 16 | + // HIDDEN PROPS |
17 | 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 { }; |
| 18 | + [Browsable(false)] |
| 19 | + public new FormBorderStyle FormBorderStyle => base.FormBorderStyle; |
22 | 20 |
|
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; |
25 | 23 |
|
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; |
28 | 26 |
|
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; |
31 | 29 |
|
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; |
34 | 32 |
|
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; |
37 | 35 |
|
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; |
40 | 38 |
|
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; |
43 | 41 |
|
44 |
| - // CUSTOM VARIABLES |
| 42 | + [Browsable(false)] |
| 43 | + public new Image BackgroundImage => base.BackgroundImage; |
45 | 44 |
|
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")] |
47 | 66 | public bool Draggable { get; set; } = false;
|
48 | 67 |
|
49 |
| - [Category("Qlib Options"), Browsable(true), Description("Title label")] |
| 68 | + [Category("Qlib props"), Browsable(true), Description("Title label")] |
50 | 69 | public Label TitleLabel { get; set; } = null;
|
51 | 70 |
|
| 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 | + |
52 | 86 | public QlibFixedForm()
|
53 | 87 | {
|
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; |
56 | 90 | base.HelpButton = false;
|
57 | 91 | 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); |
60 | 94 | base.AutoSize = false;
|
61 |
| - base.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; |
| 95 | + base.AutoSizeMode = AutoSizeMode.GrowAndShrink; |
62 | 96 | base.BackgroundImage = null;
|
63 | 97 | base.BackgroundImageLayout = ImageLayout.Tile;
|
64 | 98 | base.Font = ThemeManager.DefaultFont;
|
65 | 99 |
|
66 |
| - this.TextChanged += QlibFixedForm_TextChanged; |
| 100 | + TextChanged += QlibFixedForm_TextChanged; |
67 | 101 | }
|
68 | 102 |
|
69 | 103 | protected override void OnHandleCreated(EventArgs e)
|
@@ -112,5 +146,38 @@ private void GoDrag()
|
112 | 146 | NativeMethodsManager.ReleaseCapture();
|
113 | 147 | NativeMethodsManager.SendMessage(Handle, 0xA1, 0x2, 0);
|
114 | 148 | }
|
| 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 | + } |
115 | 182 | }
|
116 | 183 | }
|
0 commit comments