|
@@ -0,0 +1,95 @@
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using System.Windows.Forms;
|
|
|
+
|
|
|
+namespace ShareWifi.Views
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// Form 基类
|
|
|
+ /// </summary>
|
|
|
+ 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);
|
|
|
+
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 双击关闭窗体
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sender"></param>
|
|
|
+ /// <param name="e"></param>
|
|
|
+ private void BaseForm_DoubleClick(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ Application.Exit();
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 解决winform刚启动的时候,由于picture 太多闪屏问题
|
|
|
+ /// </summary>
|
|
|
+ protected override CreateParams CreateParams
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ CreateParams cp = base.CreateParams;
|
|
|
+ cp.ExStyle |= 0x02000000;
|
|
|
+ return cp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Form之间跳转
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="type"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|