Пример #1
0
        public void AddDuplicatePrimary()
        {
            Words words = new Words();

            words.Add("x", "y");
            Action act = () => words.Add("x", "z");

            act.Should().Throw <InvalidOperationException>().WithMessage("Primary 'x' already exists.");
            words["z"].Primary.Should().BeEmpty();
        }
Пример #2
0
        public void AddASingleWordMultipleTimes()
        {
#pragma warning disable IDE0028 // Simplify collection initialization
            // ReSharper disable once UseObjectOrCollectionInitializer
            var words = new Words( );
#pragma warning restore IDE0028 // Simplify collection initialization
            words.Add(new Word("a", MaxNumCharactersPerParts));
            words.Add(new Word("a", MaxNumCharactersPerParts));
            words.Add(new Word("b", MaxNumCharactersPerParts));
            words.Add(new Word("a", MaxNumCharactersPerParts));
            Assert.That(words.Count == 2);
            Assert.AreEqual("a", words[0].Value);
            Assert.AreEqual("b", words[1].Value);
        }
Пример #3
0
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            Words.Clear();
            mPractises.Clear();
            mStartTime        = DateTime.Now;
            TotalSeconds      = 0;
            WordCountInMinute = 0;
            Timer.Start();

            UserName = (string)navigationContext.Parameters["UserName"];
            Book     = ((UIBook)navigationContext.Parameters["Book"]).Name;
            Modules  = (string[])navigationContext.Parameters["Modules"];
            var words1 = navigationContext.Parameters["Words"] as List <UIWord>;

            while (words1.Count > 0)
            {
                var dan   = new Random();
                var index = dan.Next(0, words1.Count);
                var item  = words1[index];
                words1.Remove(item);
                Words.Add(item);
            }
            WordView.View.MoveCurrentToFirst();
            PlayWord();
        }
Пример #4
0
 public static void Register(Words words)
 {
     foreach (FieldInfo fi in typeof(Noun).GetFields(BindingFlags.Static | BindingFlags.Public))
     {
         words.Add((Noun)fi.GetValue(null));
     }
 }
Пример #5
0
        private bool _drawing;     // Drawing mode active

        public KinectSwitchJig(
            Document doc, Transaction tr, double profSide, double factor
            )
        {
            // Initialise the various members

            _doc             = doc;
            _tr              = tr;
            _vertices        = new Point3dCollection();
            _lastDrawnVertex = -1;
            _resizing        = false;
            _drawing         = false;
            _created         = new DBObjectCollection();
            _profSide        = profSide;
            _segFactor       = factor;
            switchm          = 0;

            Words.Add("red");
            Words.Add("green");
            Words.Add("blue");
            Words.Add("yellow");
            Words.Add("pink");
            Words.Add("magenta");
            Words.Add("cyan");
        }
Пример #6
0
        /// <summary>
        /// Assigns words its width and height
        /// </summary>
        /// <param name="g"></param>
        internal void MeasureWordsSize(Graphics g)
        {
            // Check if measure white space if not yet done to measure once
            if (!_wordsSizeMeasured)
            {
                MeasureWordSpacing(g);

                if (HtmlTag != null && HtmlTag.Name == "img")
                {
                    var image = CssValueParser.GetImage(GetAttribute("src"), HtmlContainer.Bridge);
                    var word  = new CssBoxWord(this, image);
                    Words.Clear();
                    Words.Add(word);
                }
                else if (Words.Count > 0)
                {
                    foreach (var boxWord in Words)
                    {
                        var sf = new StringFormat();
                        sf.SetMeasurableCharacterRanges(new[] { new CharacterRange(0, boxWord.Text.Length) });

                        var regions = g.MeasureCharacterRanges(boxWord.Text, ActualFont, new RectangleF(0, 0, float.MaxValue, float.MaxValue), sf);

                        SizeF  s = regions[0].GetBounds(g).Size;
                        PointF p = regions[0].GetBounds(g).Location;

                        boxWord.LastMeasureOffset = new PointF(p.X, p.Y);
                        boxWord.Width             = s.Width + ActualWordSpacing;
                        boxWord.Height            = s.Height;
                    }
                }
                _wordsSizeMeasured = true;
            }
        }
Пример #7
0
 /// <summary>
 ///     追加字符
 /// </summary>
 /// <param name="word">基本单词</param>
 public void Append(WordUnit word)
 {
     if (!word.IsReplenish)
     {
         if (Line < 0)
         {
             Line = word.Line;
         }
         if (Column < 0)
         {
             Column = word.Column;
         }
         if (Start < 0)
         {
             Start = word.Start;
         }
         End = word.End;
     }
     if (word.IsPunctuate)
     {
         IsPunctuate = true;
         if (word.IsSpace)
         {
             ItemRace   = CodeItemRace.Assist;
             ItemFamily = CodeItemFamily.Space;
             if (word.IsLine)
             {
                 ItemType = CodeItemType.Line;
             }
         }
     }
     CharAppenBuilder.Append(word.Word);
     Words.Add(word);
 }
