private void AddQImage_Click(object sender, RoutedEventArgs e) { if (current.CheckQImageFile()) { addQImage.Content = "Add Image"; current.SetQImageFile(""); } else { Microsoft.Win32.OpenFileDialog image = new Microsoft.Win32.OpenFileDialog { Filter = "JPG Image|*.jpg|PNG Image|*.png|GIF Image|*.gif", InitialDirectory = AppConstants.TESTSLOCATION }; bool?result = image.ShowDialog(); if (result != null && result == true) { current.SetQImageFile(image.FileName); addQImage.Content = "Remove Image"; } else { addQImage.Content = "Add Image"; } } qMediaFile.Text = ""; if (current.CheckQImageFile()) { qMediaFile.Text += current.GetQImageFile().Split('\\').Last(); } if (current.CheckQImageFile() && current.CheckQVideoFile()) { qMediaFile.Text += ", "; } if (current.CheckQVideoFile()) { qMediaFile.Text += current.GetQVideoFile().Split('\\').Last(); } }
private void SetQuestion(int index) { if (!question.Text.Equals("")) { foreach (DockPanel item in answerList.Children) { if (((TextBox)item.Children[2]).Text.Equals("")) { MessageBox.Show("There are some choices that are still empty. "); return; } } if (index == AppConstants.QUESTIONS.Count) { AppConstants.QUESTIONS.Add(current); } } if (qIndex > 0) { Previous.Visibility = Visibility.Visible; } AppConstants.QUESTIONS[index].SetQuestion(question.Text); AppConstants.QUESTIONS[index].removeAllChoices(); foreach (DockPanel item in answerList.Children) { // TODO make sure this works bool answer = (bool)((CheckBox)item.Children[0]).IsChecked; char key = ((string)((Label)item.Children[1]).Content)[0]; AppConstants.QUESTIONS[index].AddChoice(key, ((TextBox)item.Children[2]).Text); if (answer) { AppConstants.QUESTIONS[index].SetChoiceTrue(key); } } AppConstants.QUESTIONS[index].SetExplanation(explanation.Text + "\n"); current = new EditorQuestion(); question.Text = ""; explanation.Text = ""; addQImage.Content = "Add Image"; addQVideo.Content = "Add Video"; addImage.Content = "Add Image"; addVideo.Content = "Add Video"; if (!current.CheckQImageFile() && !current.CheckQVideoFile()) { qMediaFile.Text = "No media"; } else { qMediaFile.Text = ""; } if (!current.CheckAImageFile() && !current.CheckAVideoFile()) { mediaFile.Content = "No media"; } else { mediaFile.Content = ""; } if (current.CheckQImageFile()) { qMediaFile.Text += current.GetAImageFile().Split('\\').Last(); addQImage.Content = "Remove Image"; } if (current.CheckAImageFile() && current.CheckAVideoFile()) { qMediaFile.Text += ", "; } if (current.CheckAVideoFile()) { qMediaFile.Text += current.GetAVideoFile().Split('\\').Last(); addQVideo.Content = "Remove Video"; } if (current.CheckAImageFile()) { mediaFile.Content += current.GetAVideoFile().Split('\\').Last(); addImage.Content = "Remove Image"; } if (current.CheckAImageFile() && current.CheckAVideoFile()) { mediaFile.Content += ", "; } if (current.CheckAVideoFile()) { mediaFile.Content += current.GetAVideoFile().Split('\\').Last(); addVideo.Content = "Remove Video"; } RefreshAnswerEditList(int.Parse((string)((ComboBoxItem)answerAmountSelector.SelectedItem).Content)); }