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 { 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)); //Point newPosition = new Point(Cursor.Position.X, Cursor.Position.Y); //newPosition.X -= (this.Width / 2); //newPosition.Y -= (this.Height / 2); //this.Location = newPosition; } 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 Point DefaultLocation { get { Point newPosition = new Point(Cursor.Position.X, Cursor.Position.Y); newPosition.X -= (this.Width / 2); newPosition.Y -= (this.Height / 2); newPosition.X = Math.Max(newPosition.X, Screen.PrimaryScreen.WorkingArea.Left); newPosition.Y = Math.Max(newPosition.Y, Screen.PrimaryScreen.WorkingArea.Top); return newPosition; } } } }