예제 #1
0
        private string GetWordText(
            PaginationCollection <WordInLearningSet> collection,
            DictionaryWord dictionaryWord,
            IReadOnlyList <Translation> translations,
            WordInLearningSet wordInLearningSet)
        {
            var engWord             = dictionaryWord.Word;
            var transcription       = dictionaryWord.Transcription;
            var allowedTranslations = SearchForAllowedTranslations(translations, wordInLearningSet);
            var example             = GetExampleOrNull(wordInLearningSet, allowedTranslations);

            var msg = new StringBuilder();

            msg.AppendLine($"*{engWord.EscapeForMarkdown().Capitalize()}*");
            if (!string.IsNullOrWhiteSpace(transcription))
            {
                msg.Append($"```\r\n[{transcription.EscapeForMarkdown()}]\r\n```");
            }
            msg.AppendLine(
                $"\r\n*{string.Join("\r\n", allowedTranslations.Select(a => a.TranslatedText.EscapeForMarkdown().Capitalize()))}*");
            if (example != null)
            {
                msg.Append(
                    $"```\r\n\r\n" +
                    $"{Emojis.OpenQuote}{example.OriginPhrase.EscapeForMarkdown()}{Emojis.CloseQuote}\r\n" +
                    $"{Emojis.OpenQuote}{example.TranslatedPhrase.EscapeForMarkdown()}{Emojis.CloseQuote}" +
                    $"\r\n```");
            }
            msg.AppendLine($"\r\n{Chat.Texts.XofYMarkdown(collection.Page + 1, collection.Count)}");
            return(msg.ToString());
        }
예제 #2
0
        public async Task <IReadOnlyList <DictionaryTranslation> > TranslateAndAddToDictionary(string englishWord)
        {
            englishWord = englishWord.ToLower();

            if (!englishWord.Contains(' '))
            {
                // Go to yandex api
                var result = await _yaDicClient.TranslateAsync(englishWord);

                if (result?.Any() != true)
                {
                    return(new DictionaryTranslation[0]);
                }

                var variants = result.SelectMany(r => r.Tr.Select(tr => new {
                    defenition  = r,
                    translation = tr,
                }));
                var word = new DictionaryWord
                {
                    Id            = ObjectId.GenerateNewId(),
                    Language      = Language.En,
                    Word          = englishWord,
                    Source        = TranslationSource.Yadic,
                    Transcription = result.FirstOrDefault()?.Ts,
                    Translations  = variants.Select(v => new SayWhat.MongoDAL.Dictionary.DictionaryTranslation
                    {
                        Word     = v.translation.Text,
                        Examples = v.translation.Ex?.Select(e =>
                        {
                            var id = ObjectId.GenerateNewId();
                            return(new DictionaryReferenceToExample
                            {
                                ExampleId = id,
                                ExampleOrNull = new Example
                                {
                                    Id = id,
                                    OriginWord = englishWord,
                                    TranslatedWord = v.translation.Text,
                                    Direction = TranlationDirection.EnRu,
                                    OriginPhrase = e.Text,
                                    TranslatedPhrase = e.Tr.First().Text,
                                }
                            });
                        }).ToArray() ?? new DictionaryReferenceToExample[0]
                    }).ToArray()
                };
                await _dictionaryService.AddNewWord(word);

                return(word.Translations.Select(
                           t => new DictionaryTranslation(
                               enWord: word.Word,
                               ruWord: t.Word,
                               enTranscription: word.Transcription,
                               source: word.Source,
                               phrases: t.Examples.Select(e => e.ExampleOrNull).ToList()
                               )).ToArray());
            }
            return(null);
        }
