private void Button_DeleteFlascard(object sender, RoutedEventArgs e) { if (listBoxFlashcards.SelectedItem == null) { System.Windows.Forms.MessageBox.Show(FLASHCARDNOTSELECTED); e.Handled = true; return; } MessageBoxResult mbr = System.Windows.MessageBox.Show("Are you sure you want to delete this item?", "Delete Button", MessageBoxButton.YesNo); if (mbr == MessageBoxResult.Yes) { FlashCardSet flashCardItem = (FlashCardSet)listBoxFlashcards.SelectedItem; flashCardCollection.Remove(flashCardCollection.First(x => x.Key == flashCardItem.Key)); FlashCardSet[] dictCopy = new FlashCardSet[flashCardCollection.Count()]; flashCardCollection.CopyTo(dictCopy, 0); flashCardCollection.Clear(); handle = 0; foreach (FlashCardSet kvp in dictCopy) { flashCardCollection.Add(new FlashCardSet() { Key = FLASHCARDNUMBER + ++handle, Value = new FlashCard() { UrduPhrase = kvp.Value.UrduPhrase, EnglishPhrase = kvp.Value.EnglishPhrase } }); } this.txtBlockCardData.Visibility = Visibility.Hidden; this.flashCardBorder.Visibility = Visibility.Hidden; } }
public EditWindow(FlashCardSet kvp) { InitializeComponent(); this.txtBoxUrduWord.Text = kvp.Value.UrduPhrase; this.txtBoxEnglishWord.Text = kvp.Value.EnglishPhrase; this.KeyDown += EditWindow_KeyDown; }
void ew_ApplyChangeEvent(string text1, string text2) { FlashCardSet flashCardItem = (FlashCardSet)listBoxFlashcards.SelectedItem; flashCardCollection.Single(x => x.Key == flashCardItem.Key).Value.UrduPhrase = text1; flashCardCollection.Single(x => x.Key == flashCardItem.Key).Value.EnglishPhrase = text2; this.txtBlockCardData.Text = urduSide ? flashCardCollection.Single(x => x.Key == flashCardItem.Key).Value.UrduPhrase : flashCardCollection.Single(x => x.Key == flashCardItem.Key).Value.EnglishPhrase; }
private void listBoxFlashcards_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (listBoxFlashcards.SelectedItem == null) { e.Handled = true; return; } FlashCardSet flashCardItem = (FlashCardSet)listBoxFlashcards.SelectedItem; this.txtBlockCardData.Text = urduSide ? flashCardCollection.Single(x => x.Key == flashCardItem.Key).Value.UrduPhrase : flashCardCollection.Single(x => x.Key == flashCardItem.Key).Value.EnglishPhrase; this.txtBlockCardData.Visibility = Visibility.Visible; this.flashCardBorder.Visibility = Visibility.Visible; }
private void Button_ShowFlashCard(object sender, RoutedEventArgs e) { if (listBoxFlashcards.SelectedItem == null) { System.Windows.Forms.MessageBox.Show(FLASHCARDNOTSELECTED); e.Handled = true; return; } FlashCardSet flashCardItem = (FlashCardSet)listBoxFlashcards.SelectedItem; this.txtBlockCardData.Text = flashCardCollection.Single(x => x.Key == flashCardItem.Key).Value.UrduPhrase.ToString(); this.txtBlockCardData.Visibility = Visibility.Visible; this.flashCardBorder.Visibility = Visibility.Visible; }
private void Button_Edit(object sender, RoutedEventArgs e) { if (listBoxFlashcards.SelectedItem == null) { System.Windows.Forms.MessageBox.Show(FLASHCARDNOTSELECTED); e.Handled = true; return; } FlashCardSet kvp = listBoxFlashcards.SelectedItem as FlashCardSet; EditWindow ew = new EditWindow(kvp); ew.Show(); ew.ApplyChangeEvent += ew_ApplyChangeEvent; }
private void PreviousButton_Click(object sender, RoutedEventArgs e) { if (listBoxFlashcards.SelectedItem == null) { System.Windows.Forms.MessageBox.Show(FLASHCARDNOTSELECTED); e.Handled = true; return; } FlashCardSet item = listBoxFlashcards.SelectedItem as FlashCardSet; int currentPosition = flashCardCollection.IndexOf(item); if (currentPosition == 0) { listBoxFlashcards.SelectedItem = flashCardCollection.ElementAt(flashCardCollection.Count() - 1); } else { listBoxFlashcards.SelectedItem = flashCardCollection.ElementAt(currentPosition - 1); } }
private void flipcard() { if (listBoxFlashcards.SelectedItem == null) { System.Windows.Forms.MessageBox.Show(FLASHCARDNOTSELECTED); return; } FlashCardSet flashCardItem = (FlashCardSet)listBoxFlashcards.SelectedItem; if (urduSide) { this.txtBlockCardData.Text = flashCardCollection.Single(x => x.Key == flashCardItem.Key).Value.EnglishPhrase.ToString(); urduSide = false; } else { this.txtBlockCardData.Text = flashCardCollection.Single(x => x.Key == flashCardItem.Key).Value.UrduPhrase.ToString(); urduSide = true; } this.listBoxFlashcards.Focus(); }
private void Button_Speak(object sender, RoutedEventArgs e) { if (listBoxFlashcards.SelectedItem == null) { System.Windows.Forms.MessageBox.Show(FLASHCARDNOTSELECTED); e.Handled = true; return; } SpeechSynthesizer speech = new SpeechSynthesizer(); FlashCardSet kvp = listBoxFlashcards.SelectedItem as FlashCardSet; if (urduSide) { speech.Speak(kvp.Value.UrduPhrase); } else { speech.Speak(kvp.Value.EnglishPhrase); } }