2020-11-08 23:24:40 +00:00
|
|
|
|
using RyzStudio.Windows.Forms;
|
|
|
|
|
using System;
|
2020-05-16 12:25:59 +00:00
|
|
|
|
using System.ComponentModel;
|
2020-03-28 02:54:08 +00:00
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Windows.Forms;
|
2020-11-08 23:24:40 +00:00
|
|
|
|
using Resources = AppLauncher.Properties.Resources20;
|
2020-03-28 02:54:08 +00:00
|
|
|
|
|
|
|
|
|
namespace AppLauncher.Windows.Forms
|
|
|
|
|
{
|
2020-10-21 01:17:24 +00:00
|
|
|
|
public class TForm : Form
|
2020-03-28 02:54:08 +00:00
|
|
|
|
{
|
2020-11-08 23:24:40 +00:00
|
|
|
|
protected readonly Color borderColour = Color.FromArgb(235, 234, 233);
|
2020-05-17 02:24:46 +00:00
|
|
|
|
protected readonly int borderWidth = 1;
|
2020-10-20 21:42:40 +00:00
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
protected readonly int resizeBorderWidth = 3;
|
2020-10-20 21:42:40 +00:00
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
protected readonly Color backColour = Color.FromArgb(255, 255, 255);
|
2020-05-16 12:25:59 +00:00
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
protected readonly Color titleBackColour = Color.FromArgb(235, 234, 233);
|
|
|
|
|
protected readonly Color titleBorderColour = Color.FromArgb(200, 198, 196);
|
|
|
|
|
protected readonly Color titleColour = Color.FromArgb(102, 102, 102);
|
|
|
|
|
protected readonly int titleBarHeight = 54;
|
|
|
|
|
protected Font titleFont = null;
|
|
|
|
|
protected int titleFontTop = 0;
|
|
|
|
|
|
|
|
|
|
protected readonly int titleBarIconSize = 20;
|
|
|
|
|
protected readonly int titleBarIconMargin = 8;
|
|
|
|
|
|
|
|
|
|
protected bool isDragging = false;
|
|
|
|
|
protected Point startPosition = new Point();
|
|
|
|
|
protected Point startWindowSize = new Point();
|
2020-05-17 15:48:04 +00:00
|
|
|
|
|
|
|
|
|
protected bool isBusy = false;
|
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
protected Image appIcon = null;
|
|
|
|
|
protected int appIconTop = 0;
|
|
|
|
|
|
|
|
|
|
protected bool isMinimiseEnabled = true;
|
|
|
|
|
protected bool isMaximiseEnabled = true;
|
|
|
|
|
protected bool closeOnMinimise = false;
|
|
|
|
|
protected bool enableMinimiseMenu = true;
|
|
|
|
|
protected bool enableMaximiseMenu = true;
|
|
|
|
|
protected bool enableCloseMenu = true;
|
|
|
|
|
|
|
|
|
|
protected MouseEventHandler minimiseMenuEvent = null;
|
|
|
|
|
protected MouseEventHandler maximiseMenuEvent = null;
|
|
|
|
|
protected MouseEventHandler closeMenuEvent = null;
|
|
|
|
|
|
2020-05-17 11:28:21 +00:00
|
|
|
|
private IContainer components;
|
2020-05-15 00:19:09 +00:00
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
|
2020-10-21 01:17:24 +00:00
|
|
|
|
public TForm() : base()
|
2020-03-28 02:54:08 +00:00
|
|
|
|
{
|
2020-05-17 03:31:25 +00:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
2020-03-28 02:54:08 +00:00
|
|
|
|
if (!this.DesignMode)
|
|
|
|
|
{
|
|
|
|
|
this.FormBorderStyle = FormBorderStyle.None;
|
|
|
|
|
this.StartPosition = FormStartPosition.Manual;
|
|
|
|
|
}
|
2020-05-18 23:17:22 +00:00
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
this.AutoScaleMode = AutoScaleMode.None;
|
2020-10-20 21:42:40 +00:00
|
|
|
|
this.BackColor = backColour;
|
|
|
|
|
this.Padding = new Padding(0);
|
2020-11-08 23:24:40 +00:00
|
|
|
|
this.DoubleBuffered = true;
|
2020-10-20 21:42:40 +00:00
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
this.MouseDown += new MouseEventHandler(form_MouseDown);
|
|
|
|
|
this.MouseMove += new MouseEventHandler(form_MouseMove);
|
|
|
|
|
this.MouseUp += new MouseEventHandler(form_MouseUp);
|
|
|
|
|
this.PreviewKeyDown += new PreviewKeyDownEventHandler(form_PreviewKeyDown);
|
2020-03-28 02:54:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-17 03:31:25 +00:00
|
|
|
|
protected override void OnLoad(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnLoad(e);
|
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
this.Text = Application.ProductName;
|
2020-05-17 18:52:37 +00:00
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
initialiseLoadComponent();
|
2020-05-17 18:52:37 +00:00
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
if (appIcon != null) appIconTop = (int)Math.Floor((decimal)(titleBarHeight - appIcon.Height) / 2) + borderWidth;
|
|
|
|
|
titleFont = new Font(this.Font.FontFamily, 10F);
|
|
|
|
|
titleFontTop = (int)Math.Floor((decimal)(titleBarHeight - TextRenderer.MeasureText("#", titleFont).Height) / 2) + borderWidth;
|
2020-05-17 18:52:37 +00:00
|
|
|
|
|
2020-05-17 03:31:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-16 12:25:59 +00:00
|
|
|
|
protected override void OnMouseClick(MouseEventArgs e)
|
2020-05-10 10:03:55 +00:00
|
|
|
|
{
|
2020-05-16 12:25:59 +00:00
|
|
|
|
base.OnMouseClick(e);
|
2020-03-28 02:54:08 +00:00
|
|
|
|
|
2020-05-17 02:24:46 +00:00
|
|
|
|
bool isLabel = ((e.Location.X >= 0) && (e.Location.X <= this.Width) && (e.Location.Y >= 0) && (e.Location.Y <= titleBarHeight));
|
2020-03-28 02:54:08 +00:00
|
|
|
|
|
2020-05-16 12:25:59 +00:00
|
|
|
|
if (e.Button == MouseButtons.Left)
|
|
|
|
|
{
|
|
|
|
|
if (isLabel)
|
|
|
|
|
{
|
|
|
|
|
// do nothing
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// do nothing
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (e.Button == MouseButtons.Right)
|
|
|
|
|
{
|
|
|
|
|
if (isLabel)
|
|
|
|
|
{
|
|
|
|
|
if (this.TitleContextMenuStrip != null)
|
|
|
|
|
{
|
|
|
|
|
this.TitleContextMenuStrip.Show(this, e.Location);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// do nothing
|
|
|
|
|
}
|
2020-05-10 10:03:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-03-28 02:54:08 +00:00
|
|
|
|
|
2020-05-17 02:24:46 +00:00
|
|
|
|
protected override void OnPaint(PaintEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnPaint(e);
|
|
|
|
|
|
|
|
|
|
Graphics g = e.Graphics;
|
|
|
|
|
Rectangle area = new Rectangle(this.DisplayRectangle.X, this.DisplayRectangle.Y, (this.DisplayRectangle.Width - borderWidth), (this.DisplayRectangle.Height - borderWidth));
|
|
|
|
|
|
|
|
|
|
// border
|
|
|
|
|
g.DrawRectangle(new Pen(borderColour, borderWidth), area);
|
|
|
|
|
|
|
|
|
|
area.Inflate((-1 * borderWidth), (-1 * borderWidth));
|
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
g.FillRectangle(new SolidBrush(titleBackColour), area.X, area.Y, (area.Width + area.X), titleBarHeight);
|
2020-10-21 00:54:00 +00:00
|
|
|
|
g.DrawLine(new Pen(titleBorderColour, 1), area.X, (titleBarHeight + 1), (area.Width + area.X), (titleBarHeight + 1));
|
2020-05-17 02:24:46 +00:00
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
if (!DesignMode)
|
|
|
|
|
{
|
2020-11-09 18:00:07 +00:00
|
|
|
|
//g.DrawImageUnscaled(appIcon, 17, appIconTop);
|
|
|
|
|
g.DrawImage(appIcon, 17, appIconTop, appIcon.Width, appIcon.Height);
|
2020-05-17 02:24:46 +00:00
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
TextRenderer.DrawText(g, this.Text, titleFont, new Point(58, titleFontTop), titleColour);
|
|
|
|
|
}
|
2020-05-17 02:24:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnResize(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnResize(e);
|
|
|
|
|
|
|
|
|
|
this.Invalidate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
2020-10-20 21:42:40 +00:00
|
|
|
|
public override Color BackColor { get => base.BackColor; set => base.BackColor = value; }
|
2020-05-17 02:24:46 +00:00
|
|
|
|
|
|
|
|
|
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
|
|
|
|
public new FormBorderStyle FormBorderStyle { get => base.FormBorderStyle; set => base.FormBorderStyle = value; }
|
|
|
|
|
|
|
|
|
|
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
2020-10-20 21:42:40 +00:00
|
|
|
|
public new Padding Padding { get => base.Padding; set => base.Padding = value; }
|
2020-05-17 02:24:46 +00:00
|
|
|
|
|
|
|
|
|
[Category("Appearance")]
|
|
|
|
|
public ContextMenuStrip TitleContextMenuStrip { get; set; } = null;
|
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
//[Browsable(false)]
|
|
|
|
|
//public Image AppIcon { get; set; } = null;
|
2020-10-21 01:17:24 +00:00
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
//[Browsable(false)]
|
|
|
|
|
//public bool IsMaximiseEnabled { get; set; } = false;
|
2020-05-16 12:25:59 +00:00
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
//protected Point DefaultLocation
|
|
|
|
|
//{
|
|
|
|
|
// get
|
|
|
|
|
// {
|
|
|
|
|
// Point newPosition = new Point(Cursor.Position.X, Cursor.Position.Y);
|
|
|
|
|
// newPosition.X -= (this.Width / 2);
|
|
|
|
|
// newPosition.Y -= (this.Height / 2);
|
2020-05-16 12:25:59 +00:00
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
// newPosition.X = Math.Max(newPosition.X, Screen.PrimaryScreen.WorkingArea.Left);
|
|
|
|
|
// newPosition.Y = Math.Max(newPosition.Y, Screen.PrimaryScreen.WorkingArea.Top);
|
|
|
|
|
|
|
|
|
|
// return newPosition;
|
|
|
|
|
// }
|
|
|
|
|
//}
|
2020-05-16 12:25:59 +00:00
|
|
|
|
|
2020-05-17 03:31:25 +00:00
|
|
|
|
private void InitializeComponent()
|
|
|
|
|
{
|
2020-05-17 11:28:21 +00:00
|
|
|
|
this.components = new System.ComponentModel.Container();
|
2020-10-21 01:17:24 +00:00
|
|
|
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TForm));
|
2020-05-17 03:31:25 +00:00
|
|
|
|
this.SuspendLayout();
|
2020-05-18 23:17:22 +00:00
|
|
|
|
//
|
2020-05-17 03:31:25 +00:00
|
|
|
|
// AForm
|
2020-05-18 23:17:22 +00:00
|
|
|
|
//
|
2020-05-17 03:31:25 +00:00
|
|
|
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
2020-11-08 23:24:40 +00:00
|
|
|
|
this.Name = "Form";
|
2020-05-17 03:31:25 +00:00
|
|
|
|
this.ResumeLayout(false);
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
private void form_MouseDown(object sender, MouseEventArgs e)
|
2020-05-17 11:28:21 +00:00
|
|
|
|
{
|
|
|
|
|
if (e.Button == MouseButtons.Left)
|
|
|
|
|
{
|
2020-11-08 23:24:40 +00:00
|
|
|
|
isDragging = true;
|
|
|
|
|
startPosition = e.Location;
|
|
|
|
|
startWindowSize = new Point(this.Width, this.Height);
|
2020-05-17 11:28:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
private void form_MouseMove(object sender, MouseEventArgs e)
|
2020-05-17 11:28:21 +00:00
|
|
|
|
{
|
2020-11-08 23:24:40 +00:00
|
|
|
|
if (isDragging)
|
2020-05-17 11:28:21 +00:00
|
|
|
|
{
|
2020-11-08 23:24:40 +00:00
|
|
|
|
int x = (this.Location.X + (e.Location.X - startPosition.X));
|
|
|
|
|
int y = (this.Location.Y + (e.Location.Y - startPosition.Y));
|
2020-05-17 11:28:21 +00:00
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
//this.Location = validateFormLocation(x, y);
|
|
|
|
|
this.Location = new Point(x, y);
|
2020-05-17 11:28:21 +00:00
|
|
|
|
}
|
2020-11-08 23:24:40 +00:00
|
|
|
|
}
|
2020-10-20 21:42:40 +00:00
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
private void form_MouseUp(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
isDragging = false;
|
2020-05-17 11:28:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
private void form_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
|
2020-05-17 03:31:25 +00:00
|
|
|
|
{
|
2020-11-08 23:24:40 +00:00
|
|
|
|
if (e.KeyCode == Keys.Escape)
|
2020-05-17 03:31:25 +00:00
|
|
|
|
{
|
2020-11-08 23:24:40 +00:00
|
|
|
|
Application.Exit();
|
2020-05-17 03:31:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
protected virtual void initialiseLoadComponent()
|
2020-05-17 18:52:37 +00:00
|
|
|
|
{
|
2020-11-08 23:24:40 +00:00
|
|
|
|
if (DesignMode) return;
|
|
|
|
|
|
|
|
|
|
// close
|
|
|
|
|
TImageBox closeBox = generateToolbarImageBox();
|
|
|
|
|
if (enableCloseMenu)
|
2020-05-17 18:52:37 +00:00
|
|
|
|
{
|
2020-11-08 23:24:40 +00:00
|
|
|
|
closeBox.Image = closeBox.ImageNormal = Resources.close;
|
|
|
|
|
closeBox.ImageHover = Resources.close3;
|
|
|
|
|
//closeBox.ImageSelected = null;
|
|
|
|
|
closeBox.MouseClick += delegate (object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Button != MouseButtons.Left) return;
|
|
|
|
|
|
|
|
|
|
if (closeMenuEvent != null)
|
|
|
|
|
{
|
|
|
|
|
closeMenuEvent(sender, e);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.Close();
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
closeBox.Image = closeBox.ImageNormal = closeBox.ImageHover = closeBox.ImageSelected = Resources.close;
|
2020-05-17 18:52:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
closeBox.Left = this.DisplayRectangle.Width - closeBox.Width - 17;
|
2020-05-17 18:52:37 +00:00
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
this.Controls.Add(closeBox);
|
|
|
|
|
|
|
|
|
|
// maximise
|
|
|
|
|
TImageBox maximiseBox = generateToolbarImageBox();
|
|
|
|
|
if (enableMaximiseMenu)
|
2020-05-17 18:52:37 +00:00
|
|
|
|
{
|
2020-11-08 23:24:40 +00:00
|
|
|
|
maximiseBox.Image = maximiseBox.ImageNormal = (isMaximiseEnabled) ? Resources.maximise : Resources.empty;
|
|
|
|
|
maximiseBox.ImageHover = (isMaximiseEnabled) ? Resources.maximise2 : Resources.empty;
|
|
|
|
|
maximiseBox.ImageSelected = Resources.maximise3;
|
|
|
|
|
maximiseBox.MouseClick += delegate (object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!(sender is TImageBox)) return;
|
|
|
|
|
|
|
|
|
|
TImageBox imageBox2 = (sender as TImageBox);
|
|
|
|
|
|
|
|
|
|
if (imageBox2 == null) return;
|
|
|
|
|
|
|
|
|
|
if (maximiseMenuEvent != null)
|
|
|
|
|
{
|
|
|
|
|
maximiseMenuEvent(sender, e);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (e.Button == MouseButtons.Left)
|
|
|
|
|
{
|
|
|
|
|
if (isMaximiseEnabled)
|
|
|
|
|
{
|
|
|
|
|
if (this.WindowState == FormWindowState.Maximized)
|
|
|
|
|
{
|
|
|
|
|
this.WindowState = FormWindowState.Normal;
|
|
|
|
|
imageBox2.Image = imageBox2.ImageNormal = Resources.maximise;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.WindowState = FormWindowState.Maximized;
|
|
|
|
|
imageBox2.Image = imageBox2.ImageNormal = Resources.maximise2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (e.Button == MouseButtons.Right)
|
|
|
|
|
{
|
|
|
|
|
this.TopMost = !this.TopMost;
|
|
|
|
|
|
|
|
|
|
if (this.TopMost)
|
|
|
|
|
{
|
|
|
|
|
imageBox2.Image = imageBox2.ImageNormal = Resources.maximise3;
|
|
|
|
|
imageBox2.ImageHover = (isMaximiseEnabled) ? Resources.maximise2 : Resources.maximise3;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
imageBox2.Image = imageBox2.ImageNormal = (isMaximiseEnabled) ? Resources.maximise : Resources.empty;
|
|
|
|
|
imageBox2.ImageHover = (isMaximiseEnabled) ? Resources.maximise2 : Resources.empty;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
maximiseBox.Image = maximiseBox.ImageNormal = maximiseBox.ImageHover = maximiseBox.ImageSelected = Resources.maximise;
|
2020-05-17 18:52:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
maximiseBox.Left = closeBox.Left - maximiseBox.Width - titleBarIconMargin;
|
2020-05-18 19:45:25 +00:00
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
this.Controls.Add(maximiseBox);
|
|
|
|
|
|
|
|
|
|
// minimise
|
|
|
|
|
TImageBox minimiseBox = generateToolbarImageBox();
|
|
|
|
|
if (enableMinimiseMenu)
|
2020-05-19 23:49:47 +00:00
|
|
|
|
{
|
2020-11-08 23:24:40 +00:00
|
|
|
|
minimiseBox.Image = minimiseBox.ImageNormal = (isMinimiseEnabled) ? Resources.minimise : Resources.empty;
|
|
|
|
|
minimiseBox.ImageHover = (isMinimiseEnabled) ? Resources.minimise2 : Resources.empty;
|
|
|
|
|
//minimiseBox.ImageSelected = null;
|
|
|
|
|
minimiseBox.MouseClick += delegate (object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!isMinimiseEnabled) return;
|
|
|
|
|
if (e.Button != MouseButtons.Left) return;
|
|
|
|
|
|
|
|
|
|
if (minimiseMenuEvent != null)
|
|
|
|
|
{
|
|
|
|
|
minimiseMenuEvent(sender, e);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (closeOnMinimise)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
this.WindowState = FormWindowState.Minimized;
|
|
|
|
|
}
|
|
|
|
|
};
|
2020-05-19 23:49:47 +00:00
|
|
|
|
}
|
2020-11-08 23:24:40 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
minimiseBox.Image = minimiseBox.ImageNormal = minimiseBox.ImageHover = minimiseBox.ImageSelected = Resources.minimise;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
minimiseBox.Left = maximiseBox.Left - minimiseBox.Width - titleBarIconMargin;
|
|
|
|
|
|
|
|
|
|
this.Controls.Add(minimiseBox);
|
|
|
|
|
|
|
|
|
|
// resize
|
|
|
|
|
UserControl uc1 = new UserControl()
|
|
|
|
|
{
|
|
|
|
|
Anchor = (AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right),
|
|
|
|
|
Height = resizeBorderWidth,
|
|
|
|
|
Width = this.DisplayRectangle.Width - resizeBorderWidth,
|
|
|
|
|
Left = 0,
|
|
|
|
|
Top = this.DisplayRectangle.Height - resizeBorderWidth,
|
|
|
|
|
BackColor = Color.Transparent,
|
|
|
|
|
Cursor = Cursors.SizeNS
|
|
|
|
|
};
|
|
|
|
|
uc1.MouseDown += form_MouseDown;
|
|
|
|
|
uc1.MouseUp += form_MouseUp;
|
|
|
|
|
uc1.MouseMove += delegate (object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (isDragging)
|
|
|
|
|
{
|
|
|
|
|
this.Size = new Size(startWindowSize.X, e.Y - startPosition.Y + this.Height);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
uc1.BringToFront();
|
|
|
|
|
|
|
|
|
|
this.Controls.Add(uc1);
|
2020-05-19 23:49:47 +00:00
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
UserControl uc2 = new UserControl()
|
|
|
|
|
{
|
|
|
|
|
Anchor = (AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom),
|
|
|
|
|
Height = this.DisplayRectangle.Height - resizeBorderWidth,
|
|
|
|
|
Width = resizeBorderWidth,
|
|
|
|
|
Left = this.DisplayRectangle.Width - resizeBorderWidth,
|
|
|
|
|
Top = 0,
|
|
|
|
|
BackColor = Color.Transparent,
|
|
|
|
|
Cursor = Cursors.SizeWE
|
|
|
|
|
};
|
|
|
|
|
uc2.MouseDown += form_MouseDown;
|
|
|
|
|
uc2.MouseUp += form_MouseUp;
|
|
|
|
|
uc2.MouseMove += delegate (object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (isDragging)
|
|
|
|
|
{
|
|
|
|
|
this.Size = new Size(e.X - startPosition.X + this.Width, startWindowSize.Y);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
uc2.BringToFront();
|
|
|
|
|
|
|
|
|
|
this.Controls.Add(uc2);
|
|
|
|
|
|
|
|
|
|
UserControl uc3 = new UserControl()
|
|
|
|
|
{
|
|
|
|
|
Anchor = (AnchorStyles.Bottom | AnchorStyles.Right),
|
|
|
|
|
Height = resizeBorderWidth,
|
|
|
|
|
Width = resizeBorderWidth,
|
|
|
|
|
Left = this.DisplayRectangle.Width - resizeBorderWidth,
|
|
|
|
|
Top = this.DisplayRectangle.Height - resizeBorderWidth,
|
|
|
|
|
BackColor = Color.Transparent,
|
|
|
|
|
Cursor = Cursors.SizeNWSE
|
|
|
|
|
};
|
|
|
|
|
uc3.MouseDown += form_MouseDown;
|
|
|
|
|
uc3.MouseUp += form_MouseUp;
|
|
|
|
|
uc3.MouseMove += delegate (object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (isDragging)
|
|
|
|
|
{
|
|
|
|
|
this.Size = new Size((e.X - startPosition.X + this.Width), (e.Y - startPosition.Y + this.Height));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
uc3.BringToFront();
|
|
|
|
|
|
|
|
|
|
this.Controls.Add(uc3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected TImageBox generateToolbarImageBox()
|
|
|
|
|
{
|
|
|
|
|
TImageBox imageBox = new TImageBox();
|
|
|
|
|
imageBox.BackColor = Color.Transparent;
|
|
|
|
|
imageBox.BackgroundImageLayout = ImageLayout.Center;
|
|
|
|
|
imageBox.ErrorImage = null;
|
|
|
|
|
//imageBox.Image = Resources.close;
|
|
|
|
|
//imageBox.ImageHover = Resources.close2;
|
|
|
|
|
//imageBox.ImageNormal = Resources.close;
|
|
|
|
|
imageBox.ImageSelected = null;
|
|
|
|
|
imageBox.IsSelected = false;
|
|
|
|
|
//closeBox.Location = new System.Drawing.Point(169, 12);
|
|
|
|
|
imageBox.Size = new System.Drawing.Size(titleBarIconSize, titleBarIconSize);
|
|
|
|
|
imageBox.SizeMode = PictureBoxSizeMode.CenterImage;
|
|
|
|
|
//imageBox.MouseClick += new MouseEventHandler(closeBox_MouseClick);
|
|
|
|
|
//imageBox.Left = this.DisplayRectangle.Width - imageBox.Width - 17;
|
|
|
|
|
imageBox.Top = (int)Math.Floor((decimal)(titleBarHeight - titleBarIconSize) / 2);
|
|
|
|
|
imageBox.Anchor = (AnchorStyles.Top | AnchorStyles.Right);
|
|
|
|
|
|
|
|
|
|
return imageBox;
|
2020-05-19 23:49:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-08 23:24:40 +00:00
|
|
|
|
//private void exitToolStripMenuItem_Click(object sender, EventArgs e) => this.Close();
|
|
|
|
|
|
|
|
|
|
//private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
|
|
|
|
|
//{
|
|
|
|
|
// if (e.Button == MouseButtons.Left)
|
|
|
|
|
// {
|
|
|
|
|
// this.Visible = !this.Visible;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// //notifyIcon1.Visible = !this.Visible;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
2020-03-28 02:54:08 +00:00
|
|
|
|
}
|
2020-05-10 10:03:55 +00:00
|
|
|
|
}
|