예제 #3
0
        /// <summary>
        /// Создание нового словаря. Если существует старый словарь, то будет ошибка.
        /// </summary>
        /// <param name="text">Текст со словами.</param>
        public override void CreateDictionary(string text)
        {
            // Словарь слов и их частот.
            Dictionary <string, int> dictionery = new Dictionary <string, int>();

            if (_repoDictionary.Get().Any())//Проверка на пустоту словаря
            {
                throw new Exception("Error: Dictionary words in Data Base is not Empty.");
            }

            //проверка текста на пустоту
            //из текста удалить все знаки препинания
            //получить массив слов из текста
            string[] arrayWords = CheckTextAndSplitOnWords(text);

            //очищаем временный словарь
            dictionery.Clear();

            //составляем словарь с частотами
            CreatDictionaryWordsAndFrequencies(arrayWords, dictionery);

            //добавление в бд
            foreach (KeyValuePair <string, int> word in dictionery)
            {
                if (LimitForAddToDictionary(word.Key, word.Value))
                {
                    DictionaryWord newWord = new DictionaryWord {/*Id = _repoDictionary.Get().Count()+1,*/
                        Word = word.Key, Frequency = word.Value
                    };
                    _repoDictionary.Create(newWord);
                }
            }
        }
 protected DictionaryWordDTO(DictionaryWord word, string language, IEnumerable <WordInflectionDTO> inflectionDtos)
 {
     Word        = word.Word;
     Language    = language;
     IsNoResult  = false;
     Inflections = inflectionDtos;
 }
예제 #5
0
 public static void SaveWordInDb(DictionaryWord word)
 {
     using var dbConnection = new SqliteConnection("Data Source=" + Path.Combine(Path.GetFullPath(ProcessedWordsFilePath), "Dictionary.db"));
     dbConnection.Open();
     SaveWordInDb(dbConnection, word);
     dbConnection.Close();
 }
예제 #6
0
        public void InsertWordToDictionary()
        {
            using (var db = new DataContext())
            {
                db.Database.Migrate();
                var dictionary = new Dictionary();
                dictionary.Id = "Dic0";
                dictionary.TotalWordsNumber = 0;
                db.Dictionaries.Add(dictionary);
                db.SaveChanges();

                var word1 = new Word {
                    Id = "00test", Translation = "测试"
                };
                var word2 = new Word {
                    Id = "00a", Translation = "一个"
                };

                db.Words.Add(word1);
                db.Words.Add(word2);

                var dicWord = new DictionaryWord {
                    Word = word1, Dictionary = dictionary
                };
                db.DictionaryWords.Add(dicWord);
                db.SaveChanges();
                Assert.AreEqual("一个",
                                db.Words.SingleOrDefault(
                                    m => m.Id.Equals("00a")).Translation
                                );
            }
        }
예제 #7
0
 public DBWord(DictionaryWord dictionaryWord) :
     base(dictionaryWord.EnWord,
          dictionaryWord.RuWord,
          dictionaryWord.Discription,
          dictionaryWord.Latitude,
          dictionaryWord.Longitude)
 {
 }
        [ValidateAntiForgeryToken]//prevents cross-site request forgery attacks
        public IActionResult Results(DictionaryWord obj)
        {
            ViewBag.DictionaryString = GetDefinition(obj.Word.Trim());
            ViewBag.SearchWordDict   = ToTitle(obj.Word.Trim());
            ViewBag.SynList          = synList;

            return(View("Dictionary"));
        }
예제 #9
0
        public void DeleteWord(string wordToDelete)
        {
            // check if ip has searches
            DictionaryWord word = _em.DictionaryWords.Where(w => w.Word == wordToDelete).FirstOrDefault();

            _em.DictionaryWords.Remove(word);
            _em.SaveChanges();
        }
예제 #10
0
        public void AddWord(string input)
        {
            DictionaryWord word = new DictionaryWord();

            word.Word = input;

            _em.DictionaryWords.Add(word);
            _em.SaveChanges();
        }
예제 #11
0
        public static void GroupWordByLength(DictionaryWord word)
        {
            var fullWord = word.FullWord;

            if (fullWord.Length >= Constants.MinimumWordLength && fullWord.Length <= Math.Max(Board.Board.Rows, Board.Board.Columns))
            {
                WordsByLength[fullWord.Length].Add(fullWord);
            }
        }
