public static ProgramAdditionForm GetInstance() { if (s_Instance == null) { s_Instance = new ProgramAdditionForm(); s_Instance.FormClosing += OnFormClosing; } return(s_Instance); }
private void btnAddProgram_Click(object sender, EventArgs e) { ProgramAdditionForm form = ProgramAdditionForm.GetInstance(); if (!form.Visible) { form.Show(); } else { form.BringToFront(); } }
public static void OnFormClosing(object sender, FormClosingEventArgs e) { // When the form is closed again we set the reference of the singleton to null s_Instance = null; }