private void BtnGenerate_Click(object sender, EventArgs e) { if (ViewState == ViewState.IsRefreshing) { return; } if (!IdInternDetails.presenter.savedChanges) { ConfirmationDialog saveNotification = new ConfirmationDialog(SAVE_NOTIFICATION_TITLE, SAVE_NOTIFICATION_TEXT); if (saveNotification.ShowDialog() == DialogResult.Yes) { speichernToolStripMenuItem_Click(sender, e); } } Dictionary <string, string> textParts = new Dictionary <string, string>(); List <CriteriaTextSelectionView> sortList = new List <CriteriaTextSelectionView>(); List <GuidId> sortedCriteria = new List <GuidId>(InternDetails.SavedCriterias); sortedCriteria.Sort(InternDetails.SavedCriterias.SortDelegate); foreach (GuidId savedId in sortedCriteria) { foreach (CriteriaTextSelectionView singleTextPartSelection in textPartSelectionList) { if (singleTextPartSelection.presenter.CurShowedCriteria.guid == savedId.Guid) { sortList.Add(singleTextPartSelection); } } } foreach (CriteriaTextSelectionView singleTextPartSelection in sortList) { if (singleTextPartSelection.presenter.SelectedVariation != null) { textParts[singleTextPartSelection.presenter.CurShowedCriteria.Name] = singleTextPartSelection.presenter.SelectedVariation.PredifinedText; } else { textParts[singleTextPartSelection.presenter.CurShowedCriteria.Name] = string.Empty; } } try { Presenter.GenerateWordDocument(IdInternDetails.presenter.CurShowedInternDetails, textParts, IdInternDetails.BulletpointsPractExp, IdInternDetails.BulletpointsExcercises); } catch (FileNotFoundException) { OpenMessageDialog(FILE_NOT_FOUND_TITLE, DEFAULT_TEMPLATE_NOT_FOUND_TEXT); } catch (IOException) { OpenMessageDialog(IOEXCEPTION_DIALOG_TITLE, IOEXCEPTION_DIALOG_TEXT); } catch (Exception ex) when(ex is DirectoryNotFoundException || ex is PathTooLongException) { OpenMessageDialog(INVALID_PATH_TITLE, INVALID_PATH_TEXT); } }