// Validate the chosen location before closing private void mOKButton_Click(object sender, EventArgs e) { if (m_ProjectNameTextBox.Text.Trim() == string.Empty) { MessageBox.Show(Localizer.Message("SaveAsEmptyProjectFileName"), Localizer.Message("Caption_Error"), MessageBoxButtons.OK, MessageBoxIcon.Error); mCanClose = false; } else { string newPath = Path.Combine(mLocationTextBox.Text, m_ProjectNameTextBox.Text + ".obi"); try { string[] logicalDrives = System.IO.Directory.GetLogicalDrives(); foreach (string drive in logicalDrives) { if ((mLocationTextBox.Text == drive) || (mLocationTextBox.Text == Environment.GetFolderPath(Environment.SpecialFolder.Desktop)) || (mLocationTextBox.Text == Environment.GetFolderPath(Environment.SpecialFolder.MyComputer) || (mLocationTextBox.Text == Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)))) { MessageBox.Show(string.Format(Localizer.Message("SaveAs_cannot_save_in_root"), mLocationTextBox.Text)); mCanClose = false; return; } // Must not save in same directory } if (Path.GetFullPath(Path.GetDirectoryName(newPath)) == Path.GetFullPath(Path.GetDirectoryName(mOriginalProjectPath))) { MessageBox.Show(Localizer.Message("save_as_error_same_directory")); mCanClose = false; } // The selected location must be suitable else if (!m_PathChecked && !ObiForm.CheckProjectPath(newPath, true)) { mCanClose = false; } else { mNewProjectPath = newPath; mCanClose = true; } } catch (Exception x) { MessageBox.Show(string.Format(Localizer.Message("cannot_use_project_path"), newPath, x.Message), Localizer.Message("cannot_use_project_path_caption"), MessageBoxButtons.OK, MessageBoxIcon.Error); mCanClose = false; } } }
/// <summary> /// Before closing, make sure that the directory chosen works. /// </summary> private void mOKButton_Click(object sender, EventArgs e) { mCanClose = false; try { if (mTitleBox.Text.Trim() == "") { MessageBox.Show(Localizer.Message("NewProject_EmptyTitle"), Localizer.Message("EmptyProjectTitle_error_Caption"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } bool tempCheckPath = ObiForm.CheckProjectPath(mFileBox.Text, true); if (tempCheckPath) { m_AudioSettingsDialog.ShowDialog(); mCanClose = true; } } catch (Exception x) { MessageBox.Show(x.Message, Localizer.Message("location_error"), MessageBoxButtons.OK, MessageBoxIcon.Error); } }