/// <summary> /// Event handler for the "Add 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 AddAnswerButton_Click(object sender, RoutedEventArgs e) { GenericChangePopupUserControl popupCtrl = new GenericChangePopupUserControl(); popupCtrl.TypeOfAction = Mode.Add; popupCtrl.TypeOfItemToHandle = TypeOfItemToChange.Answer; popupCtrl.IsSavedEvent += (senderIsSaved, eIsSaved) => { CreateNewAnswer(eIsSaved.NewTitle, eIsSaved.IsRightAnswer); AnswersOfSelectedQuestion = new ObservableCollection <Answer>(quizHandler.quizManager.GetAt(QuizesListView.SelectedIndex).Questions.GetAt(QuestionsOfSelectedQuizListView.SelectedIndex).Answers.GetAllItems()); AnswersOfSelectedQuestionListView.ItemsSource = AnswersOfSelectedQuestion; UcContainer.Children.Remove(eIsSaved.UserControl); }; popupCtrl.InitializeGui(); UcContainer.Children.Add(popupCtrl); }
/// <summary> /// Event handler for "Change 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 ChangeQuizButton_Click(object sender, RoutedEventArgs e) { if (QuizesListView.SelectedIndex >= 0) { GenericChangePopupUserControl popupCtrl = new GenericChangePopupUserControl(); popupCtrl.TypeOfAction = Mode.Edit; popupCtrl.TypeOfItemToHandle = TypeOfItemToChange.Quiz; popupCtrl.OldTitle = quizHandler.quizManager.GetAt(QuizesListView.SelectedIndex).Title; popupCtrl.OldDescription = quizHandler.quizManager.GetAt(QuizesListView.SelectedIndex).Description; popupCtrl.IsSavedEvent += (senderIsSaved, eIsSaved) => { ChangeQuizInformation(QuizesListView.SelectedIndex, eIsSaved.NewTitle, eIsSaved.NewDescription); UcContainer.Children.Remove(eIsSaved.UserControl); }; popupCtrl.InitializeGui(); UcContainer.Children.Add(popupCtrl); } }
/// <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"); } }