mirror of
https://github.com/colhountech/DarkUI.Net5.git
synced 2025-07-05 08:29:26 +03:00
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:
parent
0d46ab2790
commit
e0be7e0d0a
@ -1,9 +1,34 @@
|
|||||||
using System.Windows.Forms;
|
using System.ComponentModel;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace DarkUI
|
namespace DarkUI
|
||||||
{
|
{
|
||||||
public class DarkForm : Form
|
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
|
#region Constructor Region
|
||||||
|
|
||||||
public DarkForm()
|
public DarkForm()
|
||||||
@ -12,5 +37,25 @@ namespace DarkUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
Example/Forms/MainForm.Designer.cs
generated
1
Example/Forms/MainForm.Designer.cs
generated
@ -547,6 +547,7 @@
|
|||||||
this.Controls.Add(this.toolMain);
|
this.Controls.Add(this.toolMain);
|
||||||
this.Controls.Add(this.mnuMain);
|
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.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.MainMenuStrip = this.mnuMain;
|
||||||
this.MinimumSize = new System.Drawing.Size(640, 480);
|
this.MinimumSize = new System.Drawing.Size(640, 480);
|
||||||
this.Name = "MainForm";
|
this.Name = "MainForm";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user