Ejemplo n.º 1
0
        public async Task GetDictionaryAsync()
        {
            var direction = GetDirection();
            var result    = await _yandexServices
                            .GetDictionaryAnswerAsync(Input, direction);

            Output = result.Text;
        }
        public async Task GetDictionaryAnswerAsyncTest()
        {
            var            ru  = "мысль";
            var            eng = "thought";
            YandexServices sut = new YandexServices();

            YandexServices.TranslationDirection direction
                = YandexServices.TranslationDirection.RuEng;

            YandexAnswer answer = await sut.GetDictionaryAnswerAsync(ru, direction);

            Assert.AreEqual("OK", answer.Code);
            Assert.IsTrue(answer.Text.Contains(eng));
        }
Ejemplo n.º 3
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);
        }