/// ------------------------------------------------------------------------------------ /// <summary> /// Handle the OK button: Validate input and create new project /// </summary> /// ------------------------------------------------------------------------------------ private void btnOK_Click(object sender, EventArgs e) { Enabled = false; DialogResult = DialogResult.OK; Logger.WriteEvent(string.Format( "Creating new language project: name: {0}, vernacular ws: {1}, anal ws: {2}", ProjectName, m_cbVernWrtSys.Text, m_cbAnalWrtSys.Text)); // Project with this name already exists? try { m_projInfo = ProjectInfo.GetProjectInfoByName(FwDirectoryFinder.ProjectsDirectory, ProjectName); } catch (IOException ex) { MessageBox.Show(ex.Message, FwUtils.ksSuiteName); DialogResult = DialogResult.Cancel; return; } if (m_projInfo != null) { // Bring up a dialog giving the user the option to open this existing project, // or cancel (return to New Project dialog). using (var dlg = new DuplicateProjectFoundDlg()) { dlg.ShowDialog(); switch (dlg.DialogResult) { case DialogResult.OK: m_fCreateNew = false; m_dbFile = ClientServerServices.Current.Local.IdForLocalProject(ProjectName); break; case DialogResult.Cancel: Enabled = true; DialogResult = DialogResult.None; // Return to New FieldWorks Project dialog break; } } return; } // // Create new project // CreateNewLangProjWithProgress(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handle the OK button. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// ------------------------------------------------------------------------------------ private void btnOK_Click(object sender, System.EventArgs e) { Enabled = false; DialogResult = DialogResult.OK; Logger.WriteEvent(string.Format( "Creating new language project: name: {0}, vernacular ws: {1}, anal ws: {2}", ProjectName, m_cbVernWrtSys.Text, m_cbAnalWrtSys.Text)); m_projInfo = GetProjectInfoByName(ProjectName); // Project with this name already exists? if (m_projInfo != null) { // Bring up a dialog giving the user the option to open this existing project, // create a new project or cancel (return to New Project dialog). using (DuplicateProjectFoundDlg dlg = new DuplicateProjectFoundDlg()) { dlg.ShowDialog(); switch (dlg.DialogResult) { case DialogResult.OK: m_fCreateNew = false; break; case DialogResult.Cancel: // Return to New FieldWorks Project dialog Enabled = true; DialogResult = DialogResult.None; break; } } } else { // The project does not exist yet. Bring up the new project dialog box. CreateNewLangProjWithProgress(); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handle the OK button. /// </summary> /// ------------------------------------------------------------------------------------ private void btnOK_Click(object sender, EventArgs e) { if (CheckForNonAsciiProjectName()) { if (DisplayNonAsciiWarningDialog() == DialogResult.Cancel) { m_fIgnoreClose = true; ProjectName = RemoveNonAsciiCharsFromProjectName(); m_txtName.Focus(); return; } } Enabled = false; DialogResult = DialogResult.OK; Logger.WriteEvent(string.Format( "Creating new language project: name: {0}, vernacular ws: {1}, anal ws: {2}", ProjectName, m_cbVernWrtSys.Text, m_cbAnalWrtSys.Text)); try { m_projInfo = ProjectInfo.GetProjectInfoByName(ProjectName); } catch (IOException ex) { MessageBox.Show(ex.Message, FwUtils.ksSuiteName); DialogResult = DialogResult.Cancel; return; } // Project with this name already exists? if (m_projInfo != null) { // Bring up a dialog giving the user the option to open this existing project, // or cancel (return to New Project dialog). using (var dlg = new DuplicateProjectFoundDlg()) { dlg.ShowDialog(); switch (dlg.DialogResult) { case DialogResult.OK: m_fCreateNew = false; m_dbFile = ClientServerServices.Current.Local.IdForLocalProject(ProjectName); break; case DialogResult.Cancel: // Return to New FieldWorks Project dialog Enabled = true; DialogResult = DialogResult.None; break; } } } else { // The project does not exist yet. if (ProjectName.Length > kmaxNameLength) { if (DisplayUi) { MessageBox.Show(String.Format(FwCoreDlgs.kstidErrorProjectNameTooLong, ProjectName), FwUtils.ksSuiteName); } m_txtName.Text = ""; m_txtName.Select(); // Need to figure out how to get the dialog to display itself again DialogResult = DialogResult.Retry; return; } CreateNewLangProjWithProgress(); } }