public void OkDialog() { var helper = new MessageBoxHelper(this); if (NamedPathSets == null) { if (radioAddExisting.Checked) { if (comboName.SelectedIndex == -1) { MessageBox.Show(this, Resources.ImportResultsDlg_OkDialog_You_must_select_an_existing_set_of_results_to_which_to_append_new_data, Program.Name); comboName.Focus(); return; } if (!CanCreateMultiInjectionMethods()) { return; } NamedPathSets = GetDataSourcePathsFile(comboName.SelectedItem.ToString()); } else if (radioCreateMultiple.Checked) { NamedPathSets = GetDataSourcePathsFile(null); } else if (radioCreateMultipleMulti.Checked) { if (!CanCreateMultiInjectionMethods()) { return; } NamedPathSets = GetDataSourcePathsDir(); } else { string name; if (!helper.ValidateNameTextBox(textName, out name)) { return; } if (name.IndexOfAny(Path.GetInvalidFileNameChars()) != -1) { helper.ShowTextBoxError(textName, Resources.ImportResultsDlg_OkDialog_A_result_name_may_not_contain_any_of_the_characters___0___, Path.GetInvalidFileNameChars()); return; } if (ResultsExist(name)) { helper.ShowTextBoxError(textName, Resources.ImportResultsDlg_OkDialog_The_specified_name_already_exists_for_this_document); return; } NamedPathSets = GetDataSourcePathsFile(name); if (NamedPathSets == null) { return; } foreach (var namedPathSet in NamedPathSets) { // Look for a multiple injection replicate if (namedPathSet.Value.Length > 1) { // Make sure they are allowed if (!CanCreateMultiInjectionMethods()) { return; } // If so, then no need to check any others break; } } } } if (NamedPathSets == null) { return; } if (NamedPathSets.Length > 1) { var resultNames = NamedPathSets.Select(ns => ns.Key).ToArray(); string prefix = GetCommonPrefix(resultNames); string suffix = GetCommonSuffix(resultNames); if (!String.IsNullOrEmpty(prefix) || !String.IsNullOrEmpty(suffix)) { using (var dlgName = new ImportResultsNameDlg(prefix, suffix, resultNames)) { var result = dlgName.ShowDialog(this); if (result == DialogResult.Cancel) { return; } if (dlgName.IsRemove) { dlgName.ApplyNameChange(NamedPathSets); Prefix = string.IsNullOrEmpty(prefix) ? null : prefix; Suffix = string.IsNullOrEmpty(suffix) ? null : suffix; } } } } // Always make sure multiple replicates have unique names. For single // replicate, the user will get an error. if (IsMultiple) { EnsureUniqueNames(); } DialogResult = DialogResult.OK; }
public void OkDialog() { var helper = new MessageBoxHelper(this); if (NamedPathSets == null) { if (radioAddExisting.Checked) { if (comboName.SelectedIndex == -1) { MessageBox.Show(this, Resources.ImportResultsDlg_OkDialog_You_must_select_an_existing_set_of_results_to_which_to_append_new_data, Program.Name); comboName.Focus(); return; } if (!CanCreateMultiInjectionMethods()) { return; } NamedPathSets = GetDataSourcePathsFile(comboName.SelectedItem.ToString()); } else if (radioCreateMultiple.Checked) { NamedPathSets = GetDataSourcePathsFile(null); } else if (radioCreateMultipleMulti.Checked) { if (!CanCreateMultiInjectionMethods()) { return; } NamedPathSets = GetDataSourcePathsDir(); } else { string name; if (!helper.ValidateNameTextBox(textName, out name)) { return; } if (name.IndexOfAny(Path.GetInvalidFileNameChars()) != -1) { helper.ShowTextBoxError(textName, Resources.ImportResultsDlg_OkDialog_A_result_name_may_not_contain_any_of_the_characters___0___, Path.GetInvalidFileNameChars()); return; } if (ResultsExist(name)) { helper.ShowTextBoxError(textName, Resources.ImportResultsDlg_OkDialog_The_specified_name_already_exists_for_this_document); return; } NamedPathSets = GetDataSourcePathsFile(name); if (NamedPathSets == null) { return; } foreach (var namedPathSet in NamedPathSets) { // Look for a multiple injection replicate if (namedPathSet.Value.Length > 1) { // Make sure they are allowed if (!CanCreateMultiInjectionMethods()) { return; } // If so, then no need to check any others break; } } } } if (NamedPathSets == null) { return; } if (NamedPathSets.Length > 1) { string prefix = GetCommonPrefix(Array.ConvertAll(NamedPathSets, ns => ns.Key)); if (prefix.Length >= MIN_COMMON_PREFIX_LENGTH) { using (var dlgName = new ImportResultsNameDlg(prefix)) { var result = dlgName.ShowDialog(this); if (result == DialogResult.Cancel) { return; } if (result == DialogResult.Yes) { // Rename all the replicates to remove the specified prefix. for (int i = 0; i < NamedPathSets.Length; i++) { var namedSet = NamedPathSets[i]; NamedPathSets[i] = new KeyValuePair <string, MsDataFileUri[]>( namedSet.Key.Substring(dlgName.Prefix.Length), namedSet.Value); } } } } } // Always make sure multiple replicates have unique names. For single // replicate, the user will get an error. if (IsMultiple) { EnsureUniqueNames(); } DialogResult = DialogResult.OK; }
public void OkDialog() { var helper = new MessageBoxHelper(this); if (NamedPathSets == null) { if (radioAddExisting.Checked) { if (comboName.SelectedIndex == -1) { MessageBox.Show(this, Resources.ImportResultsDlg_OkDialog_You_must_select_an_existing_set_of_results_to_which_to_append_new_data, Program.Name); comboName.Focus(); return; } if (!CanCreateMultiInjectionMethods()) return; NamedPathSets = GetDataSourcePathsFile(comboName.SelectedItem.ToString()); } else if (radioCreateMultiple.Checked) { NamedPathSets = GetDataSourcePathsFile(null); } else if (radioCreateMultipleMulti.Checked) { if (!CanCreateMultiInjectionMethods()) return; NamedPathSets = GetDataSourcePathsDir(); } else { string name; if (!helper.ValidateNameTextBox(textName, out name)) return; if (name.IndexOfAny(Path.GetInvalidFileNameChars()) != -1) { helper.ShowTextBoxError(textName, Resources.ImportResultsDlg_OkDialog_A_result_name_may_not_contain_any_of_the_characters___0___, Path.GetInvalidFileNameChars()); return; } if (ResultsExist(name)) { helper.ShowTextBoxError(textName, Resources.ImportResultsDlg_OkDialog_The_specified_name_already_exists_for_this_document); return; } NamedPathSets = GetDataSourcePathsFile(name); if (NamedPathSets == null) return; foreach (var namedPathSet in NamedPathSets) { // Look for a multiple injection replicate if (namedPathSet.Value.Length > 1) { // Make sure they are allowed if (!CanCreateMultiInjectionMethods()) return; // If so, then no need to check any others break; } } } } if (NamedPathSets == null) return; if (NamedPathSets.Length > 1) { string prefix = GetCommonPrefix(Array.ConvertAll(NamedPathSets, ns => ns.Key)); if (prefix.Length >= MIN_COMMON_PREFIX_LENGTH) { using (var dlgName = new ImportResultsNameDlg(prefix)) { var result = dlgName.ShowDialog(this); if (result == DialogResult.Cancel) { return; } if (result == DialogResult.Yes) { // Rename all the replicates to remove the specified prefix. for (int i = 0; i < NamedPathSets.Length; i++) { var namedSet = NamedPathSets[i]; NamedPathSets[i] = new KeyValuePair<string, MsDataFileUri[]>( namedSet.Key.Substring(dlgName.Prefix.Length), namedSet.Value); } } } } } // Always make sure multiple replicates have unique names. For single // replicate, the user will get an error. if (IsMultiple) EnsureUniqueNames(); DialogResult = DialogResult.OK; }