Skip to content

Commit

Permalink
- added DefaultSize property;
Browse files Browse the repository at this point in the history
- implemented ProgressBar control;
- changed default shadow and header color for forms, added innerBorderPen;
- more public to internal changes (uwf...),;
- styling.
  • Loading branch information
Meragon committed Aug 4, 2017
1 parent d513cb8 commit f566440
Show file tree
Hide file tree
Showing 28 changed files with 924 additions and 679 deletions.
3 changes: 1 addition & 2 deletions System/Drawing/Font.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ public enum FontStyle
Underline = 4,
Strikeout = 8,
}

[Serializable]

public sealed class Font
{
internal UnityEngine.Font UFont;
Expand Down
6 changes: 5 additions & 1 deletion System/Windows/Forms/ButtonBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public ButtonBase()
BackColor = Color.FromArgb(234, 234, 234);
BackgroundImageLayout = ImageLayout.Center;
ForeColor = Color.FromArgb(64, 64, 64);
Size = new Size(75, 23);
}

public FlatStyle FlatStyle
Expand Down Expand Up @@ -70,6 +69,11 @@ public virtual ContentAlignment TextAlign
set { textAlign = value; }
}

protected override Size DefaultSize
{
get { return new Size(75, 23); }
}

protected override void OnKeyUp(KeyEventArgs e)
{
if (e.KeyCode == Keys.Space || e.KeyCode == Keys.Return)
Expand Down
6 changes: 5 additions & 1 deletion System/Windows/Forms/CheckBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public CheckBox()
{
BackColor = Color.White;
ForeColor = Color.Black;
Size = new Drawing.Size(128, 17);
TextAlign = ContentAlignment.MiddleLeft;

uwfBorderColor = Color.FromArgb(112, 112, 112);
Expand Down Expand Up @@ -46,6 +45,11 @@ public CheckState CheckState
}
}

protected override Size DefaultSize
{
get { return new Size(104, 24); }
}

protected virtual void OnCheckedChanged(EventArgs e)
{
CheckedChanged(this, e);
Expand Down
9 changes: 8 additions & 1 deletion System/Windows/Forms/ComboBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public ComboBox()
HoverColor = Color.White;
HoverColorDropDownList = Color.FromArgb(227, 240, 252);
Padding = new Padding(4, 0, 4, 0);
Size = new Size(121, 21);
}

public event EventHandler SelectedIndexChanged = delegate { };
Expand Down Expand Up @@ -101,6 +100,14 @@ public object SelectedItem
}
public bool WrapText { get; set; }

protected override Size DefaultSize
{
get
{
return new Size(121, 21);
}
}

internal override bool FocusInternal()
{
var res = base.FocusInternal();
Expand Down
12 changes: 10 additions & 2 deletions System/Windows/Forms/Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class Control : Component
internal DrawHandler uwfShadowHandler;
internal IControlDesigner uwfDesigner;
internal Point uwfOffset;
internal string uwfSource;

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

Expand Down Expand Up @@ -60,6 +59,10 @@ public Control()
ControlStyles.StandardClick | ControlStyles.Selectable | ControlStyles.StandardDoubleClick |
ControlStyles.AllPaintingInWmPaint | ControlStyles.UseTextForAccessibility,
true);

var defaultSize = DefaultSize;
width = defaultSize.Width;
height = defaultSize.Height;
}

public delegate void DrawHandler(PaintEventArgs e);
Expand Down Expand Up @@ -209,7 +212,12 @@ internal virtual bool uwfContext // Close on click control.
}
}
}
internal bool uwfHovered { get { return hovered; } }
internal bool uwfHovered { get { return hovered; } }

protected virtual Size DefaultSize
{
get { return Size.Empty; }
}