예제 #12
0
        public async Task AddWordToDictionary_GetWithExampleReturnsSame()
        {
            MongoTestHelper.DropAllCollections();
            var dictionaryRepo = new DictionaryRepo(MongoTestHelper.Database);
            var examplesRepo   = new ExamplesRepo(MongoTestHelper.Database);
            var service        = new DictionaryService(dictionaryRepo, examplesRepo);
            var example        = new Example
            {
                Direction        = TranlationDirection.EnRu,
                Id               = ObjectId.GenerateNewId(),
                OriginWord       = "table",
                TranslatedWord   = "стол",
                OriginPhrase     = "What the table?",
                TranslatedPhrase = "Какого стола?"
            };
            var word = new DictionaryWord
            {
                Id            = ObjectId.GenerateNewId(),
                Word          = "table",
                Language      = Language.En,
                Source        = TranslationSource.Yadic,
                Transcription = "qweqwe",
                Translations  = new[]
                {
                    new DictionaryTranslation
                    {
                        Word     = "Стол",
                        Language = Language.Ru,
                        Examples = new []
                        {
                            new DictionaryReferenceToExample()
                            {
                                ExampleId     = example.Id,
                                ExampleOrNull = example,
                            }
                        }
                    }
                }
            };
            await service.AddNewWord(word);

            var translations = await service.GetTranslationsWithExamples("table");

            Assert.AreEqual(1, translations.Count);
            var translation = translations[0];

            Assert.AreEqual(word.Source, translation.Source);
            Assert.AreEqual(word.Transcription, translation.EnTranscription);
            Assert.AreEqual(word.Word, translation.EnWord);
            Assert.AreEqual(word.Translations[0].Word, translation.RuWord);

            Assert.AreEqual(example.OriginWord, translation.Examples[0].OriginWord);
            Assert.AreEqual(example.OriginPhrase, translation.Examples[0].OriginPhrase);
            Assert.AreEqual(example.TranslatedWord, translation.Examples[0].TranslatedWord);
            Assert.AreEqual(example.TranslatedPhrase, translation.Examples[0].TranslatedPhrase);
        }
예제 #13
0
        public async Task AddNewWord(DictionaryWord word)
        {
            var allExamples = word.Translations
                              .SelectMany(t => t.Examples)
                              .Select(e => e.ExampleOrNull)
                              .Where(e => e != null);
            await _exampleRepository.Add(allExamples);

            await _dicRepository.Add(word);
        }
예제 #14
0
        public async Task AddWordToDictionary(Word word, Dictionary dictionary)
        {
            var item = new DictionaryWord
            {
                WordId       = word.Id,
                DictionaryId = dictionary.Id
            };

            await _context.DictionaryWords.AddAsync(item);
        }
예제 #15
0
        private static bool RemoveWord(DictionaryWord word)
        {
            bool removed = PendingWords.Remove(word);

            removed |= InvalidLengthWords.Remove(word);
            removed |= InvalidCharactersWords.Remove(word);
            removed |= InvalidMiscWords.Remove(word);
            removed |= ApprovedWords.Remove(word);
            return(removed);
        }
예제 #16
0
        public bool EditWord(string originalWord, string newWord)
        {
            if (_em.DictionaryWords.Where(w => w.Word == newWord).Count() > 0)
            {
                return(false);
            }

            DictionaryWord word = _em.DictionaryWords.Where(w => w.Word == originalWord).Select(x => x).FirstOrDefault();

            word.Word = newWord;
            _em.SaveChanges();

            return(true);
        }
