106 lines
3.2 KiB
C#
106 lines
3.2 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Drawing;
|
|||
|
using System.Drawing.Drawing2D;
|
|||
|
using System.Drawing.Text;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using System.Windows.Forms;
|
|||
|
|
|||
|
namespace AppLauncher.Windows.Forms
|
|||
|
{
|
|||
|
public class AForm : Form
|
|||
|
{
|
|||
|
private bool windowDragging = false;
|
|||
|
private Point windowOffset = new Point();
|
|||
|
|
|||
|
public AForm() : base()
|
|||
|
{
|
|||
|
if (!this.DesignMode)
|
|||
|
{
|
|||
|
this.FormBorderStyle = FormBorderStyle.None;
|
|||
|
this.StartPosition = FormStartPosition.Manual;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
protected override void OnLoad(EventArgs e)
|
|||
|
{
|
|||
|
base.OnLoad(e);
|
|||
|
|
|||
|
if (this.DesignMode)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
int requestedHeight = (int)Math.Floor(decimal.Divide((Screen.PrimaryScreen.WorkingArea.Height - this.Height), 2));
|
|||
|
|
|||
|
this.Location = new Point(Screen.PrimaryScreen.WorkingArea.X, (Screen.PrimaryScreen.WorkingArea.Y + requestedHeight));
|
|||
|
}
|
|||
|
|
|||
|
protected override void OnPaintBackground(PaintEventArgs e)
|
|||
|
{
|
|||
|
base.OnPaintBackground(e);
|
|||
|
|
|||
|
Graphics g = e.Graphics;
|
|||
|
g.TextRenderingHint = TextRenderingHint.AntiAlias;
|
|||
|
g.InterpolationMode = InterpolationMode.HighQualityBilinear;
|
|||
|
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
|||
|
g.SmoothingMode = SmoothingMode.HighQuality;
|
|||
|
|
|||
|
//g.FillRectangle(new LinearGradientBrush(this.DisplayRectangle, Color.FromArgb(76, 83, 93), Color.FromArgb(255, 255, 255), -30F), this.DisplayRectangle);
|
|||
|
|
|||
|
//g.DrawRectangle(new Pen(new SolidBrush(Color.Red), 1), this.DisplayRectangle);
|
|||
|
}
|
|||
|
|
|||
|
//protected override void OnPaint(PaintEventArgs e)
|
|||
|
//{
|
|||
|
// base.OnPaint(e);
|
|||
|
|
|||
|
// if (this.BackgroundImage == null)
|
|||
|
// {
|
|||
|
// return;
|
|||
|
// }
|
|||
|
|
|||
|
// Graphics g = e.Graphics;
|
|||
|
|
|||
|
// g.TextRenderingHint = TextRenderingHint.AntiAlias;
|
|||
|
// g.InterpolationMode = InterpolationMode.HighQualityBilinear;
|
|||
|
// g.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
|||
|
// g.SmoothingMode = SmoothingMode.HighQuality;
|
|||
|
|
|||
|
// g.DrawImage(this.BackgroundImage, Point.Empty);
|
|||
|
//}
|
|||
|
|
|||
|
protected void windowMoveControl_MouseDown(object sender, MouseEventArgs e)
|
|||
|
{
|
|||
|
if (e.Button != MouseButtons.Left)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
windowDragging = true;
|
|||
|
windowOffset = e.Location;
|
|||
|
}
|
|||
|
|
|||
|
protected void windowMoveControl_MouseUp(object sender, MouseEventArgs e)
|
|||
|
{
|
|||
|
windowDragging = false;
|
|||
|
}
|
|||
|
|
|||
|
protected void windowMoveControl_MouseMove(object sender, MouseEventArgs e)
|
|||
|
{
|
|||
|
if (windowDragging)
|
|||
|
{
|
|||
|
Point pos = this.PointToScreen(e.Location);
|
|||
|
|
|||
|
int y = Math.Max((pos.Y - windowOffset.Y), Screen.PrimaryScreen.WorkingArea.Y);
|
|||
|
y = Math.Min(y, (Screen.PrimaryScreen.WorkingArea.Y + Screen.PrimaryScreen.WorkingArea.Height) - this.Height);
|
|||
|
|
|||
|
this.Location = new Point(Screen.PrimaryScreen.WorkingArea.X, y);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|