internal static void RegForm(MyForm form) { if (!forms.Contains(form)) { forms.Add(form); form.Load += form_Load; form.FormClosed += form_FormClosed; } }
static void form_FormClosed(object sender, System.Windows.Forms.FormClosedEventArgs e) { MyForm form = (MyForm)sender; form.Load -= form_Load; form.FormClosed -= form_FormClosed; forms.Remove(form); if (MainForm == form) { MainForm = null; } }
static void form_Load(object sender, EventArgs e) { MyForm form = (MyForm)sender; }