2020-04-27 12:17:13 +00:00
|
|
|
|
namespace RyzStudio.Windows.ThemedForms
|
|
|
|
|
{
|
|
|
|
|
using System;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Drawing.Design;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Resources = AppLauncher.Properties.Resources;
|
|
|
|
|
|
2020-05-10 10:45:54 +00:00
|
|
|
|
public partial class TDialogForm : System.Windows.Forms.Form
|
2020-04-27 12:17:13 +00:00
|
|
|
|
{
|
|
|
|
|
protected bool isBusy = false;
|
|
|
|
|
|
|
|
|
|
protected Color topFillColour = Color.FromArgb(15, 15, 15);
|
|
|
|
|
protected int topFillHeight = 32;
|
|
|
|
|
protected int borderWidth = 1;
|
|
|
|
|
|
|
|
|
|
private bool windowDragging = false;
|
|
|
|
|
private Point windowOffset = new Point();
|
|
|
|
|
private Point windowSize = new Point();
|
|
|
|
|
|
2020-05-10 10:45:54 +00:00
|
|
|
|
public TDialogForm() : base()
|
2020-04-27 12:17:13 +00:00
|
|
|
|
{
|
|
|
|
|
this.InitializeComponent();
|
|
|
|
|
|
|
|
|
|
this.BackColor = Color.FromArgb(246, 246, 246);
|
|
|
|
|
this.Padding = new Padding(1);
|
|
|
|
|
|
|
|
|
|
this.topFillColour = Color.FromArgb(51, 51, 51);
|
|
|
|
|
this.topFillHeight = 32;
|
|
|
|
|
|
|
|
|
|
this.BackColor = Color.FromArgb(248, 249, 250);
|
|
|
|
|
this.FormBorderStyle = FormBorderStyle.None;
|
|
|
|
|
|
|
|
|
|
imgbxClose.Click += pictureBox3_Click;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnClosing(CancelEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnClosing(e);
|
|
|
|
|
|
|
|
|
|
if (this.IsBusy)
|
|
|
|
|
{
|
|
|
|
|
e.Cancel = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnPaint(PaintEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnPaint(e);
|
|
|
|
|
|
|
|
|
|
Graphics g = e.Graphics;
|
|
|
|
|
|
|
|
|
|
Rectangle areaTop = new Rectangle(this.DisplayRectangle.Left, this.Padding.Top, this.DisplayRectangle.Width, topFillHeight);
|
|
|
|
|
Rectangle areaBorder = new Rectangle(this.ClientRectangle.X, this.ClientRectangle.Y, this.ClientRectangle.Width - borderWidth, this.ClientRectangle.Height - borderWidth);
|
|
|
|
|
|
|
|
|
|
// draw header
|
|
|
|
|
if (topFillHeight > 0)
|
|
|
|
|
{
|
|
|
|
|
g.FillRectangle(new SolidBrush(topFillColour), areaTop);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g.DrawRectangle(new Pen(Color.Black, borderWidth), areaBorder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnResize(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnResize(e);
|
|
|
|
|
|
|
|
|
|
this.Invalidate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
|
|
|
|
public new Color BackColor { get => base.BackColor; set => base.BackColor = value; }
|
|
|
|
|
|
|
|
|
|
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
|
|
|
|
public new FormBorderStyle FormBorderStyle { get => base.FormBorderStyle; set => base.FormBorderStyle = value; }
|
|
|
|
|
|
|
|
|
|
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
|
|
|
|
public new Padding Padding { get => base.Padding; set => base.Padding = value; }
|
|
|
|
|
|
|
|
|
|
[Category("Appearance"), Browsable(true)]
|
|
|
|
|
public string Description
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return lblDescription.Text?.Replace("\n", "\\n");
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
lblDescription.Text = value?.Replace("\\n", "\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual bool IsBusy { get => isBusy; set => isBusy = value; }
|
|
|
|
|
|
|
|
|
|
private void pictureBox3_Click(object sender, System.EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
MouseEventArgs mouseEvent = (MouseEventArgs)e;
|
|
|
|
|
if (mouseEvent != null)
|
|
|
|
|
{
|
|
|
|
|
if (mouseEvent.Button != MouseButtons.Left)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void label1_MouseDown(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Button != MouseButtons.Left)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
windowDragging = true;
|
|
|
|
|
windowOffset = e.Location;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void label1_MouseUp(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
windowDragging = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void label1_MouseMove(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (windowDragging)
|
|
|
|
|
{
|
|
|
|
|
Point currentScreenPos = PointToScreen(e.Location);
|
|
|
|
|
Location = new Point(currentScreenPos.X - windowOffset.X, currentScreenPos.Y - windowOffset.Y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void label1_MouseClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Button == MouseButtons.Middle)
|
|
|
|
|
{
|
|
|
|
|
this.TopMost = !this.TopMost;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void panel1_MouseDown(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Button != MouseButtons.Left)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
windowDragging = true;
|
|
|
|
|
windowOffset = e.Location;
|
|
|
|
|
windowSize = new Point(this.Width, this.Height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void panel1_MouseUp(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
windowDragging = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void panel1_MouseMove(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (windowDragging)
|
|
|
|
|
{
|
|
|
|
|
this.Size = new Size(e.X - windowOffset.X + this.Width, e.Y - windowOffset.Y + this.Height);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void panel2_MouseDown(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Button != MouseButtons.Left)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
windowDragging = true;
|
|
|
|
|
windowOffset = e.Location;
|
|
|
|
|
windowSize = new Point(this.Width, this.Height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void panel2_MouseUp(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
windowDragging = false;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void panel2_MouseMove(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (windowDragging)
|
|
|
|
|
{
|
|
|
|
|
this.Size = new Size(windowSize.X, e.Y - windowOffset.Y + this.Height);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|