Skip to content

Commit f566440

Browse files
committed
- added DefaultSize property;
- implemented ProgressBar control; - changed default shadow and header color for forms, added innerBorderPen; - more public to internal changes (uwf...),; - styling.
1 parent d513cb8 commit f566440

28 files changed

Lines changed: 924 additions & 679 deletions

System/Drawing/Font.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ public enum FontStyle
99
Underline = 4,
1010
Strikeout = 8,
1111
}
12-
13-
[Serializable]
12+
1413
public sealed class Font
1514
{
1615
internal UnityEngine.Font UFont;

System/Windows/Forms/ButtonBase.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public ButtonBase()
3030
BackColor = Color.FromArgb(234, 234, 234);
3131
BackgroundImageLayout = ImageLayout.Center;
3232
ForeColor = Color.FromArgb(64, 64, 64);
33-
Size = new Size(75, 23);
3433
}
3534

3635
public FlatStyle FlatStyle
@@ -70,6 +69,11 @@ public virtual ContentAlignment TextAlign
7069
set { textAlign = value; }
7170
}
7271

72+
protected override Size DefaultSize
73+
{
74+
get { return new Size(75, 23); }
75+
}
76+
7377
protected override void OnKeyUp(KeyEventArgs e)
7478
{
7579
if (e.KeyCode == Keys.Space || e.KeyCode == Keys.Return)

System/Windows/Forms/CheckBox.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ public CheckBox()
1111
{
1212
BackColor = Color.White;
1313
ForeColor = Color.Black;
14-
Size = new Drawing.Size(128, 17);
1514
TextAlign = ContentAlignment.MiddleLeft;
1615

1716
uwfBorderColor = Color.FromArgb(112, 112, 112);
@@ -46,6 +45,11 @@ public CheckState CheckState
4645
}
4746
}
4847

48+
protected override Size DefaultSize
49+
{
50+
get { return new Size(104, 24); }
51+
}
52+
4953
protected virtual void OnCheckedChanged(EventArgs e)
5054
{
5155
CheckedChanged(this, e);

System/Windows/Forms/ComboBox.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public ComboBox()
3636
HoverColor = Color.White;
3737
HoverColorDropDownList = Color.FromArgb(227, 240, 252);
3838
Padding = new Padding(4, 0, 4, 0);
39-
Size = new Size(121, 21);
4039
}
4140

4241
public event EventHandler SelectedIndexChanged = delegate { };
@@ -101,6 +100,14 @@ public object SelectedItem
101100
}
102101
public bool WrapText { get; set; }
103102

103+
protected override Size DefaultSize
104+
{
105+
get
106+
{
107+
return new Size(121, 21);
108+
}
109+
}
110+
104111
internal override bool FocusInternal()
105112
{
106113
var res = base.FocusInternal();

System/Windows/Forms/Control.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public class Control : Component
2323
internal DrawHandler uwfShadowHandler;
2424
internal IControlDesigner uwfDesigner;
2525
internal Point uwfOffset;
26-
internal string uwfSource;
2726

2827
protected static Color defaultShadowColor = Color.FromArgb(12, 0, 0, 0);
2928

@@ -60,6 +59,10 @@ public Control()
6059
ControlStyles.StandardClick | ControlStyles.Selectable | ControlStyles.StandardDoubleClick |
6160
ControlStyles.AllPaintingInWmPaint | ControlStyles.UseTextForAccessibility,
6261
true);
62+
63+
var defaultSize = DefaultSize;
64+
width = defaultSize.Width;
65+
height = defaultSize.Height;
6366
}
6467

6568
public delegate void DrawHandler(PaintEventArgs e);
@@ -209,7 +212,12 @@ internal virtual bool uwfContext // Close on click control.
209212
}
210213
}
211214
}
212-
internal bool uwfHovered { get { return hovered; } }
215+
internal bool uwfHovered { get { return hovered; } }
216+
217+
protected virtual Size DefaultSize
218+
{
219+
get { return Size.Empty; }
220+
}
213221