예제 #17
0
        public static void LoadWordsFromDb()
        {
            PendingWords.Clear();
            InvalidLengthWords.Clear();
            InvalidCharactersWords.Clear();
            InvalidMiscWords.Clear();
            ApprovedWords.Clear();
            WordsByLength.Clear();

            using var dbConnection = new SqliteConnection("Data Source=" + Path.Combine(Path.GetFullPath(ProcessedWordsFilePath), "Dictionary.db"));
            dbConnection.Open();
            var command = dbConnection.CreateCommand();

            command.CommandText = "CREATE TABLE IF NOT EXISTS Words (Prefix TEXT NOT NULL, Root TEXT NOT NULL, Suffix TEXT NOT NULL, Ending TEXT NOT NULL, DefiniteArticle TEXT NOT NULL, IsApproved INTEGER, " +
                                  "PRIMARY KEY (Prefix, Root, Suffix, Ending, DefiniteArticle)) WITHOUT ROWID";
            command.ExecuteNonQuery();

            command.CommandText = "SELECT iif(Prefix IS NULL, \"\", Prefix), " +
                                  "iif(Root IS NULL, \"\", Root), " +
                                  "iif(Suffix IS NULL, \"\", Suffix), " +
                                  "iif(Ending IS NULL, \"\", Ending), " +
                                  "iif(DefiniteArticle IS NULL, \"\", DefiniteArticle), " +
                                  "IsApproved " +
                                  "FROM Words";
            var reader = command.ExecuteReader();

            while (reader.Read())
            {
                var word = new DictionaryWord();
                word.Prefixes        = new List <string>(((string)reader[0]).Split('-', StringSplitOptions.RemoveEmptyEntries));
                word.Root            = (string)reader[1];
                word.Suffixes        = new List <string>(((string)reader[2]).Split('-', StringSplitOptions.RemoveEmptyEntries));
                word.Ending          = (string)reader[3];
                word.DefiniteArticle = (string)reader[4];

                //MessageBox.Show(reader[5].ToString());
                if (reader[5] == DBNull.Value || (long?)reader[5] == null)
                {
                    PendingWords.Add(word);
                }
                else if ((long?)reader[5] == 1)
                {
                    ApprovedWords.Add(word);
                }
            }

            GroupWordsByLength();
        }
 /// <summary>
 /// 插入一个单词到单词本。
 /// 已经存在 返回0
 /// 插入失败 返回-1
 /// 插入成功 返回1
 /// 词典不存在 返回2
 /// </summary>
 public static int InsertAVocabularyToCustomDictionary(string customDictionaryName, Vocabulary vocabulary)
 {
     using (var db = new DataContext())
     {
         db.Database.Migrate();
         var dictionary = db.Dictionaries.Find(customDictionaryName);
         if (dictionary == null)
         {
             return(2);                   //如果词典不存在,就返回-1
         }
         if (db.Words.Find(vocabulary.Word) == null)
         {
             db.Words.Add(VocabularyToWord(vocabulary));  //添加一个单词
         }
         //无论原来单词是否存在,都在wordDictionary关系表中建立一个条目
         var Selectedword = db.DictionaryWords
                            .Where(dw => dw.WordId.Equals(vocabulary.Word))
                            .Where(dw => dw.DictionaryId.Equals(customDictionaryName))
                            .Count();
         if (Selectedword == 0)//如果词典中不存在这个条目
         {
             DictionaryWord dictionaryWord = new DictionaryWord();
             dictionaryWord.Word       = VocabularyToWord(vocabulary);
             dictionaryWord.Dictionary = new Dictionary
             {
                 Id = customDictionaryName,
                 TotalWordsNumber = 0
             };
             db.DictionaryWords.Add(dictionaryWord);
             db.SaveChanges();
             db.Database.CloseConnection();
             foreach (var dics in WordBook.Custom)
             {
                 if (dics.Name.Equals(customDictionaryName))
                 {
                     dics.Wordlist.Add(vocabulary.Word, vocabulary);
                 }
             }
             return(1);
         }
         else
         {
             return(0);
         }
     }
 }
예제 #19
0
        /// <summary>
        /// Модификация существующего словаря.
        /// </summary>
        /// <param name="text">Текст со словами.</param>
        public override void UpdateDictionary(string text)
        {
            // Словарь слов и их частот.
            Dictionary <string, int> dictionery = new Dictionary <string, int>();

            //проверка текста на пустоту
            //из текста удалить все знаки препинания
            //получить массив слов из текста
            string[] arrayWords = CheckTextAndSplitOnWords(text);

            //очищаем временный (промежуточный) словарь
            dictionery.Clear();

            //составляем словарь с частотами
            CreatDictionaryWordsAndFrequencies(arrayWords, dictionery);

            //Слово в базе данных
            IEnumerable <DictionaryWord> wordInDB;

            foreach (KeyValuePair <string, int> word in dictionery)
            {
                //проверка на несколько значений в бд и выдать исключение
                wordInDB = _repoDictionary.Get(x => x.Word == word.Key);

                if (LimitForAddToDictionary(word.Key, word.Value))
                {
                    if (wordInDB.Any())
                    {
                        //Обновляем в базе существующее слово

                        DictionaryWord specificWord = wordInDB.FirstOrDefault();
                        specificWord.Frequency += word.Value;
                        _repoDictionary.Update(specificWord);
                    }
                    else
                    {
                        //Создаем в базе новое слово
                        DictionaryWord newWord = new DictionaryWord {
                            Word = word.Key, Frequency = word.Value
                        };
                        _repoDictionary.Create(newWord);
                    }
                }
            }
        }
