Esempio n. 1
0
        private async void bLookUp_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(tbInputWord.Text))
            {
                return;
            }

            var word = tbInputWord.Text.Trim().ToLower();

            try
            {
                var wordInfo = await _cambridgeProvider.GetWordInfo(word);

                if (wordInfo == null)
                {
                    MessageBox.Show($"\"{word}\" doesn't exist.");
                    return;
                }

                WordInfo = wordInfo;
                lvDefinitions.Items.Clear();
                lvExamples.Items.Clear();

                RefreshWordInfoUI();
                ChangeMade = true;
            }
            catch (Exception exception)
            {
                Debug.WriteLine($"Internal Error:: Word ({word}): {exception.Message}");
            }
        }
Esempio n. 2
0
        private async void lvWords_DoubleClick(object sender, EventArgs e)
        {
            var word = lvWords.SelectedItems[0].Text.Trim().ToLower();

            if (string.IsNullOrWhiteSpace(word))
            {
                return;
            }

            var wordViewItem = (lvWords.SelectedItems[0] as WordViewItem);

            if (wordViewItem.WordInfo.Entries.Count == 0)
            {
                wordViewItem.WordInfo = await _cambridgeProvider.GetWordInfo(word);

                if (wordViewItem.WordInfo == null)
                {
                    return;
                }
            }
            rtbWordOutput.Text = _textFormatter.Render(wordViewItem.WordInfo);
        }