using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace DayOf1440.UI { /// /// Form 基类 /// public partial class BaseForm : Form { public BaseForm() { this.Load += new EventHandler(BaseForm_Load); this.FormClosed += new FormClosedEventHandler(BaseForm_FormClosed); InitializeComponent(); } public void BaseForm_Load(object sender, EventArgs e) { Program.formList.Add(this); } public void BaseForm_FormClosed(object sender, FormClosedEventArgs e) { Program.formList.Remove(this); } private void InitializeComponent() { this.SuspendLayout(); // // BaseForm // this.ClientSize = new System.Drawing.Size(1350, 729); this.Name = "BaseForm"; this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.DoubleClick += new System.EventHandler(this.BaseForm_DoubleClick); this.ResumeLayout(false); } /// /// 双击关闭窗体 /// /// /// private void BaseForm_DoubleClick(object sender, EventArgs e) { Application.Exit(); } /// /// 解决winform刚启动的时候,由于picture 太多闪屏问题 /// protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp.ExStyle |= 0x02000000; return cp; } } /// /// Form之间跳转 /// /// /// internal static Form Go(Type type) { Form currentForm = null; foreach (Form formItem in Program.formList) { if (formItem.GetType() == type) { currentForm = formItem; currentForm.Activate(); break; } } if (currentForm == null) { object obj = Activator.CreateInstance(type); if (obj is Form) { currentForm = obj as Form; currentForm.Show(); } } return currentForm; } } }