예제 #20
0
        private void WordList_StylesApplied(Grid <DictionaryWord> .Row row, DictionaryWord word)
        {
            foreach (Grid <DictionaryWord> .Cell cell in row.Controls)
            {
                if (cell.Index == 0)
                {
                    cell.ForeColor = word?.IsApproved switch
                    {
                        true => Constants.Colors.FontGreen,
                        false => Constants.Colors.FontRed,
                        null => (row.Parent as Grid <DictionaryWord>).DefaultForeColor
                    };

                    switch (word?.IsApproved)
                    {
                    case true:
                        cell.Invoke((MethodInvoker) delegate
                        {
                            cell.ForeColor = Constants.Colors.FontGreen;
                            this.ToolTip.SetToolTip(cell, "Валидна");
                        });
                        break;

                    case false:
                        cell.Invoke((MethodInvoker) delegate
                        {
                            cell.ForeColor = Constants.Colors.FontRed;
                            ToolTip.SetToolTip(cell, "Невалидна");
                        });
                        break;

                    default:
                        cell.Invoke((MethodInvoker) delegate
                        {
                            cell.ForeColor = (row.Parent as Grid <DictionaryWord>).DefaultForeColor;
                            ToolTip.SetToolTip(cell, null);
                        });
                        break;
                    }

                    return;
                }
            }
        }
예제 #21
0
        public static void SaveWordInDb(SqliteConnection dbConnection, DictionaryWord word)
        {
            try
            {
                var command = dbConnection.CreateCommand();
                command.CommandText = "INSERT INTO Words(Prefix, Root, Suffix, Ending, DefiniteArticle, IsApproved) VALUES(@Prefix, @Root, @Suffix, @Ending, @DefiniteArticle, @IsApproved)";
                command.Parameters.AddWithValue("@Prefix", string.Join('-', word.Prefixes));
                command.Parameters.AddWithValue("@Root", word.Root);
                command.Parameters.AddWithValue("@Suffix", string.Join('-', word.Suffixes));
                command.Parameters.AddWithValue("@Ending", word.Ending);
                command.Parameters.AddWithValue("@DefiniteArticle", word.DefiniteArticle);

                if (word.IsApproved == null)
                {
                    command.Parameters.AddWithValue("@IsApproved", DBNull.Value);
                }
                else if (word.IsApproved == false)
                {
                    command.Parameters.AddWithValue("@IsApproved", "0");
                }
                else if (word.IsApproved == true)
                {
                    command.Parameters.AddWithValue("@IsApproved", "1");
                }

                command.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                if (e.Message.StartsWith("SQLite Error 19:"))
                {
                    MessageBox.Show($"Думата {word.FullWord} вече съществува.");
                }
                else
                {
                    MessageBox.Show($"Грешка при добавяне на думата {word.FullWord} - {e.Message} | {e.InnerException?.Message}");
                }
            }
        }
예제 #22
0
 public static void SetAsPending(this DictionaryWord word)
 {
     RemoveWord(word);
     PendingWords.Add(word);
     word.IsApproved = null;
 }
예제 #23
0
 public static void Reject(this DictionaryWord word)
 {
     RemoveWord(word);
     InvalidMiscWords.Add(word);
     word.IsApproved = false;
 }
