private void btnGetAll_Click(object sender, EventArgs e) { if (Application.OpenForms[GlobalConstants.GetAllForm] != null) { _form = Application.OpenForms["getAllForm"]; _form.Focus(); } else { if (_todoService.Count() > 0) { if (Application.OpenForms[GlobalConstants.NewTodoForm] != null) { Application.OpenForms[GlobalConstants.NewTodoForm].Close(); } getAllForm form = new getAllForm { MdiParent = this, StartPosition = FormStartPosition.CenterScreen }; form.Show(); } else { MessageBox.Show(GlobalConstants.EmptyList, GlobalConstants.CaptionInfo, MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult result = MessageBox.Show(GlobalConstants.AddTodoQuestion, GlobalConstants.CaptionQuestion, MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (result == DialogResult.Yes) { if (Application.OpenForms[GlobalConstants.NewTodoForm] == null) { NewTodoForm newTodoForm = new NewTodoForm { MdiParent = this, StartPosition = FormStartPosition.CenterScreen }; newTodoForm.Show(); } else { Form form = Application.OpenForms[GlobalConstants.NewTodoForm]; form.Focus(); } } } } }
private void btnNew_Click(object sender, EventArgs e) { if (Application.OpenForms[GlobalConstants.NewTodoForm] != null) { _form = Application.OpenForms[GlobalConstants.NewTodoForm]; _form.Focus(); } else { if (Application.OpenForms[GlobalConstants.GetAllForm] != null) { Application.OpenForms[GlobalConstants.GetAllForm].Close(); } NewTodoForm form = new NewTodoForm { MdiParent = this, StartPosition = FormStartPosition.CenterScreen }; form.Show(); } }