Added 'FlatBorder' property to DarkForm

FlatBorder can be used to set whether a single pixel border is rendered
around the form or not.
This commit is contained in:
Robin 2015-09-18 10:41:33 +01:00
parent 0d46ab2790
commit e0be7e0d0a
2 changed files with 47 additions and 1 deletions

View File

@ -1,9 +1,34 @@
using System.Windows.Forms;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace DarkUI
{
public class DarkForm : Form
{
#region Field Region
private bool _flatBorder;
#endregion
#region Property Region
[Category("Appearance")]
[Description("Determines whether a single pixel border should be rendered around the form.")]
[DefaultValue(false)]
public bool FlatBorder
{
get { return _flatBorder; }
set
{
_flatBorder = value;
Invalidate();
}
}
#endregion
#region Constructor Region
public DarkForm()
@ -12,5 +37,25 @@ namespace DarkUI
}
#endregion
#region Paint Region
protected override void OnPaintBackground(PaintEventArgs e)
{
base.OnPaintBackground(e);
if (!_flatBorder)
return;
var g = e.Graphics;
using (var p = new Pen(Colors.DarkBorder))
{
var modRect = new Rectangle(ClientRectangle.Location, new Size(ClientRectangle.Width - 1, ClientRectangle.Height - 1));
g.DrawRectangle(p, modRect);
}
}
#endregion
}
}

View File

@ -547,6 +547,7 @@
this.Controls.Add(this.toolMain);
this.Controls.Add(this.mnuMain);
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MainMenuStrip = this.mnuMain;
this.MinimumSize = new System.Drawing.Size(640, 480);
this.Name = "MainForm";