예제 #24
0
        public DictionaryWordPrompt(DictionaryWord word = null, bool advanced = true)
        {
            this.Word         = word ?? new DictionaryWord();
            this.originalWord = this.Word.FullWord;

            this.StartPosition = FormStartPosition.CenterParent;

            this.PrefixTextBox = new TextBox()
            {
                Text            = string.Join(null, this.Word.Prefixes),
                Top             = Constants.Padding.Top / 2,
                Left            = Constants.Padding.Left / 2,
                TextAlign       = HorizontalAlignment.Right,
                PlaceholderText = "представки",
                Visible         = advanced,
            };
            if (!advanced)
            {
                this.PrefixTextBox.Width = 0;
            }
            this.PrefixTextBox.Width        = (int)(this.PrefixTextBox.Width * 1.5);
            this.PrefixTextBox.TextChanged += (sender, args) =>
            {
                this.Word.Prefixes      = this.PrefixTextBox.Text?.ToUpperInvariant().Split('-', StringSplitOptions.RemoveEmptyEntries).ToList();
                this.FullWordLabel.Text = this.Word.FullWord;
            };
            this.Controls.Add(this.PrefixTextBox);

            this.RootTextBox = new TextBox()
            {
                Text            = this.Word.Root,
                Top             = this.PrefixTextBox.Top,
                Left            = advanced ? this.PrefixTextBox.Right : Constants.Padding.Left / 2,
                TextAlign       = HorizontalAlignment.Center,
                PlaceholderText = advanced ? "корен" : "дума..."
            };
            this.RootTextBox.Width        = advanced ? this.RootTextBox.Width : (int)(this.RootTextBox.Width * 5.5);
            this.RootTextBox.TextChanged += (sender, args) =>
            {
                this.Word.Root          = this.RootTextBox.Text.ToUpperInvariant();
                this.FullWordLabel.Text = this.Word.FullWord;
            };
            this.Controls.Add(this.RootTextBox);

            this.SuffixTextBox = new TextBox()
            {
                Text            = string.Join(null, this.Word.Suffixes),
                Top             = this.PrefixTextBox.Top,
                Left            = this.RootTextBox.Right,
                TextAlign       = HorizontalAlignment.Left,
                PlaceholderText = "наставки",
                Visible         = advanced
            };
            if (!advanced)
            {
                this.SuffixTextBox.Width = 0;
            }
            this.SuffixTextBox.TextChanged += (sender, args) =>
            {
                this.Word.Suffixes      = this.SuffixTextBox.Text?.ToUpperInvariant().Split('-', StringSplitOptions.RemoveEmptyEntries).ToList();
                this.FullWordLabel.Text = this.Word.FullWord;
            };
            this.Controls.Add(this.SuffixTextBox);

            this.EndingTextBox = new TextBox()
            {
                Text            = this.Word.Ending,
                Top             = this.PrefixTextBox.Top,
                Left            = this.SuffixTextBox.Right,
                TextAlign       = HorizontalAlignment.Left,
                PlaceholderText = "окончание",
                Visible         = advanced
            };
            if (!advanced)
            {
                this.EndingTextBox.Width = 0;
            }
            this.EndingTextBox.TextChanged += (sender, args) =>
            {
                this.Word.Ending        = this.EndingTextBox.Text?.ToUpperInvariant();
                this.FullWordLabel.Text = this.Word.FullWord;
            };
            this.Controls.Add(this.EndingTextBox);

            this.DefiniteArticleTextBox = new TextBox()
            {
                Text            = this.Word.DefiniteArticle,
                Top             = this.PrefixTextBox.Top,
                Left            = this.EndingTextBox.Right,
                TextAlign       = HorizontalAlignment.Left,
                PlaceholderText = "опр. член",
                Visible         = advanced
            };
            if (!advanced)
            {
                this.DefiniteArticleTextBox.Width = 0;
            }
            this.DefiniteArticleTextBox.TextChanged += (sender, args) =>
            {
                this.Word.DefiniteArticle = this.DefiniteArticleTextBox.Text?.ToUpperInvariant();
                this.FullWordLabel.Text   = this.Word.FullWord;
            };
            this.Controls.Add(this.DefiniteArticleTextBox);

            this.FullWordLabel = new Label()
            {
                Top       = this.PrefixTextBox.Bottom,
                Height    = this.Font.Height + 6,
                Width     = this.DefiniteArticleTextBox.Right + Constants.Padding.Right / 2,
                TextAlign = ContentAlignment.MiddleCenter,
                Text      = this.Word.FullWord
            };
            this.Controls.Add(this.FullWordLabel);

            var acceptButton = new Button()
            {
                Text         = "Запази",
                Top          = this.FullWordLabel.Bottom,
                Left         = this.FullWordLabel.Width / 16 * 3,
                Width        = this.FullWordLabel.Width / 4,
                Height       = this.PrefixTextBox.Height,
                DialogResult = DialogResult.OK
            };

            acceptButton.Click += AcceptButton_Click;
            this.Controls.Add(acceptButton);

            var cancelButton = new Button()
            {
                Text         = "Откажи",
                Top          = this.FullWordLabel.Bottom,
                Left         = this.FullWordLabel.Width / 16 * 9,
                Width        = this.FullWordLabel.Width / 4,
                Height       = this.PrefixTextBox.Height,
                DialogResult = DialogResult.Cancel
            };

            this.Controls.Add(cancelButton);

            this.ClientSize = new Size(this.FullWordLabel.Width, acceptButton.Bottom + Constants.Padding.Bottom / 2);
        }
