Пример #1
0
        private void tsmiAddWord_Click(object sender, EventArgs e)
        {
            var wordInfos = lvWords.GetAsWordInfoList();

            var wordViewItem = new WordViewItem(string.Empty);

            lvWords.Items.Add(wordViewItem);

            using (var dialog = new EditWordInfoForm(this, Job.Add, _cambridgeProvider, wordViewItem.WordInfo, ref wordInfos))
            {
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    RemoveItemByWordInfo(wordViewItem.WordInfo, false);
                    return;
                }

                wordViewItem.WordInfo = dialog.WordInfo;
                RefreshWordColumn();
                _changeMade = true;
            }
        }
Пример #2
0
        private async Task LookUpWord(WordViewItem wordViewItem = null, string word = null)
        {
            word = wordViewItem.Text.Trim().ToLower();
            CambridgeWordInfo wordInfo = null;

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

                if (wordInfo == null)
                {
                    Invoke(new Action(() => wordViewItem.SubItems[2].Text = "Cannot find word."));
                    Debug.WriteLine($"Error:: Word ({word}): Cannot find word.");
                    return;
                }
                Invoke(new Action(() => wordViewItem.WordInfo = wordInfo));
                _changeMade = true;
                await Task.Delay(1000);
            }
            catch (Exception exception)
            {
                Debug.WriteLine($"Internal Error:: Word ({word}): {exception.Message}");
            }
        }
 private void SetWordInfoStates(WordViewItem wordViewItem, bool addedBefore, DateTime dateTime)
 {
     wordViewItem.WordInfo.AddedBefore      = addedBefore;
     wordViewItem.WordInfo.ImportedIntoAnki = dateTime;
     wordViewItem.Refresh();
 }