namespace RyzStudio.Windows.ThemedForms
{
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
///
/// Theme customised form
///
public partial class Form : System.Windows.Forms.Form
{
protected Image topImage = null;
protected Color topFillColour = Color.FromArgb(15, 15, 15);
protected int topFillHeight = 52;
protected Image bottomImage = null;
protected Color bottomFillColour = Color.FromArgb(15, 15, 15);
protected int bottomFillMargin = 19;
///
/// Initializes a new instance of the Form class
///
public Form()
{
this.InitializeComponent();
this.BackColor = Color.FromArgb(246, 246, 246);
}
///
/// Onresize event
///
/// Event argument
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
this.Invalidate();
}
///
/// OnPaint event
///
/// Event argument
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics g = e.Graphics;
Rectangle areaTop = new Rectangle(this.DisplayRectangle.Left, 0, this.DisplayRectangle.Width, topFillHeight);
Rectangle areaBottom = new Rectangle(this.DisplayRectangle.Left, (this.DisplayRectangle.Height - bottomFillMargin), this.DisplayRectangle.Width, bottomFillMargin);
// draw header
if (topFillHeight > 0)
{
g.FillRectangle(new SolidBrush(topFillColour), areaTop);
}
// draw footer
if (bottomFillMargin > 0)
{
g.FillRectangle(new SolidBrush(bottomFillColour), areaBottom);
}
// draw logo
if (topImage != null)
{
g.DrawImageUnscaled(topImage, 0, 0);
}
if (bottomImage != null)
{
g.DrawImageUnscaled(bottomImage, 0, (this.DisplayRectangle.Height - bottomImage.Height - bottomFillMargin), this.DisplayRectangle.Width, bottomImage.Height);
}
}
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public new Color BackColor { get => base.BackColor; set => base.BackColor = value; }
}
}