//Add an existing word. private void Lb_PreviewMouseDown(object sender, MouseButtonEventArgs e) { string data = (sender as Label).Content.ToString(); try { data = (sender as Label).Content.ToString().Split(" 1234567890.,!?()-_<>';:\"\\/=+-/^@$%{}|&\n\r\t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[0]; } catch { return; } int?word = _proxy.GetWord(data); if (word == null) { AddWord form = new AddWord(_proxy, data, user, videoId, ServerData.Video); _play = true; btnPlay_Click(null, null); form.ShowDialog(); btnPlay_Click(null, null); } else { _play = true; btnPlay_Click(null, null); if (MessageBox.Show("Do you want to add this word to your list?", "Save word", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { _proxy.AddItemsWord(Convert.ToInt32(word), videoId, ServerData.Video); _proxy.AddItemsWord(Convert.ToInt32(word), Convert.ToInt32(user), ServerData.User); } btnPlay_Click(null, null); } }
//Add a new word. private void Lb_PreviewMouseDown(object sender, MouseButtonEventArgs e) { string data = (sender as TextBox).Text; try { data = (sender as TextBox).Text.Split(" 1234567890.,!'?()-_<>;:\"\\/=+-/^@$%{}|&\n\r\t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[0]; } catch { return; } int?word = _proxy.GetWord(data); if (word == null) { AddWord form = new AddWord(_proxy, data, user, book, ServerData.Book); form.ShowDialog(); } else { if (MessageBox.Show("Do you want to add this word to your list?", "Save word", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { _proxy.AddItemsWord(Convert.ToInt32(word), book, ServerData.Book); _proxy.AddItemsWord(Convert.ToInt32(word), user, ServerData.User); } } }
//Show a form for editting the word. private void btnEditWord_Click(object sender, RoutedEventArgs e) { AddWord form = new AddWord(_proxy, Convert.ToInt32((sender as Button).Tag), Convert.ToInt32(_proxy.GetItemsId(lUserName.Content.ToString(), ServerData.User))); form.ShowDialog(); btnWords_Click(null, null); }
//Show a form for adding a new word. private void btnAddWord(object sender, RoutedEventArgs e) { int? user = _proxy.GetItemsId(lUserName.Content.ToString(), ServerData.User); AddWord form = new AddWord(_proxy, user); form.ShowDialog(); btnWords_Click(null, null); }