Пример #1
0
        private async void TextBox_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (String.IsNullOrWhiteSpace(_textBox.Text))
            {
                return;
            }

            //находим слово по которому был двойной клик
            var word = _wordsService.GetWordByPosition(_textBox.Text, _textBox.SelectionStart);

            //находим перевод слова
            var result = await _yandexServices.GetDictionaryAnswerAsync(word.Value,
                                                                        YandexServices.TranslationDirection.RuEng);

            word.Translation = result.Text;

            //показываем слово и его перевод
            var message = $"Слово: {word.Value}"
                          + Environment.NewLine
                          + $"Перевод: {word.Translation}";

            MessageBox.Show(message);
        }