Пример #8
0
        async Task ExecuteRefreshCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            try
            {
                var words = topic.Words;
                Words.Clear();

                foreach (var word in words)
                {
                    Words.Add(word);
                }
            }
            catch (Exception ex)
            {
                //Acr.UserDialogs.UserDialogs.Instance.ShowError(ex.Message);
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #9
0
        private string ReadWord(bool isFirstWord = false)
        {
            var    i    = 0;
            string word = string.Empty;

            //while (!MatrixHelper.MatrixContainsWordEnd(GameFieldToLines.ToList()))
            while (true)
            {
                var letter = LetterHelper.GetLetterFromMatrix(GameFieldToLines.ToList());
                word += letter;
                if (MatrixHelper.MatrixContainsWordEnd(GetWidedMatrixToRight()))
                {
                    MoveToRight(2);
                    break;
                }
                MoveToRight(8);
            }
            if (isFirstWord)
            {
                FirstWordWasDetected = word;
            }

            if (String.IsNullOrEmpty(FirstWordInRow))
            {
                FirstWordInRow = word;
            }
            if (Words.Take(5).ToList().Contains(word))
            {
                FirstWordInRow = String.Empty;
                MoveToDown(10);
                return(word);
            }
            Words.Add(word);
            return(word);
        }
Пример #10
0
        private static Words GetWordsMatchingString(List <Word> words, string fullText, string SearchString)
        {
            if (!fullText.Contains(SearchString))
            {
                return(null);
            }
            int   StartIndex    = fullText.IndexOf(SearchString);
            int   CheckedLength = 0;
            Words Ret           = new Words();

            Ret.Tag = SearchString;
            for (int i = 0; i < words.Count; i++)
            {
                CheckedLength += words[i].Text.Length;
                if (CheckedLength > StartIndex)
                {
                    if (StartIndex + SearchString.Length > CheckedLength - words[i].Text.Length)
                    {
                        Ret.Add(words[i]);
                    }
                    else
                    {
                        break;
                    }
                }
            }
            return(Ret);
        }
Пример #11
0
 public void Add(Word Word)
 {
     if (Word.Length > 0)
     {
         Words.Add(Word);
     }
 }
Пример #12
0
 private void CopyWord()
 {
     if (SelectedWord != null)
     {
         Words.Add(new Word(SelectedWord));
     }
 }
Пример #13
0
        async Task ExecuteLoadGamesCommand()
        {
            IsBusy = true;

            try
            {
                Words.Clear();
                var g = new Dictionary <string, PlayerWords>(await DataStore.GetItemsAsync(true)).Select(e => e.Value).ToList <PlayerWords>();

                foreach (var gs in g)
                {
                    if (gs.Guessed.Count() == 0 && gs.NotGuessed.Count() == 0)
                    {
                        continue;
                    }
                    Words.Add(gs);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        public void PlaceSolution(string theme, string hiddenWord)
        {
            Solution = hiddenWord;
            List <string> themeWords = _repository.GetRelatedWordsForTheme(theme);

            if (Shuffle)
            {
                themeWords.Shuffle();
            }
            foreach (char letter in hiddenWord)
            {
                foreach (string puzzleCandidate in themeWords)
                {
                    if (!puzzleCandidate.Contains(letter.ToString()))
                    {
                        continue;
                    }
                    if (puzzleCandidate.Contains(hiddenWord))
                    {
                        continue;                                       //Don't include any part of the hidden word.
                    }
                    if (Words.Contains(puzzleCandidate))
                    {
                        continue;                                  //don't repeat any words.
                    }
                    Words.Add(puzzleCandidate);
                    break;
                }
            }
        }
Пример #15
0
        public void CheckSpelling(string content)
        {
            if (box.IsSpellCheckEnabled)
            {
                ClearLists();

                var matches = Regex.Matches(content, @"\w+[^\s]*\w+|\w");

                foreach (Match match in matches)
                {
                    Words.Add(new Word(match.Value.Trim(), match.Index));
                }

                foreach (var word in Words)
                {
                    bool isIgnored = IgnoredWords.Contains(word);
                    if (!isIgnored)
                    {
                        bool exists = hunSpell.Spell(word.Text);
                        if (exists)
                        {
                            IgnoredWords.Add(word);
                        }
                        else
                        {
                            MisspelledWords.Add(word);
                        }
                    }
                }

                OnPropertyChanged("MisspelledWords");
                OnPropertyChanged("IgnoredWords");
            }
        }
Пример #16
0
        public static void DownloadAll()
        {
            var dataReader = DatabaseConnection.Execute("Select * from Word").ExecuteReader();

            while (dataReader.Read())
            {
                var word = new Word
                           (
                    dataReader.GetInt32(0),
                    dataReader.GetString(1),
                    dataReader.GetString(2),
                    dataReader.GetInt32(5),
                    dataReader.GetInt32(3),
                    dataReader.GetInt32(4)
                           );

                Words.Add(word);
            }

            dataReader.Close();

            dataReader = DatabaseConnection.Execute("Select * from CATEGORY").ExecuteReader();

            while (dataReader.Read())
            {
                var category = new Category
                {
                    Id   = dataReader.GetInt32(0),
                    Name = dataReader.GetString(1),
                };
                Categories.Add(category);
            }

            dataReader.Close();
        }
Пример #17
0
        public void Read(WorldPacket data)
        {
            MinLevel    = data.ReadInt32();
            MaxLevel    = data.ReadInt32();
            RaceFilter  = data.ReadInt64();
            ClassFilter = data.ReadInt32();

            uint nameLength                  = data.ReadBits <uint>(6);
            uint virtualRealmNameLength      = data.ReadBits <uint>(9);
            uint guildNameLength             = data.ReadBits <uint>(7);
            uint guildVirtualRealmNameLength = data.ReadBits <uint>(9);
            uint wordsCount                  = data.ReadBits <uint>(3);

            ShowEnemies         = data.HasBit();
            ShowArenaPlayers    = data.HasBit();
            ExactName           = data.HasBit();
            ServerInfo.HasValue = data.HasBit();
            data.ResetBitPos();

            for (int i = 0; i < wordsCount; ++i)
            {
                Words.Add(data.ReadString(data.ReadBits <uint>(7)));
                data.ResetBitPos();
            }

            Name                  = data.ReadString(nameLength);
            VirtualRealmName      = data.ReadString(virtualRealmNameLength);
            Guild                 = data.ReadString(guildNameLength);
            GuildVirtualRealmName = data.ReadString(guildVirtualRealmNameLength);

            if (ServerInfo.HasValue)
            {
                ServerInfo.Value.Read(data);
            }
        }
Пример #18
0
        private void MergeDictionary(object sender, RoutedEventArgs e)
        {
            var dlg = new OpenFileDialog
            {
                FileName        = "Dictionary.dic",
                DefaultExt      = "dic",
                Filter          = "Wörterbücher|*.dic",
                CheckFileExists = true
            };

            if (dlg.ShowDialog() == true)
            {
                using (var reader = new StreamReader(dlg.FileName, Encoding.Unicode))
                {
                    string readLine;
                    while ((readLine = reader.ReadLine()) != null)
                    {
                        var firstOrDefault = Words.FirstOrDefault(elem => elem.Value.Equals(readLine));

                        if (firstOrDefault != null)
                        {
                            firstOrDefault.IsForDeletion = false;
                            continue;
                        }
                        Words.Add(new DictionaryItem {
                            Value = readLine
                        });
                    }
                }
            }
        }
        public void LoadViewModel(string username, string bookFilename, string unitID)
        {
            Book book = VTrainerModule.Default.BookController.GetBook(username, bookFilename);

            this.BookFilename      = bookFilename;
            this.BookImageFilePath = Path.Combine(VTrainerModule.Default.RootPath, VTrainerModule.Default.BookPath, bookFilename + ".png");
            this.BookCaption       = book?.Caption;
            this.Username          = username;
            this.UnitID            = unitID;
            this.Lang1             = book.GetLang1FullCaption();
            this.Lang2             = book.GetLang2FullCaption();

            Words.Clear();
            IEnumerable <Word> words = VTrainerModule.Default.WordController.GetWords(username, bookFilename, unitID);

            if (words == null)
            {
                return;
            }
            foreach (Word word in words)
            {
                LearningWordListPageItemViewModel vm = new LearningWordListPageItemViewModel();
                vm.LoadViewModel(word);
                Words.Add(vm);
            }
        }
Пример #20
0
        /// <summary>
        /// Init.
        /// </summary>
        /// <param name="parent">the parent box of this box</param>
        /// <param name="tag">the html tag data of this box</param>
        public CssBoxFrame(CssBox parent, HtmlTag tag)
            : base(parent, tag)
        {
            _imageWord = new CssRectImage(this);
            Words.Add(_imageWord);

            Uri uri;

            if (Uri.TryCreate(GetAttribute("src"), UriKind.Absolute, out uri))
            {
                if (uri.Host.IndexOf("youtube.com", StringComparison.InvariantCultureIgnoreCase) > -1)
                {
                    _isVideo = true;
                    LoadYoutubeDataAsync(uri);
                }
                else if (uri.Host.IndexOf("vimeo.com", StringComparison.InvariantCultureIgnoreCase) > -1)
                {
                    _isVideo = true;
                    LoadVimeoDataAsync(uri);
                }
            }

            if (!_isVideo)
            {
                SetErrorBorder();
            }
        }
        // put words in tiles
        private bool PlaceWordsInTiles(int maxWordLength, int totalWords)
        {
            bool bOK = true;

            try
            {
                // load words database
                //var wordDb = new WordDatabase();
                //bOK = wordDb.LoadWordsDB(difficulty);
                Debug.Assert(bOK);
                if (!bOK)
                {
                    return(false);
                }
                int count      = 0;
                int tries      = 0;
                var filterList = new List <string>();
                var listado    = App.Database.GetPalabra(App.LeccionSeleccionada.IdLeccion);
                var listado2   = listado.Palabras.Split(',');
                while (count < totalWords && tries < App.MAX_RANDOM_TRIES)
                {
                    string text = listado2[count].ToLower();
                    //bOK = wordDb.GetNextRandomWord(maxWordLength, filterList, out text);
                    Debug.Assert(bOK); //bOK = true;
                    if (bOK)
                    {
                        // create word object
                        Word word = new Word(text);
                        // select a random direction and position
                        bOK = SelectRandomPose(ref word);
                        Debug.Assert(bOK);
                        if (bOK)
                        {
                            bOK = word.CalculateTilePositions();
                            Debug.Assert(bOK);
                            if (bOK)
                            {
                                // found next word that fits ok
                                filterList.Add(text);
                                Debug.WriteLine($"PlaceWordsInTiles adding word {text}");
                                lock (WordsLock)
                                {
                                    Words.Add(word);
                                }
                                count++;
                                tries = 0;
                            }
                        }
                    }
                    tries++;
                }
            }
            catch (Exception ex)
            {
                //Logger.Instance.Error($"PlaceWordsInTiles exception, {ex.Message}");
                bOK = false;
            }
            return(bOK);
        }
Пример #22
0
        /// <summary>
        /// Adds word to list
        /// </summary>
        public void AddWord()
        {
            Words.Add(Word);
            Word = null;
            NotifyPropertyChanged(() => Word);

            IsSaveEnabled = true;
        }
        public void SendWordsSynonyms(string input, string output)
        {
            MessageBus               bus        = new MessageBus();
            List <string>            sentences  = new List <string>();
            Action <SentenceMessage> onSentence = m => sentences.Add(m.Verb.Primary + "|" + m.Noun.Primary);

            bus.Subscribe(onSentence);
            Words words = new Words();

            words.Add("look", "see", "inspect", "examine");
            words.Add("house", "home");
            SentenceParser parser = new SentenceParser(bus, words);

            bus.Send(new InputReceivedMessage(input));

            sentences.Should().ContainSingle().Which.Should().Be(output);
        }
Пример #24
0
        public void CreateEmptyListAndAddNull()
        {
            var words = new Words();

            Assert.That(words.Count == 0);
            words.Add((Word)null);
            Assert.That(words.Count == 0);
        }
Пример #25
0
        public void AddNullPrimary()
        {
            Words words = new Words();

            Action act = () => words.Add(null);

            act.Should().Throw <ArgumentNullException>().Which.ParamName.Should().Be("primary");
        }
Пример #26
0
 private void CutWord()
 {
     if (_curword.Text.Length > 0)
     {
         Words.Add(_curword);
     }
     _curword = new CssBoxWord(Box);
 }
Пример #27
0
        private void AddWord(object window)
        {
            var viewModel = new WordViewModel {
                Word = new Word()
            };

            new WordWindow(window, viewModel).ShowDialog();
            Words.Add(viewModel.Word);
        }
Пример #28
0
        public void AddWord(Word word)
        {
            if (word == null)
            {
                throw new ArgumentNullException("The word cannot be null.");
            }

            Words.Add(word);
        }
Пример #29
0
        public void AddASingleWord()
        {
#pragma warning disable IDE0028 // Simplify collection initialization
            // ReSharper disable once UseObjectOrCollectionInitializer
            var words = new Words();
#pragma warning restore IDE0028 // Simplify collection initialization
            words.Add(new Word("a", MaxNumCharactersPerParts));
            Assert.That(words.Count == 1);
        }
Пример #30
0
        public void CreateEmptyListAndAddSingleWord()
        {
            var words = new Words();

            Assert.That(words.Count == 0);
            words.Add(new Word("Test", MaxNumCharactersPerParts));
            Assert.That(words.Count == 1);
            Assert.AreEqual("Test", words[0].Value);
        }