/// <summary> /// Event handler for "Delete quiz" button /// </summary> /// <param name="sender">The object sending the request, in this case a button</param> /// <param name="e">Event arguments</param> private void DeleteQuizButton_Click(object sender, RoutedEventArgs e) { if (QuizesListView.SelectedIndex >= 0) { if (quizHandler.RemoveQuiz(QuizesListView.SelectedIndex)) { quizes.RemoveAt(QuizesListView.SelectedIndex); QuestionsOfSelectedQuiz.Clear(); QuestionsAnswersTabControl.IsEnabled = false; } } else { MessageBoxes.ShowInformationMessageBox("Please select a quiz to remove"); } }
/// <summary> /// Event handler for "Edit quiz" button /// </summary> /// <param name="sender">The object sending the request, in this case a ListView</param> /// <param name="e">The event arguments</param> private void EditQuestionButton_Click(object sender, RoutedEventArgs e) { if (QuestionsOfSelectedQuizListView.SelectedIndex >= 0) { GenericChangePopupUserControl popupCtrl = new GenericChangePopupUserControl(); popupCtrl.TypeOfAction = Mode.Edit; popupCtrl.TypeOfItemToHandle = TypeOfItemToChange.Question; popupCtrl.OldTitle = QuestionsOfSelectedQuiz.Where(x => x.Id == QuestionsOfSelectedQuizListView.SelectedIndex + 1).FirstOrDefault().Title; popupCtrl.IsSavedEvent += (senderIsSaved, eIsSaved) => { ChangeQuestionInformation(QuestionsOfSelectedQuizListView.SelectedIndex, eIsSaved.NewTitle); UcContainer.Children.Remove(eIsSaved.UserControl); }; popupCtrl.InitializeGui(); UcContainer.Children.Add(popupCtrl); } else { MessageBoxes.ShowInformationMessageBox("Please select an question to edit"); } }
/// <summary> /// Event handler for "Edit answer" button /// </summary> /// <param name="sender">The object sending the request, in this case a button</param> /// <param name="e">The event arguments</param> private void EditAnswerButton_Click(object sender, RoutedEventArgs e) { if (AnswersOfSelectedQuestionListView.SelectedIndex >= 0) { GenericChangePopupUserControl popupCtrl = new GenericChangePopupUserControl(); popupCtrl.TypeOfAction = Mode.Edit; popupCtrl.TypeOfItemToHandle = TypeOfItemToChange.Answer; popupCtrl.OldTitle = quizHandler.quizManager.GetAt(QuizesListView.SelectedIndex).Questions.GetAt(QuestionsOfSelectedQuizListView.SelectedIndex).Answers.GetAt(AnswersOfSelectedQuestionListView.SelectedIndex).Title; popupCtrl.OldIsRightAnswer = quizHandler.quizManager.GetAt(QuizesListView.SelectedIndex).Questions.GetAt(QuestionsOfSelectedQuizListView.SelectedIndex).Answers.GetAt(AnswersOfSelectedQuestionListView.SelectedIndex).RightAnswer; popupCtrl.IsSavedEvent += (senderIsSaved, eIsSaved) => { ChangeAnswerInformation(AnswersOfSelectedQuestionListView.SelectedIndex, eIsSaved.NewTitle); UcContainer.Children.Remove(eIsSaved.UserControl); }; popupCtrl.InitializeGui(); UcContainer.Children.Add(popupCtrl); } else { MessageBoxes.ShowInformationMessageBox("Please select an answer to edit"); } }
/// <summary> /// Asks theuser if they want to continue without saving /// </summary> /// <returns>true/false</returns> private static bool WantToContinueWithoutSaving() { return(MessageBoxes.ShowSaveWarningMessageBox("Your current work will be lost, please save them first. Do you want to continue?") == MessageBoxResult.Yes); }