예제 #25
0
        async Task <bool> HandleWordButton(Update update, PaginationCollection <WordInLearningSet> selector)
        {
            if (selector.Count == 0)
            {
                await Chat.ConfirmCallback(update.CallbackQuery.Id);

                return(false);
            }

            var moveResult = false;

            if (update.CallbackQuery.Data == selectLearningSetData)
            {
                await AddWordToUser(selector.Current);

                //Todo почему то не работает
                await Chat.AnswerCallbackQueryWithTooltip(
                    update.CallbackQuery.Id, Chat.Texts.WordIsAddedForLearning(selector.Current.Word));

                moveResult = await MoveOnNextWord(selector, true);
            }
            else if (update.CallbackQuery.Data == moveNextData)
            {
                await Chat.AnswerCallbackQueryWithTooltip(
                    update.CallbackQuery.Id, Chat.Texts.WordIsSkippedForLearning(selector.Current.Word));

                moveResult = await MoveOnNextWord(selector, true);
            }
            else
            {
                await Chat.ConfirmCallback(update.CallbackQuery.Id);
            }

            DictionaryWord word = null;
            IReadOnlyList <Translation> translations = null;

            while (word == null)
            {
                if (!moveResult)
                {
                    await SendAllWordsAreLearnedMessage(update.CallbackQuery.Message.MessageId);

                    return(false);
                }

                (word, translations) =
                    await _localDictionaryService.GetTranslationWithExamplesByEnWord(selector.Current.Word);

                if (word == null)
                {
                    moveResult = await MoveOnNextWord(selector, true);
                }
            }

            await Chat.EditMessageTextMarkdown(
                update.CallbackQuery.Message.MessageId,
                GetWordText(selector, word, translations, selector.Current),
                GetWordKeyboard());

            return(true);
        }
예제 #26
0
 public PreviewCrosswordWord(DictionaryWord dictionaryWord, CrosswordWordPosition position)
     : base(null, dictionaryWord, position)
 {
 }
예제 #27
0
 public DictionaryItem(string original_word, int hieroglyph_number)
 {
     this.original = original_word;
     word          = new DictionaryWord(hieroglyph_number);
 }
예제 #28
0
 public bool IsWordEmpty() => !DictionaryWord.Any();
예제 #29
0
 public static void AddWord(DictionaryWord word)
 {
     PendingWords.Add(word);
 }
예제 #30
0
 public static void Approve(this DictionaryWord word)
 {
     RemoveWord(word);
     ApprovedWords.Add(word);
     word.IsApproved = true;
 }
예제 #31
0
 public bool IsMatch(DictionaryWord dictionaryWord)
 {
     string word = dictionaryWord.Word.ToLower();
     return _IsMatch(_mask, word);
 }