private void btnOK_Click(object sender, EventArgs e) { int selCount = listFiles.SelectedIndices.Count; if (selCount < templateInfo.minFiles || selCount > templateInfo.maxFiles) { if (templateInfo.maxFiles == 1) { MessageBox.Show("Please select a file."); // is the same as selCount=0 (as list is in single-selection mode) } else if (templateInfo.minFiles == templateInfo.maxFiles) { MessageBox.Show(string.Format("Please select {0} files.", templateInfo.maxFiles)); } else if (templateInfo.maxFiles == int.MaxValue) { MessageBox.Show(string.Format("Please select at least {0} files.", templateInfo.minFiles)); } else { MessageBox.Show(string.Format("Please select {0} to {1} files.", templateInfo.minFiles, templateInfo.maxFiles)); } return; } filePackages = new List <FilePackageContent>(); foreach (var file in selectedIndices.Select(i => listFiles.Items[i])) { string fileFullPath = Path.Combine(textPath.Text, file.ToString()); if (templateInfo.templateType == HardDefinitions.TemplateType.Default) { filePackages.Add(new FilePackageContent() { PathBase = fileFullPath }); } else // MULTI_ALT { if (filePackages.Count == 0) { filePackages.Add(new FilePackageContent()); } filePackages[0].PathsAlt.Add(fileFullPath); } } // save selected paths in UI-user-settings (see EM_UI.PlugInService.SessionInfo.cs, about why not using an own settings-file) if (!EMPath.IsSamePath(textPath.Text.ToLower(), UISessionInfo.GetOutputFolder().ToLower())) // if the path was changed: save in user-settings ... { UISessionInfo.SetRetainedUserSetting(StatisticsPresenter.USER_SETTINGS_ID, StatisticsPresenter.BASE_OUTPUT_FOLDER, textPath.Text); } else // ... if path corresponds with default-output-folder: remove from user-settings, to avoid that it will remain, if user changes the default-path in project settings { UISessionInfo.RemoveRetainedUserSetting(StatisticsPresenter.USER_SETTINGS_ID, StatisticsPresenter.BASE_OUTPUT_FOLDER); } DialogResult = DialogResult.OK; Close(); }
private void btnOK_Click(object sender, EventArgs e) { if (listBase.SelectedIndex < 0) { MessageBox.Show("Please select a file for the base scenario."); return; } int selCount = listAlt.SelectedIndices.Count; if (selCount < templateInfo.minFiles || selCount > templateInfo.maxFiles) { if (templateInfo.maxFiles == 1) { MessageBox.Show("Please select a file for the alternative scenario."); // is the same as selCount=0 (as list is in single-selection mode) } else if (templateInfo.minFiles == templateInfo.maxFiles) { MessageBox.Show(string.Format("Please select {0} files for the alternative scenarios.", templateInfo.maxFiles)); } else if (templateInfo.maxFiles == int.MaxValue) { MessageBox.Show(string.Format("Please select at least {0} files for the alternative scenarios.", templateInfo.minFiles)); } else { MessageBox.Show(string.Format("Please select {0} to {1} files for the alternative scenarios.", templateInfo.minFiles, templateInfo.maxFiles)); } return; } FilePackageContent filePackage = new FilePackageContent() { PathBase = Path.Combine(textBasePath.Text, listBase.SelectedItem.ToString()) }; foreach (string altFile in selectedIndices.Select(i => listAlt.Items[i])) // get alt selections in order { filePackage.PathsAlt.Add(Path.Combine(textAltPath.Text, altFile)); } // in fact the dialog always returns exactly one file-package, the list is just for consistency-reasons with SelectFilesForm and SelectTemplateForm filePackages = new List <FilePackageContent>() { filePackage }; // save selected paths in UI-user-settings (see description in SelectFileForm.cs ) if (!EMPath.IsSamePath(textBasePath.Text.ToLower(), UISessionInfo.GetOutputFolder().ToLower())) { UISessionInfo.SetRetainedUserSetting(StatisticsPresenter.USER_SETTINGS_ID, StatisticsPresenter.BASE_OUTPUT_FOLDER, textBasePath.Text); } else { UISessionInfo.RemoveRetainedUserSetting(StatisticsPresenter.USER_SETTINGS_ID, StatisticsPresenter.BASE_OUTPUT_FOLDER); } if (!EMPath.IsSamePath(textAltPath.Text.ToLower(), UISessionInfo.GetOutputFolder().ToLower())) { UISessionInfo.SetRetainedUserSetting(StatisticsPresenter.USER_SETTINGS_ID, StatisticsPresenter.REFORM_OUTPUT_FOLDER, textAltPath.Text); } else { UISessionInfo.RemoveRetainedUserSetting(StatisticsPresenter.USER_SETTINGS_ID, StatisticsPresenter.REFORM_OUTPUT_FOLDER); } this.DialogResult = DialogResult.OK; this.Close(); }