public void BringToFront()
{
Expand Down
55 changes: 35 additions & 20 deletions System/Windows/Forms/Form.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,23 @@
[Serializable]
public class Form : ContainerControl, IResizableControl
{
internal readonly Pen borderPen = new Pen(Color.White);
internal readonly Pen innerBorderPen = new Pen(Color.FromArgb(214, 214, 214));
internal bool dialog;
internal Color uwfHeaderColor = Color.FromArgb(251, 251, 251);
internal Font uwfHeaderFont;
internal int uwfHeaderHeight = 24;
internal Padding uwfHeaderPadding = new Padding(32, 0, 32, 0);
internal ContentAlignment uwfHeaderTextAlign;
internal Color uwfHeaderTextColor = Color.FromArgb(64, 64, 64);
internal bool uwfMovable = true;

protected Button uwfSizeGripRenderer;
protected internal Button uwfSizeGripRenderer;

private const int RESIZE_OFFSET = 8;
private static Point nextLocation = new Point(128, 64);
private readonly Pen borderPen;

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

public Form()
{
borderPen = new Pen(Color.White);

BackColor = Color.FromArgb(238, 238, 242);
ControlBox = true;
Font = SystemFonts.uwfArial_14;
FormBorderStyle = FormBorderStyle.Sizable;
Location = nextLocation;
MinimumSize = new Size(128, 48);
Size = new Size(334, 260);
Visible = false;

uwfBorderColor = Color.FromArgb(204, 206, 219);
uwfHeaderColor = Color.FromArgb(238, 238, 242);
uwfBorderColor = Color.FromArgb(192, 192, 192);
uwfHeaderFont = Font;
uwfHeaderHeight = 24;
uwfHeaderPadding = new Padding(32, 0, 32, 0);
uwfHeaderTextColor = Color.FromArgb(64, 64, 64);
uwfHeaderTextAlign = ContentAlignment.MiddleLeft;
uwfMovable = true;
uwfShadowBox = true;
uwfShadowHandler = DrawShadow;
uwfAppOwner.UpClick += _Application_UpClick;
uwfAppOwner.UpdateEvent += Owner_UpdateEvent;

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

public IButtonControl AcceptButton { get; set; }
public override Color BackColor
{
get { return backColor; }
set { backColor = value; }
}
public Button CloseButton { get { return closeButton; } }
public bool ControlBox
{
Expand Down Expand Up @@ -125,18 +131,16 @@ public bool TopMost
}
}

public Color uwfBorderColor
internal Color uwfBorderColor
{
get { return borderPen.Color; }
set { borderPen.Color = value; }
}
public Color uwfHeaderColor { get; set; }
public Font uwfHeaderFont { get; set; }
public int uwfHeaderHeight { get; set; }
public Padding uwfHeaderPadding { get; set; }
public ContentAlignment uwfHeaderTextAlign { get; set; }
public Color uwfHeaderTextColor { get; set; }
public bool uwfMovable { get; set; }

protected override Size DefaultSize
{
get { return new Size(300, 300); }
}

public void Close()
{
Expand Down Expand Up @@ -308,6 +312,7 @@ protected override void uwfOnLatePaint(PaintEventArgs e)
{
base.uwfOnLatePaint(e);

e.Graphics.DrawLine(innerBorderPen, 0, uwfHeaderHeight - 1, Width, uwfHeaderHeight - 1);
e.Graphics.DrawRectangle(borderPen, 0, 0, Width, Height);
}
protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
Expand All @@ -322,6 +327,16 @@ private void _Application_UpClick(object sender, MouseEventArgs e)
if (Application.activeResizeControl == this)
Application.activeResizeControl = null;
}
private void DrawShadow(PaintEventArgs e)
{
var loc = PointToScreen(Point.Empty);
var shadowAlpha = 12;
var shadowColor = Color.FromArgb(shadowAlpha, 64, 64, 64);

e.Graphics.uwfFillRectangle(shadowColor, loc.X - 3, loc.Y, Width + 6, Height + 3);
e.Graphics.uwfFillRectangle(shadowColor, loc.X - 2, loc.Y, Width + 4, Height + 2);
e.Graphics.uwfFillRectangle(shadowColor, loc.X - 1, loc.Y - 1, Width + 2, Height + 2);
}
private void _MakeButtonClose()
{
closeButton = new formSystemButton();
Expand Down
34 changes: 17 additions & 17 deletions System/Windows/Forms/GroupBox.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace System.Windows.Forms
namespace System.Windows.Forms
{
using System.Drawing;

public class GroupBox : Control
{
private Pen borderPen = new Pen(Color.Transparent);

public Color BorderColor
{
get { return borderPen.Color; }
set { borderPen.Color = value; }
}
private readonly Pen borderPen = new Pen(Color.LightGray);

public GroupBox()
{
BackColor = Color.FromArgb(240, 240, 240);
BorderColor = Color.LightGray;
ForeColor = Color.Gray;
Size = new Size(168, 286);
TabIndex = -1;

SetStyle(ControlStyles.Selectable, false);
}

internal Color uwfBorderColor
{
get { return borderPen.Color; }
set { borderPen.Color = value; }
}

protected override Size DefaultSize
{
get { return new Size(200, 100); }
}

protected override void uwfOnLatePaint(PaintEventArgs e)
{
base.uwfOnLatePaint(e);
Expand All @@ -35,7 +35,7 @@ protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);

Graphics g = e.Graphics;
var g = e.Graphics;

g.uwfFillRectangle(BackColor, 0, 0, Width, Height);
g.uwfDrawString(Text, Font, ForeColor, 8, 0, Width - 16, Height - 0);
Expand Down
26 changes: 13 additions & 13 deletions System/Windows/Forms/HScrollBar.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace System.Windows.Forms
namespace System.Windows.Forms
{
using System.Drawing;

public class HScrollBar : ScrollBar
{
private readonly Size ButtonSize = new Size(17, 15);
private readonly Size buttonSize = new Size(17, 15);

public HScrollBar()
{
scrollOrientation = ScrollOrientation.HorizontalScroll;
Size = new Size(80, 15);

subtractButton.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom;
subtractButton.Image = uwfAppOwner.Resources.CurvedArrowLeft;
subtractButton.Location = new Point(0, 0);
subtractButton.Size = ButtonSize;
subtractButton.Size = buttonSize;

addButton.Anchor = AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
addButton.Image = uwfAppOwner.Resources.CurvedArrowRight;
addButton.Location = new Point(Width - ButtonSize.Width, 0);
addButton.Size = ButtonSize;
addButton.Location = new Point(Width - buttonSize.Width, 0);
addButton.Size = buttonSize;

Refresh();
UpdateScrollRect();
}

protected override Size DefaultSize
{
get { return new Size(80, 15); }
}
}
}
5 changes: 5 additions & 0 deletions System/Windows/Forms/Label.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public Label()

public ContentAlignment TextAlign { get; set; }

protected override Size DefaultSize
{
get { return new Size(100, 23); } // Autosize ? Preferred height.
}

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Expand Down
6 changes: 5 additions & 1 deletion System/Windows/Forms/ListBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public ListBox()
SelectionBackColor = SystemColors.Highlight;
SelectionDisabledColor = Color.FromArgb(101, 203, 255);
SelectionForeColor = SystemColors.HighlightText;
Size = new Size(120, 95);
WrapText = true;

vScroll = new VScrollBar();
Expand Down Expand Up @@ -173,6 +172,11 @@ internal int ScrollIndex
set { vScroll.Value = value * ItemHeight; }
}

protected override Size DefaultSize
{
get { return new Size(120, 96); }
}

public void AdjustHeight()
{
integralHeightAdjust = false;
Expand Down
8 changes: 7 additions & 1 deletion System/Windows/Forms/MenuStrip.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace System.Windows.Forms
{
using System.Drawing;

[Serializable]
public class MenuStrip : ToolStrip
{
Expand All @@ -8,7 +10,11 @@ public MenuStrip()
BorderColor = Drawing.Color.Transparent;
Orientation = Orientation.Horizontal;
Padding = new Padding(2);
Size = new Drawing.Size(600, 24);
}

protected override Size DefaultSize
{
get { return new Size(200, 24); }
}
}
}
2 changes: 1 addition & 1 deletion System/Windows/Forms/MessageBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static DialogResult Show(string text, string caption, Font textFont)
GroupBox formGroup = new GroupBox();
formGroup.Anchor = AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Top;
formGroup.BackColor = Color.White;
formGroup.BorderColor = form.uwfBorderColor;
formGroup.uwfBorderColor = form.uwfBorderColor;
formGroup.Size = new Size(form.Width - 16, form.Height - (int)form.uwfHeaderHeight - 8 - 28);
formGroup.Location = new Point(8, (int)form.uwfHeaderHeight);

Expand Down
Loading

0 comments on commit f566440

Please sign in to comment.