// ----------------------------------------------------------------------------------------------- // Методы установки нижнего меню статуса // ----------------------------------------------------------------------------------------------- void SetStatus(ModeOpen modeOpenRW) { switch (modeOpenRW) { case ModeOpen.none: actionToolStripMenuItem.Enabled = false; modeOpen = ModeOpen.none; statusModeOpenLabelMenu.Text = "-"; break; case ModeOpen.read: insertActionToolStripMenuItem.Enabled = false; deleteActionToolStripMenuItem.Enabled = false; modeOpen = ModeOpen.read; statusModeOpenLabelMenu.Text = "Режим чтения"; break; case ModeOpen.write: insertActionToolStripMenuItem.Enabled = true; deleteActionToolStripMenuItem.Enabled = true; modeOpen = ModeOpen.write; statusModeOpenLabelMenu.Text = "Режим записи"; break; } }
private void FileDialogOperation(object sender, EventArgs e, ModeOpen modeOpen) { FileDialog dialog; if (StudentRepository != null && !StudentRepository.StateIsSaved && modeOpen != ModeOpen.Save) { ConfirmAction(sender, e); } if (modeOpen == ModeOpen.Open) { dialog = new OpenFileDialog() { Filter = StudentRepository.AvailableDbFileExtensionsFilter }; } else { dialog = new SaveFileDialog() { Filter = StudentRepository.AvailableDbFileExtensionsFilter }; } if (dialog.ShowDialog() == DialogResult.OK) { CurrentOpenedFile = dialog.FileName; StudentRepository = StudentRepository.BindToFile(dialog.FileName); if (modeOpen == ModeOpen.Create) { BindingSource.DataSource = StudentRepository.GetEmptyStudentsLIst(); StudentsDataGreedView.DataSource = BindingSource; } else if (modeOpen == ModeOpen.Save) { StudentRepository.SaveStudents((List <Student>)BindingSource.DataSource); } else { try { BindingSource.DataSource = StudentRepository.LoadStudents(); StudentsDataGreedView.DataSource = BindingSource; } catch (InvalidOperationException exception) { StudentService.SaveParseErrors(exception, out LogFilePath); InvalidFileDialog(); } } } ; RefreshLabels(); }
public static void OpenForm(XtraForm xtraForm, ModeOpen modo) { if (Application.OpenForms[xtraForm.Name] != null) { Application.OpenForms[xtraForm.Name].Activate(); } else { switch (modo) { case ModeOpen.Normal: xtraForm.Show(); break; case ModeOpen.Dialog: xtraForm.ShowDialog(); break; default: break; } } }
void SetStatus(ModeOpen modeOpenRW, ModeOpenConnection modeOpenConnectionRW) { SetStatus(modeOpenRW); SetStatus(modeOpenConnectionRW); }