214222
public void BringToFront()
215223
{

System/Windows/Forms/Form.cs

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,23 @@
66
[Serializable]
77
public class Form : ContainerControl, IResizableControl
88
{
9+
internal readonly Pen borderPen = new Pen(Color.White);
10+
internal readonly Pen innerBorderPen = new Pen(Color.FromArgb(214, 214, 214));
911
internal bool dialog;
12+
internal Color uwfHeaderColor = Color.FromArgb(251, 251, 251);
13+
internal Font uwfHeaderFont;
14+
internal int uwfHeaderHeight = 24;
15+
internal Padding uwfHeaderPadding = new Padding(32, 0, 32, 0);
16+
internal ContentAlignment uwfHeaderTextAlign;
17+
internal Color uwfHeaderTextColor = Color.FromArgb(64, 64, 64);
18+
internal bool uwfMovable = true;
1019

11-
protected Button uwfSizeGripRenderer;
20+
protected internal Button uwfSizeGripRenderer;
1221

1322
private const int RESIZE_OFFSET = 8;
1423
private static Point nextLocation = new Point(128, 64);
15-
private readonly Pen borderPen;
1624

25+
private Color backColor = SystemColors.Control;
1726
private Button closeButton;
1827
private Action<Form, DialogResult> dialogCallback;
1928
private MenuStrip mainMenuStrip;
@@ -28,26 +37,18 @@ public class Form : ContainerControl, IResizableControl
2837

2938
public Form()
3039
{
31-
borderPen = new Pen(Color.White);
32-
33-
BackColor = Color.FromArgb(238, 238, 242);
3440
ControlBox = true;
3541
Font = SystemFonts.uwfArial_14;
3642
FormBorderStyle = FormBorderStyle.Sizable;
3743
Location = nextLocation;
3844
MinimumSize = new Size(128, 48);
39-
Size = new Size(334, 260);
4045
Visible = false;
4146

42-
uwfBorderColor = Color.FromArgb(204, 206, 219);
43-
uwfHeaderColor = Color.FromArgb(238, 238, 242);
47+
uwfBorderColor = Color.FromArgb(192, 192, 192);
4448
uwfHeaderFont = Font;
45-
uwfHeaderHeight = 24;
46-
uwfHeaderPadding = new Padding(32, 0, 32, 0);
47-
uwfHeaderTextColor = Color.FromArgb(64, 64, 64);
4849
uwfHeaderTextAlign = ContentAlignment.MiddleLeft;
49-
uwfMovable = true;
5050
uwfShadowBox = true;
51+
uwfShadowHandler = DrawShadow;
5152
uwfAppOwner.UpClick += _Application_UpClick;
5253
uwfAppOwner.UpdateEvent += Owner_UpdateEvent;
5354

@@ -63,6 +64,11 @@ public Form()
6364
public event EventHandler Shown = delegate { };
6465

6566
public IButtonControl AcceptButton { get; set; }
67+
public override Color BackColor
68+
{
69+
get { return backColor; }
70+
set { backColor = value; }
71+
}
6672
public Button CloseButton { get { return closeButton; } }
6773
public bool ControlBox
6874
{
@@ -125,18 +131,16 @@ public bool TopMost
125131
}
126132
}
127133

128-
public Color uwfBorderColor
134+
internal Color uwfBorderColor
129135
{
130136
get { return borderPen.Color; }
131137
set { borderPen.Color = value; }
132138
}
133-
public Color uwfHeaderColor { get; set; }
134-
public Font uwfHeaderFont { get; set; }
135-
public int uwfHeaderHeight { get; set; }
136-
public Padding uwfHeaderPadding { get; set; }
137-
public ContentAlignment uwfHeaderTextAlign { get; set; }
138-
public Color uwfHeaderTextColor { get; set; }
139-
public bool uwfMovable { get; set; }
139+
140+
protected override Size DefaultSize
141+
{
142+
get { return new Size(300, 300); }
143+
}
140144

141145
public void Close()
142146
{
@@ -308,6 +312,7 @@ protected override void uwfOnLatePaint(PaintEventArgs e)
308312
{
309313
base.uwfOnLatePaint(e);
310314

315+
e.Graphics.DrawLine(innerBorderPen, 0, uwfHeaderHeight - 1, Width, uwfHeaderHeight - 1);
311316
e.Graphics.DrawRectangle(borderPen, 0, 0, Width, Height);
312317
}
313318
protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
@@ -322,6 +327,16 @@ private void _Application_UpClick(object sender, MouseEventArgs e)
322327
if (Application.activeResizeControl == this)
323328
Application.activeResizeControl = null;
324329
}
330+
private void DrawShadow(PaintEventArgs e)
331+
{
332+
var loc = PointToScreen(Point.Empty);
333+
var shadowAlpha = 12;
334+
var shadowColor = Color.FromArgb(shadowAlpha, 64, 64, 64);
335+
336+
e.Graphics.uwfFillRectangle(shadowColor, loc.X - 3, loc.Y, Width + 6, Height + 3);
337+
e.Graphics.uwfFillRectangle(shadowColor, loc.X - 2, loc.Y, Width + 4, Height + 2);
338+
e.Graphics.uwfFillRectangle(shadowColor, loc.X - 1, loc.Y - 1, Width + 2, Height + 2);
339+
}
325340
private void _MakeButtonClose()
326341
{
327342
closeButton = new formSystemButton();

System/Windows/Forms/GroupBox.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Drawing;
6-
7-
namespace System.Windows.Forms
1+
namespace System.Windows.Forms
82
{
3+
using System.Drawing;
4+
95
public class GroupBox : Control
106
{
11-
private Pen borderPen = new Pen(Color.Transparent);
12-
13-
public Color BorderColor
14-
{
15-
get { return borderPen.Color; }
16-
set { borderPen.Color = value; }
17-
}
7+
private readonly Pen borderPen = new Pen(Color.LightGray);
188

199
public GroupBox()
2010
{
2111
BackColor = Color.FromArgb(240, 240, 240);
22-
BorderColor = Color.LightGray;
2312
ForeColor = Color.Gray;
24-
Size = new Size(168, 286);
2513
TabIndex = -1;
2614

2715
SetStyle(ControlStyles.Selectable, false);
2816
}
17+
18+
internal Color uwfBorderColor
19+
{
20+
get { return borderPen.Color; }
21+
set { borderPen.Color = value; }
22+
}
23+
24+
protected override Size DefaultSize
25+
{
26+
get { return new Size(200, 100); }
27+
}
28+
2929
protected override void uwfOnLatePaint(PaintEventArgs e)
3030
{
3131
base.uwfOnLatePaint(e);
@@ -35,7 +35,7 @@ protected override void OnPaint(PaintEventArgs e)
3535
{
3636
base.OnPaint(e);
3737

38-
Graphics g = e.Graphics;
38+
var g = e.Graphics;
3939

4040
g.uwfFillRectangle(BackColor, 0, 0, Width, Height);
4141
g.uwfDrawString(Text, Font, ForeColor, 8, 0, Width - 16, Height - 0);

System/Windows/Forms/HScrollBar.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Drawing;
6-
7-
namespace System.Windows.Forms
1+
namespace System.Windows.Forms
82
{
3+
using System.Drawing;
4+
95
public class HScrollBar : ScrollBar
106
{
11-
private readonly Size ButtonSize = new Size(17, 15);
7+
private readonly Size buttonSize = new Size(17, 15);
128

139
public HScrollBar()
1410
{
1511
scrollOrientation = ScrollOrientation.HorizontalScroll;
16-
Size = new Size(80, 15);
1712

1813
subtractButton.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom;
1914
subtractButton.Image = uwfAppOwner.Resources.CurvedArrowLeft;
2015
subtractButton.Location = new Point(0, 0);
21-
subtractButton.Size = ButtonSize;
16+
subtractButton.Size = buttonSize;
2217

2318
addButton.Anchor = AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
2419
addButton.Image = uwfAppOwner.Resources.CurvedArrowRight;
25-
addButton.Location = new Point(Width - ButtonSize.Width, 0);
26-
addButton.Size = ButtonSize;
20+
addButton.Location = new Point(Width - buttonSize.Width, 0);
21+
addButton.Size = buttonSize;
2722

28-
Refresh();
23+
UpdateScrollRect();
24+
}
25+
26+
protected override Size DefaultSize
27+
{
28+
get { return new Size(80, 15); }
2929
}
3030
}
3131
}

System/Windows/Forms/Label.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ public Label()
1919

2020
public ContentAlignment TextAlign { get; set; }
2121

22+
protected override Size DefaultSize
23+
{
24+
get { return new Size(100, 23); } // Autosize ? Preferred height.
25+
}
26+
2227
protected override void OnPaint(PaintEventArgs e)
2328
{
2429
base.OnPaint(e);

System/Windows/Forms/ListBox.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ public ListBox()
4242
SelectionBackColor = SystemColors.Highlight;
4343
SelectionDisabledColor = Color.FromArgb(101, 203, 255);
4444
SelectionForeColor = SystemColors.HighlightText;
45-
Size = new Size(120, 95);
4645
WrapText = true;
4746

4847
vScroll = new VScrollBar();
@@ -173,6 +172,11 @@ internal int ScrollIndex
173172
set { vScroll.Value = value * ItemHeight; }
174173
}
175174

175+
protected override Size DefaultSize
176+
{
177+
get { return new Size(120, 96); }
178+
}
179+
176180
public void AdjustHeight()
177181
{
178182
integralHeightAdjust = false;

0 commit comments

Comments
 (0)