using System; using System.Drawing; using System.Windows.Forms; namespace Common { public class FormEx : Form { public FormEx() : base() { FormClosed += new FormClosedEventHandler(FormEx_FormClosed); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); Theme.UseTheme(this); DpiScaling.Apply(this); Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); new FormDimensions().Load(this, Owner); } private void FormEx_FormClosed(object sender, FormClosedEventArgs e) { new FormDimensions().Save(this); } protected override bool ProcessDialogKey(Keys keyData) { if (ModifierKeys == Keys.None && keyData == Keys.Escape) { Close(); return true; } return base.ProcessDialogKey(keyData); } } }