Пример #1
0
 public void checkin(Word._Document activeDocument)
 {
     try
     {
         if (MessageBox.Show(resources.GetString("sure_check_in"), resources.GetString("checkin"), MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK)
         {
             object saveChanges = Word.WdSaveOptions.wdSaveChanges;
             object missing = Type.Missing;
             String localFileName = activeDocument.FullName;
             activeDocument.Close(ref saveChanges, ref missing, ref missing); // Always we save document
             docXML.refresh(); // Refresh document list
             if (docXML.isOpenKMDocument(localFileName))
             {
                 OKMDocument oKMDocument = docXML.getOpenKMDocument(localFileName);
                 docXML.remove(oKMDocument);
                 DocumentLogic.checkin(oKMDocument, configXML.getHost(), configXML.getUser(), configXML.getPassword());
                 if (File.Exists(localFileName))
                 {
                     File.Delete(localFileName);
                 }
             }
         }
     }
     catch (Exception e)
     {
         String errorMsg = "OpenKMWordAddIn - (checkinButton_Click)\n" + e.Message + "\n\n" + e.StackTrace;
         MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
Пример #2
0
 /// <summary>
 /// Analyse password and make suer that all char types set for use are used inside password.
 /// </summary>
 /// <returns type="System.Char[]">Array of chars.</returns>
 public override char[] GetChars(Generator generator, Word password, char[] charsList)
 {
     ValidateInput(generator, password, charsList);
     if (charsList.Length == 0) return charsList;
     Preset p = generator.Preset;
     // How many chars left to generate.
     int leftChars = p.PasswordLength - password.Chars.Length;
     bool haveUppercase = p.UseUppercase && password.Chars.Intersect(p.CharsUppercase).Count() > 0;
     bool haveLowercase = p.UseLowercase && password.Chars.Intersect(p.CharsLowercase).Count() > 0;
     bool haveNumbers = p.UseNumbers && password.Chars.Intersect(p.CharsNumbers).Count() > 0;
     bool haveSymbols = p.UseSymbols && password.Chars.Intersect(p.CharsSymbols).Count() > 0;
     bool haveExtra = p.UseExtra && p.CharsExtra.Length > 0 && password.Chars.Intersect(p.CharsExtra).Count() > 0;
     // How many char types are not used yet.
     int tc = 0;
     if (p.UseUppercase && !haveUppercase) tc++;
     if (p.UseLowercase && !haveLowercase) tc++;
     if (p.UseNumbers && !haveNumbers) tc++;
     if (p.UseSymbols && !haveSymbols) tc++;
     if (p.UseExtra && !haveExtra) tc++;
     // if no space for random generation left then...
     if (leftChars == tc)
     {
         Preset preset = generator.Preset.Copy();
         //Disable chars which were used
         if (preset.UseUppercase && haveUppercase) preset.UseUppercase = false;
         if (preset.UseLowercase && haveLowercase) preset.UseLowercase = false;
         if (preset.UseNumbers && haveNumbers) preset.UseNumbers = false;
         if (preset.UseSymbols && haveSymbols) preset.UseSymbols = false;
         if (preset.UseExtra && haveExtra) preset.UseExtra = false;
         // Generate new chars list.
         charsList = preset.GetChars().Intersect(charsList).ToArray();
     }
     ValidateOutput(generator, password, charsList);
     return charsList;
 }
Пример #3
0
 public virtual void ValidateOutput(Generator generator, Word password, char[] chars)
 {
     if (chars.Length == 0)
     {
         password.AppendLog("Error: '{0}' filter removed all chars from list.\r\n", FilterName);
     }
 }
Пример #4
0
    static void Main(string[] args)
    {
        var dictionary = new Dictionary<int, HashSet<Word>>();

        int N = int.Parse(Console.ReadLine());
        for (int i = 0; i < N; i++)
        {
            string W = Console.ReadLine();

            //Filtrera bort alla dict. ord > 7 texten
            if (W.Length <= 7)
            {
                var word = new Word(W, i);

                //Gruppera dict. efter poäng
                HashSet<Word> hashSet;
                if (!dictionary.TryGetValue(word.Value, out hashSet))
                {
                    hashSet = new HashSet<Word>();
                    dictionary.Add(word.Value, hashSet);
                }
                hashSet.Add(word);
            }
        }

        string LETTERS = Console.ReadLine();

        LETTERS = string.Join("", LETTERS.OrderBy(x => x));

        var allUniqueVariants = LETTERS.Variants()
            .Distinct()
            .Select(x => new Word(x, 0))
            .OrderByDescending(x => x.Value)
            .ToArray();

        foreach (var word in allUniqueVariants)
        {
            HashSet<Word> hashSet;
            if (dictionary.TryGetValue(word.Value, out hashSet))
            {
                var found = hashSet.Contains(word);

                if (found)
                {
                    var lookupTable = hashSet.ToLookup(x => x.Chars, x => x);
                    var wordToFind = lookupTable[word.Chars].OrderBy(x => x.Index).First();

                    Console.WriteLine(wordToFind);
                    return;

                }

            }
        }

        // Write an action using Console.WriteLine()
        // To debug: Console.Error.WriteLine("Debug messages...");

        Console.WriteLine("invalid word");
    }
Пример #5
0
 /// <summary>
 /// Analyses last char of password and removes all chars which are located on same phone key.
 /// </summary>
 /// <returns type="System.Char[]">Array of chars.</returns>
 public override char[] GetChars(Generator generator, Word password, char[] charsList)
 {
     ValidateInput(generator, password, charsList);
     if (charsList.Length == 0) return charsList;
     // Keep only letters and numbers.
     var chars = charsList.Intersect(charsets.Chars["Letnums"]);
     // Limit if this is second+ letter only.
     if (password.Chars.Length > 0)
     {
         // Get last char.
         var lastChar = password.Chars.Last();
         // Route thru GSM Phone keys.
         for (int i = 0; i == 9; i++)
         {
             char[] keys = charsets.Chars["PhoneKey" + i];
             // If current key contains last char of password then...
             if (keys.Contains(lastChar))
             {
                 // Remove all chars located on same key.
                 chars = chars.Intersect(keys);
                 break;
             }
         }
     }
     charsList = chars.ToArray();
     ValidateOutput(generator, password, charsList);
     return charsList;
 }
Пример #6
0
        public new void Load(string card)
        {
            this.Name = card.Substring(0, 4);

            string localNUPU = card.Substring(7, 3);
            this.NUPU = Convert.ToInt32(localNUPU);

            try
            {
                Word newWord;
                for (int i = 10; i <= card.Length - 1; i += 5)
                {
                    if (i == 10)
                    {
                        newWord = new Word { Name = "Delta-s = change in wing area(m2)", Position = EpplerCommon.WordPosition.F1, Format = EpplerCommon.WordFormat.F5p2, Value = Convert.ToSingle(card.Substring(i, 5)) };
                        words.Add(newWord);
                    }
                    else if (i == 15)
                    {
                        newWord = new Word { Name = "Delta-w = change in aircraft mass(kg)", Position = EpplerCommon.WordPosition.F2, Format = EpplerCommon.WordFormat.F5p2, Value = Convert.ToSingle(card.Substring(i, 5)) };
                        words.Add(newWord);
                    }
                    else if (i == 20)
                    {
                        newWord = new Word { Name = "Delta-Ap = change in parasite-drag area(m2)", Position = EpplerCommon.WordPosition.F3, Format = EpplerCommon.WordFormat.F5p2, Value = Convert.ToSingle(card.Substring(i, 5)) };
                        words.Add(newWord);
                    }
                }
            }
            catch (Exception ex)
            {
                //TODO: implement message passing
                //MessageBox.show(ex.Message);
            }
        }
        public override bool IsApplicable(Word input)
        {
            if (!_subrule.RequiredSyntacticFeatureStruct.IsUnifiable(input.SyntacticFeatureStruct))
            {
                if (input.CurrentRuleResults != null)
                    input.CurrentRuleResults[_index] = new Tuple<FailureReason, object>(FailureReason.RequiredSyntacticFeatureStruct, _subrule.RequiredSyntacticFeatureStruct);
                return false;
            }

            MprFeatureGroup group;
            if (_subrule.RequiredMprFeatures.Count > 0 && !_subrule.RequiredMprFeatures.IsMatchRequired(input.MprFeatures, out group))
            {
                if (input.CurrentRuleResults != null)
                    input.CurrentRuleResults[_index] = new Tuple<FailureReason, object>(FailureReason.RequiredMprFeatures, group);
                return false;
            }

            if (_subrule.ExcludedMprFeatures.Count > 0 && !_subrule.ExcludedMprFeatures.IsMatchExcluded(input.MprFeatures, out group))
            {
                if (input.CurrentRuleResults != null)
                    input.CurrentRuleResults[_index] = new Tuple<FailureReason, object>(FailureReason.ExcludedMprFeatures, group);
                return false;
            }

            return true;
        }
        public void LoadWords(Word[] words)
        {
            Array.Sort(words);

            HashTable = new Dictionary<string, List<string>>(words.Length);

            foreach (var word in words)
            {
                for (var i = 1; i <= word.Text.Length; i++)
                {
                    var prefix = word.Text.Substring(0, i);

                    if (HashTable.ContainsKey(prefix))
                    {
                        if (HashTable[prefix].Count < 10)
                        {
                            HashTable[prefix].Add(word.Text);
                        }
                    }
                    else
                    {
                        HashTable[prefix] = new List<string> { word.Text };
                    }
                }
            }
        }
Пример #9
0
 public ActionResult AddFromTranslator(string wordText, string translationsConcated)
 {
     try
     {
         var activeDict = _authService.CurrentAccount.ActiveDictionary;
         var translations = translationsConcated.Split(';');
         string firstTranslation = translations.First();
         var newWord = new Word { Original = wordText, InsertedOn = DateTime.Now };
         try
         {
             var pronounceFile = _translationService.GetPronounceAudioFile(wordText, activeDict.From, "mp3", String.Empty);
             newWord.PronounceAudioFile = pronounceFile;
         }
         catch (TranslatorException)
         {
         }
         activeDict.Words.Add(newWord);
         newWord.Translations = translations.Select(t => new Translation { Value = t }).ToArray();
         _wordRepository.SaveChanges();
         return RedirectToAction("List", new { dictionaryId = activeDict.ID });
     }
     catch (Exception ex)
     {
         LoggingService.Instance.Log.Fatal(String.Format("A fatal error has occurred while adding a new word using an external translator service. The new word is {0}. The error is {1}", wordText, ex));
         return RedirectToAction("Error", "Home");
     }
 }
Пример #10
0
	void Start()
	{
		NextSentence();

		Word[] words = new Word[tests.WordBank.Values.Count];
		int j = 0;
		foreach (Word w in tests.WordBank.Values) {
			words[j] = w;
			j++;
		}

		// scramble the word order

		int num = words.Length;

		// decide a random order to add nouns
		int[] indices = new int[num];
		for (int i = 0; i < num; ++i) indices[i] = i;
		for (int i = 0; i < num - 1; ++i)
		{
			int swp = Random.Range(i, num);
			int tmp = indices[swp];
			indices[swp] = indices[i];
			indices[i] = tmp;
		}

		// add nouns
		for (int i = 0; i < num; ++i)
		{
			CreateNoun(words[indices[i]]);
		}


	}
Пример #11
0
        public void TestGetWord()
        {
            Word word = new Word("test");

            string originalWord = word.GetWord;
            Assert.AreEqual(originalWord, "test");
        }
 public BombedGuessResponseMessage(int scoreYou, int scoreOpponent, Word word, int[] bombs, ePlayer player) {
     this.scoreYou = scoreYou;
     this.scoreOpponent = scoreOpponent;
     this.bombs = bombs;
     this.Word = word;
     this.Player = player;
 }
Пример #13
0
        public Word[] parseWordsFromString(string sourceText)
        {
            //
            //	Convert the string into a list of words
            //
            RawWord[] rawWords = preParser.parseSourceIntoRawWords(sourceText);
            Word[] words = new Word[rawWords.Length];
            int i=0;
            foreach(RawWord r in rawWords) {
                //TODO:	We're just using one word words right now.
                RawWord[] oneWordWord = { r };

                //	Look up the word.  If it isn't there, complain.
                Word word = lookupWordFromRawWords(oneWordWord);
                if (word == null)
                    failBecauseWordNotFound(oneWordWord);

                words[i] = word;	//	Save the word

                //DEBUG:
            //				string readable = words[i].getReadableString();
            //				Console.WriteLine(readable);

                //	Next
                i++;
            }
            return words;
        }
Пример #14
0
        public void TestCheckForLetterMissing()
        {
            Word word = new Word("test");

            bool isLetterFound = word.CheckForLetter('o');
            Assert.IsFalse(isLetterFound);
        }
Пример #15
0
        public ActionResult Create(TestModel model)
        {
            if (model == null) return Json("Error");
            //User.Identity.Name;

            WebExamEntities WordEntities = new WebExamEntities();
            WordPackage wp = new WordPackage();
            wp.UserName = User.Identity.Name;
            wp.Title = model.title;

            //добавляем новую запись в таблицу WordPackage
            WordEntities.WordPackage.Add(wp);
            WordEntities.SaveChanges();

            //получаем id только что добавленного элемента
            int id = (from p in WordEntities.WordPackage
                      where p.UserName == wp.UserName && p.Title == wp.Title
                      orderby p.WordPackageID descending
                      select p.WordPackageID).First();

            //Debug.WriteLine(id);

            foreach (word word in model.word)
            {
                Word w = new Word();
                w.WordPackageID = id;
                w.En = word.en;
                w.Ru = word.ru;
                WordEntities.Word.Add(w);
            }
            WordEntities.SaveChanges();

            return Json("Success");
        }
Пример #16
0
 private Word[] StringToWords(string s)
 {
     if (s == null)
     {
         return null;
     }
     int wordCount = s.Length / 4;
     Word[] words = new Word[wordCount];
     for (int i = 0; i < wordCount; i++)
     {
         words[i] = new Word(s.Substring(i * 4, 4));
     }
     string remaining = s.Substring(s.Length - s.Length % 4);
     if (remaining.Length > 0)
     {
         Word[] allWords = new Word[wordCount + 1];
         words.CopyTo(allWords, 0);
         allWords[allWords.Length - 1] = new Word(remaining);
         return allWords;
     }
     else
     {
         return words;
     }
 }
Пример #17
0
 public virtual string Print(Word word)
 {
     _counter.Increment();
     if (_counter.Value > 1)
         return word.Value + " " + _counter.Value + " times!";
     return word.Value;
 }
Пример #18
0
        public new void Load(string card)
        {
            this.Name = card.Substring(0, 4);

            string localNUPU = card.Substring(7, 3);
            this.NUPU = Convert.ToInt32(localNUPU);

            try
            {
                Word newWord;
                for (int i = 10; i <= card.Length - 1; i += 5)
                {
                    if (i == 10)
                    {
                        newWord = new Word { Name = "YBL, vertical extent of the plot(mm)", Position = EpplerCommon.WordPosition.F1, Format = EpplerCommon.WordFormat.F5p0, Value = Convert.ToSingle(card.Substring(i, 5)) };
                        words.Add(newWord);
                    }
                    else if (i == 15)
                    {
                        newWord = new Word { Name = "RUA, veritcal shift of the chord line(mm)", Position = EpplerCommon.WordPosition.F2, Format = EpplerCommon.WordFormat.F5p0, Value = Convert.ToSingle(card.Substring(i, 5)) };
                        words.Add(newWord);
                    }
                }
            }
            catch (Exception ex)
            {
                //TODO: implement message passing
                //MessageBox.show(ex.Message);
            }
        }
Пример #19
0
 public Conjugation(Word verb, FirstTense firstTense, SecondTense secondTense, Person person)
 {
     this.verb = verb;
     FirstTense = firstTense;
     SecondTense = secondTense;
     Person = person;
 }
Пример #20
0
 public override IEnumerable<Tuple<ShapeNode, ShapeNode>> Apply(Match<Word, ShapeNode> match, Word output)
 {
     FeatureStruct fs = _simpleCtxt.FeatureStruct.DeepClone();
     fs.ReplaceVariables(match.VariableBindings);
     ShapeNode newNode = output.Shape.Add(fs);
     return Tuple.Create((ShapeNode) null, newNode).ToEnumerable();
 }
Пример #21
0
		public void PhonologicalRuleNotUnapplied(IPhonologicalRule rule, int subruleIndex, Word input)
		{
			((XElement) input.CurrentTrace).Add(new XElement("PhonologicalRuleAnalysisTrace",
				CreateHCRuleElement("PhonologicalRule", rule),
				CreateWordElement("Input", input, true),
				CreateWordElement("Output", input, true)));
		}
Пример #22
0
        internal override bool IsWordValid(Morpher morpher, Word word)
        {
            if (!base.IsWordValid(morpher, word))
                return false;

            if (IsBound && word.Allomorphs.Count == 1)
            {
                if (morpher.TraceManager.IsTracing)
                    morpher.TraceManager.ParseFailed(morpher.Language, word, FailureReason.BoundRoot, this, null);
                return false;
            }

            if (StemName != null && !StemName.IsRequiredMatch(word.SyntacticFeatureStruct))
            {
                if (morpher.TraceManager.IsTracing)
                    morpher.TraceManager.ParseFailed(morpher.Language, word, FailureReason.RequiredStemName, this, StemName);
                return false;
            }

            foreach (RootAllomorph otherAllo in ((LexEntry) Morpheme).Allomorphs.Where(a => a != this && a.StemName != null))
            {
                if (!otherAllo.StemName.IsExcludedMatch(word.SyntacticFeatureStruct, StemName))
                {
                    if (morpher.TraceManager.IsTracing)
                        morpher.TraceManager.ParseFailed(morpher.Language, word, FailureReason.ExcludedStemName, this, otherAllo.StemName);
                    return false;
                }
            }

            return true;
        }
Пример #23
0
 private bool IsTimOrPex()
 {
     bool matching = _timpexPredicate.Matches(_counter);
     if (matching)
         _resultWord = _handlerBase.HandleWordBasedOnCounter(_counter);
     return matching;
 }
Пример #24
0
        public void Add(Word verb)
        {
            if (!verb.IsTypeOf(typeof(VerbType)))
            {
                throw new Exception(verb + " is not verb!");
            }

            foreach (WordType type in verb.types)
            {
                if (type is VerbType)
                {
                    VerbType tv = (type as VerbType);

                    tv.table = this;

                    string tense = (tv.tense != null ? tv.tense : "");
                    Person person = (tv.person != null ? tv.person : new Person(0, 0, "", "", ""));

                    if (!this.table.ContainsKey(tv.mood)) this.table.Add(tv.mood, new Dictionary<string, Dictionary<Person, Word>>());
                    if (!this.table[tv.mood].ContainsKey(tense)) this.table[tv.mood].Add(tense, new Dictionary<Person, Word>());

                    this.table[tv.mood][tense].Add(person, verb);

                }
            }
        }
Пример #25
0
 /// <summary>
 /// Analyses type of last char (volve or consonant) and removes all chars of same type.
 /// This creates <volve>,<consonant>,<volve>,<consonant>,... password.
 /// </summary>
 /// <returns type="System.Char[]">Array of chars.</returns>
 public override char[] GetChars(Generator generator, Word password, char[] charsList)
 {
     ValidateInput(generator, password, charsList);
     if (charsList.Length == 0) return charsList;
     // Keep only proper chars (volves and consonants).
     var chars = charsList.Intersect(charsets.Chars["Letters"]);
     // If password already contains some chars then...
     if (password.Chars.Length > 0)
     {
         // If last character is volve then...
         if (charsets.Chars["Volves"].Contains(password.Chars.Last()))
         {
             // Keep only consonants.
             chars = chars.Intersect(charsets.Chars["Consonants"]);
         }
         else
         {
             // Keep only volves.
             chars = chars.Intersect(charsets.Chars["Volves"]);
         }
     }
     charsList = chars.ToArray();
     ValidateOutput(generator, password, charsList);
     return charsList;
 }
Пример #26
0
        private static void DrawWord(Graphics grph, Word word)
        {
            foreach (Character ch in word.CharList)
                DrawChar(grph, ch);

            word.Draw(grph);
        }
Пример #27
0
        public void TestGetHiddenWord()
        {
            Word word = new Word("test");

            string hiddenWord = word.GetHiddenWord;
            Assert.AreEqual(hiddenWord, "_ _ _ _");
        }
Пример #28
0
        public ConjugationTable(Word verbBase)
        {
            this.verbBase = null;
            this.table = new Dictionary<string, Dictionary<string, Dictionary<Person, Word>>>();

            this.setBase(verbBase);
        }
Пример #29
0
 public String Print(Counter counter,Word actualWord)
 {
     _counter = counter;
     if (IsTimOrPex())
         return _simpleWordPrinter.Print(actualWord, _resultWord);
     return _wordAndCountPrinter.Print(_counter, actualWord);
 }
Пример #30
0
 public void AddRange(Word[] list)
 {
     foreach (Word item in list)
     {
         this.Add(item);
     }
 }
Пример #31
0
        /*
         * морфоанализатор::{PartOfSpeechEnum}  PoS-tagger::{PosTaggerOutputType}
         * PartOfSpeechEnum.Adjective	    PosTaggerOutputType.Adjective
         *                              PosTaggerOutputType.AdjectivePronoun
         * PartOfSpeechEnum.Adverb	        PosTaggerOutputType.Adverb
         *                              PosTaggerOutputType.AdverbialPronoun
         * PartOfSpeechEnum.Article	    PosTaggerOutputType.Article
         * PartOfSpeechEnum.Conjunction	PosTaggerOutputType.Conjunction
         * PartOfSpeechEnum.Interjection	PosTaggerOutputType.Interjection
         * PartOfSpeechEnum.Noun	        PosTaggerOutputType.Noun
         * PartOfSpeechEnum.Numeral	    PosTaggerOutputType.Numeral
         * PartOfSpeechEnum.Other	        PosTaggerOutputType.Other
         * PartOfSpeechEnum.Particle	    PosTaggerOutputType.Particle
         * PartOfSpeechEnum.Predicate	    PosTaggerOutputType.Predicate
         * PartOfSpeechEnum.Preposition	PosTaggerOutputType.Preposition
         * PartOfSpeechEnum.Pronoun	    PosTaggerOutputType.Pronoun 
         *                                  PosTaggerOutputType.PossessivePronoun
         *                                  PosTaggerOutputType.AdjectivePronoun  
         *                                  PosTaggerOutputType.AdverbialPronoun
         * PartOfSpeechEnum.Verb	        PosTaggerOutputType.Verb
         *                                  PosTaggerOutputType.Infinitive
         *                                  PosTaggerOutputType.AdverbialParticiple
         *                                  PosTaggerOutputType.AuxiliaryVerb
         *                                  PosTaggerOutputType.Participle
         * -	                            PosTaggerOutputType.Punctuation
         */
        #endregion

        private static void CorrectPosTaggerOutputType(Word word, PartOfSpeechEnum singlePartOfSpeech)
        {
            switch (singlePartOfSpeech)
            {
            case PartOfSpeechEnum.Adjective:
                switch (word.posTaggerOutputType)
                {
                case PosTaggerOutputType.Adjective:
                case PosTaggerOutputType.AdjectivePronoun:
                    break;

                default:
                    word.posTaggerOutputType = PosTaggerOutputType.Adjective;
                    break;
                }
                break;

            case PartOfSpeechEnum.Adverb:
                switch (word.posTaggerOutputType)
                {
                case PosTaggerOutputType.Adverb:
                case PosTaggerOutputType.AdverbialPronoun:
                    break;

                default:
                    word.posTaggerOutputType = PosTaggerOutputType.Adverb;
                    break;
                }
                break;

            case PartOfSpeechEnum.Article: word.posTaggerOutputType = PosTaggerOutputType.Article; break;

            case PartOfSpeechEnum.Conjunction: word.posTaggerOutputType = PosTaggerOutputType.Conjunction; break;

            case PartOfSpeechEnum.Interjection: word.posTaggerOutputType = PosTaggerOutputType.Interjection; break;

            case PartOfSpeechEnum.Noun: word.posTaggerOutputType = PosTaggerOutputType.Noun; break;

            case PartOfSpeechEnum.Numeral: word.posTaggerOutputType = PosTaggerOutputType.Numeral; break;

            case PartOfSpeechEnum.Other: word.posTaggerOutputType = PosTaggerOutputType.Other; break;

            case PartOfSpeechEnum.Particle: word.posTaggerOutputType = PosTaggerOutputType.Particle; break;

            case PartOfSpeechEnum.Predicate: word.posTaggerOutputType = PosTaggerOutputType.Predicate; break;

            case PartOfSpeechEnum.Preposition: word.posTaggerOutputType = PosTaggerOutputType.Preposition; break;

            case PartOfSpeechEnum.Pronoun:
                switch (word.posTaggerOutputType)
                {
                case PosTaggerOutputType.Pronoun:
                case PosTaggerOutputType.PossessivePronoun:
                case PosTaggerOutputType.AdjectivePronoun:
                case PosTaggerOutputType.AdverbialPronoun:
                    break;

                default:
                    word.posTaggerOutputType = PosTaggerOutputType.Pronoun;
                    break;
                }
                break;

            case PartOfSpeechEnum.Verb:
                switch (word.posTaggerOutputType)
                {
                case PosTaggerOutputType.Verb:
                case PosTaggerOutputType.Infinitive:
                case PosTaggerOutputType.AdverbialParticiple:
                case PosTaggerOutputType.AuxiliaryVerb:
                case PosTaggerOutputType.Participle:
                    break;

                default:
                    word.posTaggerOutputType = PosTaggerOutputType.Verb;
                    break;
                }
                break;

            default:
                throw new ArgumentException(singlePartOfSpeech.ToString());
            }
        }
Пример #32
0
        public ActionResult Game()
        {
            List <Word> allwords = Word.GetAll();

            return(View(allwords));
        }
 private int getWordCountByTopic(Word word, string topic)
 {
     return(_iWordRepository.getWordCountByTopic(word, topic));
 }
Пример #34
0
 public Id(Word id, VarType p, int b)
     : base(id, p)
 {
     Offset = b;
 }
Пример #35
0
        public async Task <IActionResult> PutWord(long id, Word item)
        {
            if (id != item.WordId)
            {
                return(BadRequest());
            }

            var alreadyExist = db.Words
                               .AsNoTracking()
                               .FirstOrDefault(a => a.Value == item.Value);

            if (alreadyExist != null)
            {
                // already have this entry, cannot create an duplicate

                // find all the relations to this word.
                var wordRelations = await db.WordRelations
                                    .AsNoTracking()
                                    .Where(e => id == e.WordFromId || id == e.WordToId)
                                    .ToListAsync();

                if (wordRelations.Any())
                {
                    var allRelatedWordsIds = wordRelations
                                             .SelectMany(w => new[] { w.WordFromId, w.WordToId })
                                             .Distinct()
                                             .Where(w => w != id && w != alreadyExist.WordId)
                                             .OrderBy(w => w)
                                             .ToList()
                    ;

                    // create new relations to the original word
                    var allWordRelationsFrom = allRelatedWordsIds.Select(wordFromId =>
                                                                         new WordRelation {
                        WordFromId = wordFromId, WordToId = alreadyExist.WordId
                    }
                                                                         );

                    // add relation from each hint to word as well
                    var allWordRelationsTo = allRelatedWordsIds.Select(wordToId =>
                                                                       new WordRelation {
                        WordFromId = alreadyExist.WordId, WordToId = wordToId
                    }
                                                                       );

                    // all relations
                    var allWordRelations = allWordRelationsFrom.Concat(allWordRelationsTo).Distinct();

                    // which relations need to be added?
                    var newWordRelations = allWordRelations.Where(x => !db.WordRelations.Any(z => z.WordFromId == x.WordFromId && z.WordToId == x.WordToId)).ToList();

                    if (newWordRelations.Count > 0)
                    {
                        db.WordRelations.AddRange(newWordRelations);
                    }

                    // then delete the original relations
                    db.WordRelations.RemoveRange(wordRelations);
                }

                // then delete the actual word
                db.Words.Remove(item);
                await db.SaveChangesAsync();

                return(Ok(alreadyExist));
            }
            else
            {
                // make sure the counts are recalculated
                var wordText = item.Value;
                item.NumberOfLetters = ScraperUtils.CountNumberOfLetters(wordText);
                item.NumberOfWords   = ScraperUtils.CountNumberOfWords(wordText);

                db.Entry(item).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(Ok(item));
            }
        }
Пример #36
0
 private static string GetMessage(Word w)
 {
     return($"An illegal instruction was encountered at address {w}.");
 }
Пример #37
0
        //drawstring justified with paragraph format
        public static void DrawStringJustified(Graphics graphics, string s, Font font, Brush brush, RectangleF layoutRectangle, char paragraphFormat)
        {
            try
            {
                //save the current state of the graphics handle
                GraphicsState graphicsState = graphics.Save();
                //obtain the font height to be used as line height
                double lineHeight = (double)Math.Round(font.GetHeight(graphics), 1);
                //string builder to format the text
                StringBuilder text         = new StringBuilder(s);
                Font          originalFont = new Font(font.FontFamily, font.Size, font.Style);

                //adjust the text string to ease detection of carriage returns
                text = text.Replace("\r\n", " <CR> ");
                text = text.Replace("\r", " <CR> ");
                text.Append(" <CR> ");

                //ensure measure string will bring the best measures possible (antialias)
                graphics.TextRenderingHint = TextRenderingHint.AntiAlias;

                //create a string format object with the generic typographic to obtain the most accurate string measurements
                //strange, but the recommended for this case is to use a "cloned" stringformat
                StringFormat stringFormat = (StringFormat)StringFormat.GenericTypographic.Clone();

                //allow the correct measuring of spaces
                stringFormat.FormatFlags = StringFormatFlags.MeasureTrailingSpaces;

                //create a stringformat for leftalignment
                StringFormat leftAlignHandle = new StringFormat();
                leftAlignHandle.LineAlignment = StringAlignment.Near;

                //create a stringformat for rightalignment
                StringFormat rightAlignHandle = new StringFormat();
                rightAlignHandle.LineAlignment = StringAlignment.Far;

                //measure space for the given font
                SizeF  stringSize = graphics.MeasureString(" ", font, layoutRectangle.Size, stringFormat);
                double spaceWidth = stringSize.Width + 1;

                //measure paragraph format for the given font
                double paragraphFormatWidth = 0;
                if (paragraphFormat != ' ')
                {
                    SizeF paragraphFormatSize = graphics.MeasureString(paragraphFormat.ToString(), new Font(font.FontFamily, font.Size, FontStyle.Regular), layoutRectangle.Size, stringFormat);
                    paragraphFormatWidth = paragraphFormatSize.Width;
                }

                //total word count
                int totalWords = Regex.Matches(text.ToString(), " ").Count;

                //array of words
                ArrayList words = new ArrayList();

                //measure each word
                int n = 0;
                while (true)
                {
                    //original word
                    string word = Regex.Split(text.ToString(), " ").GetValue(n).ToString();

                    //add to words array the word without tags
                    words.Add(new Word(word.Replace("<b>", "").Replace("</b>", "").Replace("<i>", "").Replace("</i>", "")));

                    //marque to start bolding or/and italic
                    if (word.ToLower().Contains("<b>") && word.ToLower().Contains("<i>"))
                    {
                        font = new Font(originalFont.FontFamily, originalFont.Size, FontStyle.Bold & FontStyle.Italic);
                    }
                    else if (word.ToLower().Contains("<b>"))
                    {
                        font = new Font(originalFont.FontFamily, originalFont.Size, FontStyle.Bold);
                    }
                    else if (word.ToLower().Contains("<i>"))
                    {
                        font = new Font(originalFont.FontFamily, originalFont.Size, FontStyle.Italic);
                    }

                    Word currentWord = (Word)words[n];
                    currentWord.StartBold   = word.ToLower().Contains("<b>");
                    currentWord.StopBold    = word.ToLower().Contains("</b>");
                    currentWord.StartItalic = word.ToLower().Contains("<i>");
                    currentWord.StopItalic  = word.ToLower().Contains("</i>");

                    //size of the word
                    SizeF wordSize  = graphics.MeasureString(currentWord.String, font, layoutRectangle.Size, stringFormat);
                    float wordWidth = wordSize.Width;

                    if (wordWidth > layoutRectangle.Width && currentWord.String != "<CR>")
                    {
                        int reduce = 1;
                        while (true)
                        {
                            int    lengthChars = (int)Math.Round(currentWord.String.Length / (wordWidth / layoutRectangle.Width), 0) - reduce;
                            string cutWord     = currentWord.String.Substring(0, lengthChars);

                            //the new size of the word
                            wordSize  = graphics.MeasureString(cutWord, font, layoutRectangle.Size, stringFormat);
                            wordWidth = wordSize.Width;

                            //update the word string
                            ((Word)words[n]).String = cutWord;

                            //add new word
                            if (wordWidth <= layoutRectangle.Width)
                            {
                                totalWords++;
                                words.Add(new Word("", 0,
                                                   currentWord.StartBold, currentWord.StopBold,
                                                   currentWord.StartItalic, currentWord.StopItalic));
                                text.Replace(currentWord.String, cutWord + " " + currentWord.String.Substring(lengthChars + 1), 0, 1);
                                break;
                            }

                            reduce++;
                        }
                    }

                    //update the word size
                    ((Word)words[n]).Length = wordWidth;

                    //marque to stop bolding or/and italic
                    if (word.ToLower().Contains("</b>") && font.Style == FontStyle.Italic)
                    {
                        font = new Font(originalFont.FontFamily, originalFont.Size, FontStyle.Italic);
                    }
                    else if (word.ToLower().Contains("</i>") && font.Style == FontStyle.Bold)
                    {
                        font = new Font(originalFont.FontFamily, originalFont.Size, FontStyle.Bold);
                    }
                    else if (word.ToLower().Contains("</b>") || word.ToLower().Contains("</i>"))
                    {
                        font = new Font(originalFont.FontFamily, originalFont.Size, FontStyle.Regular);
                    }

                    n++;
                    if (n > totalWords - 1)
                    {
                        break;
                    }
                }

                //before we start drawing, its wise to restore ou graphics objecto to its original state
                graphics.Restore(graphicsState);

                //restore to font to the original values
                font = new Font(originalFont.FontFamily, originalFont.Size, originalFont.Style);

                //start drawing word by word
                int currentLine = 0;
                for (int i = 0; i < totalWords; i++)
                {
                    bool   endOfSentence = false;
                    double wordsWidth    = 0;
                    int    wordsInLine   = 0;

                    int j = i;
                    for (j = i; j < totalWords; j++)
                    {
                        if (((Word)words[j]).String == "<CR>")
                        {
                            endOfSentence = true;
                            break;
                        }

                        wordsWidth += ((Word)words[j]).Length + spaceWidth;
                        if (wordsWidth > layoutRectangle.Width && j > i)
                        {
                            wordsWidth = wordsWidth - ((Word)words[j]).Length - (spaceWidth * wordsInLine);
                            break;
                        }

                        wordsInLine++;
                    }

                    if (j > totalWords)
                    {
                        endOfSentence = true;
                    }

                    double widthOfBetween = 0;
                    if (endOfSentence)
                    {
                        widthOfBetween = spaceWidth;
                    }
                    else
                    {
                        widthOfBetween = (layoutRectangle.Width - wordsWidth) / (wordsInLine - 1);
                    }

                    double currentTop = layoutRectangle.Top + (int)(currentLine * lineHeight);

                    if (currentTop > (layoutRectangle.Height + layoutRectangle.Top))
                    {
                        i = totalWords;
                        break;
                    }

                    double currentLeft = layoutRectangle.Left;

                    bool lastWord = false;
                    for (int currentWord = 0; currentWord < wordsInLine; currentWord++)
                    {
                        bool loop = false;

                        if (((Word)words[i]).String == "<CR>")
                        {
                            i++;
                            loop = true;
                        }

                        if (!loop)
                        {
                            //last word in sentence
                            if (currentWord == wordsInLine && !endOfSentence)
                            {
                                lastWord = true;
                            }

                            if (wordsInLine == 1)
                            {
                                currentLeft = layoutRectangle.Left;
                                lastWord    = false;
                            }

                            RectangleF   rectangleF;
                            StringFormat stringFormatHandle;

                            if (lastWord)
                            {
                                rectangleF         = new RectangleF(layoutRectangle.Left, (float)currentTop, layoutRectangle.Width, (float)(currentTop + lineHeight));
                                stringFormatHandle = rightAlignHandle;
                            }
                            else
                            {
                                //lets zero size for word to drawstring auto-size de word
                                rectangleF         = new RectangleF((float)currentLeft, (float)currentTop, 0, 0);
                                stringFormatHandle = leftAlignHandle;
                            }

                            //start bolding and/or italic
                            if (((Word)words[i]).StartBold && ((Word)words[i]).StartItalic)
                            {
                                font = new Font(originalFont.FontFamily, originalFont.Size, FontStyle.Bold & FontStyle.Italic);
                            }
                            else if (((Word)words[i]).StartBold)
                            {
                                font = new Font(originalFont.FontFamily, originalFont.Size, FontStyle.Bold);
                            }
                            else if (((Word)words[i]).StartItalic)
                            {
                                font = new Font(originalFont.FontFamily, originalFont.Size, FontStyle.Italic);
                            }

                            //draw the word
                            graphics.DrawString(((Word)words[i]).String, font, brush, rectangleF, stringFormatHandle);

                            //stop bolding and/or italic
                            if (((Word)words[i]).StopBold && font.Style == FontStyle.Italic)
                            {
                                font = new Font(originalFont.FontFamily, originalFont.Size, FontStyle.Regular);
                            }
                            else if (((Word)words[i]).StopItalic && font.Style == FontStyle.Bold)
                            {
                                font = new Font(originalFont.FontFamily, originalFont.Size, FontStyle.Bold);
                            }
                            else if (((Word)words[i]).StopBold || ((Word)words[i]).StopItalic)
                            {
                                font = new Font(originalFont.FontFamily, originalFont.Size, FontStyle.Regular);
                            }

                            //paragraph formating
                            if (endOfSentence && currentWord == wordsInLine - 1 && paragraphFormat != ' ')
                            {
                                currentLeft += ((Word)words[i]).Length;
                                //draw until end of line
                                while (currentLeft + paragraphFormatWidth <= layoutRectangle.Left + layoutRectangle.Width)
                                {
                                    rectangleF = new RectangleF((float)currentLeft, (float)currentTop, 0, 0);
                                    //draw the paragraph format
                                    graphics.DrawString(paragraphFormat.ToString(), font, brush, rectangleF, stringFormatHandle);
                                    currentLeft += paragraphFormatWidth;
                                }
                            }
                            else
                            {
                                currentLeft += ((Word)words[i]).Length + widthOfBetween;
                            }

                            //go to next word
                            i++;
                        }
                    }

                    currentLine++;

                    if (i >= totalWords)
                    {
                        break;
                    }

                    //compensate endfor
                    if (((Word)words[i]).String != "<CR>")
                    {
                        i--;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #38
0
 // nlz returns the number of leading zeros in x.
 // Wraps bits.LeadingZeros call for convenience.
 private static ulong nlz(Word x)
 {
     return(uint(bits.LeadingZeros(uint(x))));
 }
Пример #39
0
 private ulong DeriveUInt64(ushort b3, ushort b2, ushort b1, ushort b0)
 {
     return(Word.MakeQuadWord(ModbusUtility.GetUInt32(b3, b2), ModbusUtility.GetUInt32(b1, b0)));
 }
Пример #40
0
        public async Task DeleteWord(Word word)
        {
            await _wordManager.Delete(word);

            await UpdateWordList();
        }
Пример #41
0
        public async Task SaveWord(Word word)
        {
            await _wordManager.Save(word);

            await UpdateWordList();
        }
Пример #42
0
 /// <param name="address">The address of the first byte of the instruction.</param>
 public IllegalInstructionException(Word address)
 {
     Address = address;
 }
Пример #43
0
 public IllegalInstructionException(Word address, Exception innerException) : base(GetMessage(address), innerException)
 {
     Address = address;
 }
Пример #44
0
        private void WriteWord(DirectoryInfo path)
        {
            //string wordPath = @"./templates/4_2_1 人均居住用地指标计算书(居建).docx";
            FileInfo[] files = path.GetFiles();
            Parallel.ForEach(files, f =>
            {
                if (f.Extension == ".doc" || f.Extension == ".docx")
                {
                    try
                    {
                        string wordPath = f.FullName;
                        string wordName = f.Name;
                        Word word       = new Word();
                        word.Open(wordPath);
                        word.Builder();

                        #region 项目概况
                        word.ReplaceBookMark("Project_Name", Project_Name);
                        word.ReplaceBookMark("Project_Name1", Project_Name);
                        word.ReplaceBookMark("Project_Name2", Project_Name);
                        word.ReplaceBookMark("Deve_Org", Deve_Org);
                        word.ReplaceBookMark("Con_Org", Con_Org);
                        word.ReplaceBookMark("Proj_Overview", Proj_Overview);
                        word.ReplaceBookMark("Making", Making);
                        word.ReplaceBookMark("Reader", Reader);
                        word.ReplaceBookMark("Check", Check);
                        word.ReplaceBookMark("Report_Date", Report_Date);
                        //string imagePath = @"./参评范围.jpg";
                        if (File.Exists(@"./参评范围.jpg"))
                        {
                            word.ReplaceBookMark("Involved_Range", @"./参评范围.jpg", "IMG");
                        }
                        else
                        {
                            Console.WriteLine("请在当前文件夹中放入:参评范围.jpg 文件");
                        }

                        word.ReplaceBookMark("Site_Area", Site_Area);
                        word.ReplaceBookMark("Gross_Bldg_Area", Gross_Bldg_Area);
                        word.ReplaceBookMark("Above_Area", Above_Area);
                        word.ReplaceBookMark("Under_Area", Under_Area);
                        word.ReplaceBookMark("Under_One_Area", Under_One_Area);
                        word.ReplaceBookMark("Rr", Rr);
                        word.ReplaceBookMark("Rp1", Rp1);
                        word.ReplaceBookMark("Rp2", Rp2);
                        word.ReplaceBookMark("Users", Users);
                        word.ReplaceBookMark("Res_P", Res_P);
                        word.ReplaceBookMark("Avg_Area_Per_P", Avg_Area_Per_P);
                        word.ReplaceBookMark("Green_Area", Green_Area);
                        word.ReplaceBookMark("Green_Radio", Green_Radio);
                        word.ReplaceBookMark("Pub_Green_Space", Pub_Green_Space);
                        word.ReplaceBookMark("Green_Per_P", Green_Per_P);
                        word.ReplaceBookMark("Design_Org", Design_Org);
                        word.ReplaceBookMark("Check_Org", Check_Org);
                        word.ReplaceBookMark("Plot_ratio", Plot_ratio);
                        #endregion



                        //替换评价工具表内容
                        word.ReplaceBookMark("Score4_2_1_R", Score4_2_1_R);
                        word.ReplaceBookMark("Score4_2_3_R", Score4_2_3_R);
                        word.ReplaceBookMark("Score4_2_3_P", Score4_2_3_P);


                        //绿建自评估报告内容
                        word.ReplaceBookMark("StarLevel", StarLevel);

                        double scoreSum = Convert.ToDouble(ScoreSum);

                        word.ReplaceBookMark("Star", StarRange(scoreSum));

                        if (scoreSum < 50)
                        {
                            word.ReplaceBookMark("StarTick1", Images.Unselected, "IMG", 12, 12);
                            word.ReplaceBookMark("StarTick2", Images.Unselected, "IMG", 12, 12);
                            word.ReplaceBookMark("StarTick3", Images.Unselected, "IMG", 12, 12);
                        }
                        else if (scoreSum >= 50.0 && scoreSum < 60.0)
                        {
                            word.ReplaceBookMark("StarTick1", Images.Selected, "IMG", 12, 12);
                            word.ReplaceBookMark("StarTick2", Images.Unselected, "IMG", 12, 12);
                            word.ReplaceBookMark("StarTick3", Images.Unselected, "IMG", 12, 12);
                        }
                        else if (scoreSum >= 60.0 && scoreSum < 80.0)
                        {
                            word.ReplaceBookMark("StarTick1", Images.Unselected, "IMG", 12, 12);
                            word.ReplaceBookMark("StarTick2", Images.Selected, "IMG", 12, 12);
                            word.ReplaceBookMark("StarTick3", Images.Unselected, "IMG", 12, 12);
                        }
                        else
                        {
                            word.ReplaceBookMark("StarTick1", Images.Unselected, "IMG", 12, 12);
                            word.ReplaceBookMark("StarTick2", Images.Unselected, "IMG", 12, 12);
                            word.ReplaceBookMark("StarTick3", Images.Selected, "IMG", 12, 12);
                        }



                        word.ReplaceBookMark("ScoreSum", ScoreSum);
                        word.ReplaceBookMark("ScoreItem", ScoreItem);
                        word.ReplaceBookMark("Item4_1", Item4_1);
                        word.ReplaceBookMark("Item4_2", Item4_2);
                        word.ReplaceBookMark("Item4_3", Item4_3);
                        word.ReplaceBookMark("Item4_4", Item4_4);
                        word.ReplaceBookMark("Item4_5", Item4_5);

                        #region 4节地与室外环境
                        word.ReplaceBookMark("Item421_1_1", Item421_1_1);
                        word.ReplaceBookMark("Item421_1_2", Item421_1_2);
                        word.ReplaceBookMark("Item422_1_1", Item422_1_1);
                        word.ReplaceBookMark("Item422_1_2", Item422_1_2);
                        word.ReplaceBookMark("Item423_1_1", Item423_1_1);
                        word.ReplaceBookMark("Item423_1_2", Item423_1_2);
                        word.ReplaceBookMark("Item424_1_1", Item424_1_1);
                        word.ReplaceBookMark("Item424_1_2", Item424_1_2);
                        word.ReplaceBookMark("Item425_1_1", Item425_1_1);
                        word.ReplaceBookMark("Item425_1_2", Item425_1_2);
                        word.ReplaceBookMark("Item426_1_1", Item426_1_1);
                        word.ReplaceBookMark("Item426_1_2", Item426_1_2);
                        word.ReplaceBookMark("Item427_1_1", Item427_1_1);
                        word.ReplaceBookMark("Item427_1_2", Item427_1_2);
                        word.ReplaceBookMark("Item428_1_1", Item428_1_1);
                        word.ReplaceBookMark("Item428_1_2", Item428_1_2);
                        word.ReplaceBookMark("Item429_1_1", Item429_1_1);
                        word.ReplaceBookMark("Item429_1_2", Item429_1_2);
                        word.ReplaceBookMark("Item4210_1_1", Item4210_1_1);
                        word.ReplaceBookMark("Item4210_1_2", Item4210_1_2);
                        word.ReplaceBookMark("Item4211_1_1", Item4211_1_1);
                        word.ReplaceBookMark("Item4211_1_2", Item4211_1_2);
                        word.ReplaceBookMark("Item4212_1_1", Item4212_1_1);
                        word.ReplaceBookMark("Item4212_1_2", Item4212_1_2);
                        word.ReplaceBookMark("Item4213_1_1", Item4213_1_1);
                        word.ReplaceBookMark("Item4213_1_2", Item4213_1_2);
                        word.ReplaceBookMark("Item4214_1_1", Item4214_1_1);
                        word.ReplaceBookMark("Item4214_1_2", Item4214_1_2);
                        word.ReplaceBookMark("Item4215_1_1", Item4215_1_1);
                        word.ReplaceBookMark("Item4215_1_2", Item4215_1_2);

                        #endregion



                        word.ReplaceBookMark("Item5_1", Item5_1);
                        word.ReplaceBookMark("Item5_2", Item5_2);
                        word.ReplaceBookMark("Item5_3", Item5_3);
                        word.ReplaceBookMark("Item5_4", Item5_4);
                        word.ReplaceBookMark("Item5_5", Item5_5);

                        #region 5节能
                        word.ReplaceBookMark("Item521_1_1", Item521_1_1);
                        word.ReplaceBookMark("Item521_1_2", Item521_1_2);
                        word.ReplaceBookMark("Item522_1_1", Item522_1_1);
                        word.ReplaceBookMark("Item522_1_2", Item522_1_2);
                        word.ReplaceBookMark("Item523_1_1", Item523_1_1);
                        word.ReplaceBookMark("Item523_1_2", Item523_1_2);
                        word.ReplaceBookMark("Item524_1_1", Item524_1_1);
                        word.ReplaceBookMark("Item524_1_2", Item524_1_2);
                        word.ReplaceBookMark("Item525_1_1", Item525_1_1);
                        word.ReplaceBookMark("Item525_1_2", Item525_1_2);
                        word.ReplaceBookMark("Item526_1_1", Item526_1_1);
                        word.ReplaceBookMark("Item526_1_2", Item526_1_2);
                        word.ReplaceBookMark("Item527_1_1", Item527_1_1);
                        word.ReplaceBookMark("Item527_1_2", Item527_1_2);
                        word.ReplaceBookMark("Item528_1_1", Item528_1_1);
                        word.ReplaceBookMark("Item528_1_2", Item528_1_2);
                        word.ReplaceBookMark("Item529_1_1", Item529_1_1);
                        word.ReplaceBookMark("Item529_1_2", Item529_1_2);
                        word.ReplaceBookMark("Item5210_1_1", Item5210_1_1);
                        word.ReplaceBookMark("Item5210_1_2", Item5210_1_2);
                        word.ReplaceBookMark("Item5211_1_1", Item5211_1_1);
                        word.ReplaceBookMark("Item5211_1_2", Item5211_1_2);
                        word.ReplaceBookMark("Item5212_1_1", Item5212_1_1);
                        word.ReplaceBookMark("Item5212_1_2", Item5212_1_2);
                        word.ReplaceBookMark("Item5213_1_1", Item5213_1_1);
                        word.ReplaceBookMark("Item5213_1_2", Item5213_1_2);
                        word.ReplaceBookMark("Item5214_1_1", Item5214_1_1);
                        word.ReplaceBookMark("Item5214_1_2", Item5214_1_2);
                        word.ReplaceBookMark("Item5215_1_1", Item5215_1_1);
                        word.ReplaceBookMark("Item5215_1_2", Item5215_1_2);
                        word.ReplaceBookMark("Item5216_1_1", Item5216_1_1);
                        word.ReplaceBookMark("Item5216_1_2", Item5216_1_2);

                        #endregion

                        word.ReplaceBookMark("Item6_1", Item6_1);
                        word.ReplaceBookMark("Item6_2", Item6_2);
                        word.ReplaceBookMark("Item6_3", Item6_3);
                        word.ReplaceBookMark("Item6_4", Item6_4);
                        word.ReplaceBookMark("Item6_5", Item6_5);

                        #region 6节水
                        //word.ReplaceBookMark("Item621_1_1", Item621_1_1); //设计阶段不参评
                        //word.ReplaceBookMark("Item621_1_2", Item621_1_2); //设计阶段不参评
                        word.ReplaceBookMark("Item622_1_1", Item622_1_1);
                        word.ReplaceBookMark("Item622_1_2", Item622_1_2);
                        word.ReplaceBookMark("Item623_1_1", Item623_1_1);
                        word.ReplaceBookMark("Item623_1_2", Item623_1_2);
                        word.ReplaceBookMark("Item624_1_1", Item624_1_1);
                        word.ReplaceBookMark("Item624_1_2", Item624_1_2);
                        word.ReplaceBookMark("Item625_1_1", Item625_1_1);
                        word.ReplaceBookMark("Item625_1_2", Item625_1_2);
                        word.ReplaceBookMark("Item626_1_1", Item626_1_1);
                        word.ReplaceBookMark("Item626_1_2", Item626_1_2);
                        word.ReplaceBookMark("Item627_1_1", Item627_1_1);
                        word.ReplaceBookMark("Item627_1_2", Item627_1_2);
                        word.ReplaceBookMark("Item628_1_1", Item628_1_1);
                        word.ReplaceBookMark("Item628_1_2", Item628_1_2);
                        word.ReplaceBookMark("Item629_1_1", Item629_1_1);
                        word.ReplaceBookMark("Item629_1_2", Item629_1_2);
                        word.ReplaceBookMark("Item6210_1_1", Item6210_1_1);
                        word.ReplaceBookMark("Item6210_1_2", Item6210_1_2);
                        word.ReplaceBookMark("Item6211_1_1", Item6211_1_1);
                        word.ReplaceBookMark("Item6211_1_2", Item6211_1_2);
                        word.ReplaceBookMark("Item6212_1_1", Item6212_1_1);
                        word.ReplaceBookMark("Item6212_1_2", Item6212_1_2);


                        #endregion

                        word.ReplaceBookMark("Item7_1", Item7_1);
                        word.ReplaceBookMark("Item7_2", Item7_2);
                        word.ReplaceBookMark("Item7_3", Item7_3);
                        word.ReplaceBookMark("Item7_4", Item7_4);
                        word.ReplaceBookMark("Item7_5", Item7_5);


                        #region 7节材
                        word.ReplaceBookMark("Item721_1_1", Item721_1_1);
                        word.ReplaceBookMark("Item721_1_2", Item721_1_2);
                        word.ReplaceBookMark("Item722_1_1", Item722_1_1);
                        word.ReplaceBookMark("Item722_1_2", Item722_1_2);
                        word.ReplaceBookMark("Item723_1_1", Item723_1_1);
                        word.ReplaceBookMark("Item723_1_2", Item723_1_2);
                        word.ReplaceBookMark("Item724_1_1", Item724_1_1);
                        word.ReplaceBookMark("Item724_1_2", Item724_1_2);
                        word.ReplaceBookMark("Item725_1_1", Item725_1_1);
                        word.ReplaceBookMark("Item725_1_2", Item725_1_2);
                        word.ReplaceBookMark("Item726_1_1", Item726_1_1);
                        word.ReplaceBookMark("Item726_1_2", Item726_1_2);
                        //word.ReplaceBookMark("Item727_1_1", Item727_1_1);//设计阶段不参评
                        //word.ReplaceBookMark("Item727_1_2", Item727_1_2);//设计阶段不参评
                        word.ReplaceBookMark("Item728_1_1", Item728_1_1);
                        word.ReplaceBookMark("Item728_1_2", Item728_1_2);
                        word.ReplaceBookMark("Item729_1_1", Item729_1_1);
                        word.ReplaceBookMark("Item729_1_2", Item729_1_2);
                        word.ReplaceBookMark("Item7210_1_1", Item7210_1_1);
                        word.ReplaceBookMark("Item7210_1_2", Item7210_1_2);
                        word.ReplaceBookMark("Item7211_1_1", Item7211_1_1);
                        word.ReplaceBookMark("Item7211_1_2", Item7211_1_2);
                        word.ReplaceBookMark("Item7212_1_1", Item7212_1_1);
                        word.ReplaceBookMark("Item7212_1_2", Item7212_1_2);
                        //word.ReplaceBookMark("Item7213_1_1", Item7213_1_1);//设计阶段不参评
                        // word.ReplaceBookMark("Item7213_1_2", Item7213_1_2);//设计阶段不参评
                        //word.ReplaceBookMark("Item7214_1_1", Item7214_1_1);//设计阶段不参评
                        //word.ReplaceBookMark("Item7214_1_2", Item7214_1_2);//设计阶段不参评
                        #endregion

                        word.ReplaceBookMark("Item8_1", Item8_1);
                        word.ReplaceBookMark("Item8_2", Item8_2);
                        word.ReplaceBookMark("Item8_3", Item8_3);
                        word.ReplaceBookMark("Item8_4", Item8_4);
                        word.ReplaceBookMark("Item8_5", Item8_5);

                        #region 8室内环境
                        word.ReplaceBookMark("Item821_1_1", Item821_1_1);
                        word.ReplaceBookMark("Item821_1_2", Item821_1_2);
                        word.ReplaceBookMark("Item822_1_1", Item822_1_1);
                        word.ReplaceBookMark("Item822_1_2", Item822_1_2);
                        word.ReplaceBookMark("Item823_1_1", Item823_1_1);
                        word.ReplaceBookMark("Item823_1_2", Item823_1_2);
                        word.ReplaceBookMark("Item824_1_1", Item824_1_1);
                        word.ReplaceBookMark("Item824_1_2", Item824_1_2);
                        word.ReplaceBookMark("Item825_1_1", Item825_1_1);
                        word.ReplaceBookMark("Item825_1_2", Item825_1_2);
                        word.ReplaceBookMark("Item826_1_1", Item826_1_1);
                        word.ReplaceBookMark("Item826_1_2", Item826_1_2);
                        word.ReplaceBookMark("Item827_1_1", Item827_1_1);
                        word.ReplaceBookMark("Item827_1_2", Item827_1_2);
                        word.ReplaceBookMark("Item828_1_1", Item828_1_1);
                        word.ReplaceBookMark("Item828_1_2", Item828_1_2);
                        word.ReplaceBookMark("Item829_1_1", Item829_1_1);
                        word.ReplaceBookMark("Item829_1_2", Item829_1_2);
                        word.ReplaceBookMark("Item8210_1_1", Item8210_1_1);
                        word.ReplaceBookMark("Item8210_1_2", Item8210_1_2);
                        word.ReplaceBookMark("Item8211_1_1", Item8211_1_1);
                        word.ReplaceBookMark("Item8211_1_2", Item8211_1_2);
                        word.ReplaceBookMark("Item8212_1_1", Item8212_1_1);
                        word.ReplaceBookMark("Item8212_1_2", Item8212_1_2);
                        word.ReplaceBookMark("Item8213_1_1", Item8213_1_1);
                        word.ReplaceBookMark("Item8213_1_2", Item8213_1_2);


                        #endregion

                        word.ReplaceBookMark("Item11_1", Item11_1);

                        #region 11创新
                        word.ReplaceBookMark("Item1121_1_1", Item1121_1_1);
                        word.ReplaceBookMark("Item1122_1_1", Item1122_1_1);
                        word.ReplaceBookMark("Item1123_1_1", Item1123_1_1);
                        word.ReplaceBookMark("Item1124_1_1", Item1124_1_1);
                        word.ReplaceBookMark("Item1125_1_1", Item1125_1_1);
                        word.ReplaceBookMark("Item1126_1_1", Item1126_1_1);
                        word.ReplaceBookMark("Item1127_1_1", Item1127_1_1);
                        word.ReplaceBookMark("Item1128_1_1", Item1128_1_1);
                        word.ReplaceBookMark("Item1129_1_1", Item1129_1_1);
                        word.ReplaceBookMark("Item11210_1_1", Item11210_1_1);
                        word.ReplaceBookMark("Item11211_1_1", Item11211_1_1);
                        word.ReplaceBookMark("Item11212_1_1", Item11212_1_1);

                        #endregion



                        word.Save(wordPath);
                        Console.WriteLine(wordName + "  报告生成完成!");
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("错误,{0}", e.Message);
                    }
                }
            });
        }
Пример #45
0
    public LoadWordMap(string loadSource, int level, GameObject tilePrefab,
                       GameObject levelCanvas, GameObject tileStartPoint, Sprite[] sprites,
                       string json, MusicController _audio)
    {
        audioController = _audio;
        wordList        = new List <Word> ();
        string   content = json /*.text*/;
        JSONNode levels  = JSON.Parse(content);
        int      w       = levels ["levels"] [level] ["width"].AsInt;
        int      h       = levels ["levels"] [level] ["height"].AsInt;

        for (int i = 0; i < w; i++)
        {
            for (int j = 0; j < h; j++)
            {
                Word word = new Word(levels["levels"][level], j, i);
                wordList.Add(word);
            }
        }

        int width  = w;
        int height = h;

        tileData = new List <List <GameObject> >();
        for (int y = 0; y < height; y++)
        {
            tileData.Add(new List <GameObject>());
        }

        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                GameObject tileGameObject = CreateTile(tilePrefab, levelCanvas, tileStartPoint);
                Tile       tile           = tileGameObject.GetComponent <Tile>();
                tile.audioController = audioController;
                tile.tileName        = wordList[height * x + y].word;

                for (int i = 0; i < sprites.Length; i++)
                {
                    Sprite temp = sprites[i];

                    if (temp.name == tile.tileName)
                    {
                        tile.sprite = temp;
                    }
                }

                Vector3       pos = tileStartPoint.transform.position;
                BoxCollider2D box = tilePrefab.GetComponent <BoxCollider2D>();
                pos.x += x * box.size.x * 2f;

                if (x > 1)
                {
                    pos.x += box.size.x;
                }

                pos.y += y * -box.size.y * 2f;
                pos.z  = tileStartPoint.transform.position.z;
                tile.transform.position = pos;
                tileData[y].Add(tileGameObject);
            }
        }
    }
Пример #46
0
 private int GetConfidence(Word word)
 {
     return(100);
 }
Пример #47
0
 public bool Equals(GraphNode other)
 {
     return(Word.Equals(other.Word));
 }
Пример #48
0
        public IEnumerable <Word> GetTranslates(int id)
        {
            Word byKey = Repository.GetByKey <UserWord>(id, "Word.TranslationsTo.Language", "Word.TranslationsFrom.Language", "Word.TranslationsTo.Type", "Word.TranslationsTo.Type").Word;

            return(byKey.TranslationsTo.Union(byKey.TranslationsFrom));
        }
Пример #49
0
        static void Main(string[] args)
        {
            IWordScrambleGame      game  = new WordScrambleClient.WordScrambleGameService.WordScrambleGameClient();
            WordScrambleGameClient proxy = new WordScrambleGameClient();
            bool canPlayGame             = true;

            Console.WriteLine("Player's name?");
            String playerName = Console.ReadLine();

            if (!proxy.isGameBeingHosted())
            {
                Console.WriteLine("Welcome " + playerName +
                                  "! Do you want to host the game?");
                if (Console.ReadLine().CompareTo("yes") == 0)
                {
                    Console.WriteLine("Type the word to scramble.");
                    string inputWord = Console.ReadLine();
                    inputWord = inputWord.Trim();
                    string scrambledWord = "";
                    try
                    {
                        scrambledWord = proxy.hostGame(playerName, "", inputWord);
                    }
                    catch (FaultException <GameBeingHostedFault> e)
                    {
                        Console.WriteLine("WARNING: {0}", e.Detail.problem);
                    }
                    canPlayGame = false;
                    Console.WriteLine("You're hosting the game with word '" + inputWord + "' scrambled as '" + scrambledWord + "'");
                    Console.ReadKey();
                }
            }

            if (canPlayGame)
            {
                Console.WriteLine("Do you want to play the game?");
                if (Console.ReadLine().CompareTo("yes") == 0)
                {
                    //catch the host cannot join game exception
                    try
                    {
                        //catch the nogame hosted exception
                        try
                        {
                            //catch the maxium players reached exception
                            try
                            {
                                Word gameWords = proxy.join(playerName);
                                Console.WriteLine("Can you unscramble this word? => " + gameWords.scrambledWord);
                                String guessedWord;

                                bool gameOver = false;
                                while (!gameOver && !proxy.isGameOver())
                                {
                                    guessedWord = Console.ReadLine();
                                    //catch the 'not playing game' fault
                                    try
                                    {
                                        gameOver = proxy.guessWord(playerName, guessedWord, gameWords.unscrambledWord);
                                    }
                                    catch (FaultException <PlayerNotPlayingGameFault> e)
                                    {
                                        Console.WriteLine("Warning: {0}", e.Detail.problem);
                                    }
                                    if (!gameOver)
                                    {
                                        Console.WriteLine("Nope, try again...");
                                    }
                                    else if (proxy.isGameOver())
                                    {
                                        Console.WriteLine("Game is over. YOU HAVE LOST!");
                                    }
                                }
                                Console.WriteLine("You WON!!!");
                            }
                            catch (FaultException <MaximumPlayersReachedFault> e)
                            {
                                Console.WriteLine("WARNING: you, {1} cannot join due to {0}", e.Detail.problem, e.Detail.playerName);
                            }
                        }
                        catch (FaultException <NoGameHostedFault> e)
                        {
                            Console.WriteLine("WARNING: {0}", e.Detail.problem);
                        }
                    }
                    catch (FaultException <HostCannotJoinGameFault> e)
                    {
                        Console.WriteLine("WARNING: {0} due to your name {1} hosting.", e.Detail.problem, e.Detail.userName);
                    }
                }
            }
        }
Пример #50
0
 public Guess(Word updatedWord, bool isCorrect)
 {
     UpdatedWord = updatedWord;
     IsCorrect   = isCorrect;
 }
Пример #51
0
    void Start()
    {
        LogSystem.InstallDefaultReactors();

        ////	Get Voices
        //Log.Debug("ExampleTextToSpeech", "Attempting to get voices.");
        //m_TextToSpeech.GetVoices(OnGetVoices);

        ////	Get Voice
        ////string selectedVoice = "en-US_AllisonVoice";
        //Log.Debug("ExampleTextToSpeech", "Attempting to get voice {0}.", VoiceType.en_US_Allison);
        //m_TextToSpeech.GetVoice(OnGetVoice, VoiceType.en_US_Allison);

        ////	Get Pronunciation
        //string testWord = "Watson";
        //Log.Debug("ExampleTextToSpeech", "Attempting to get pronunciation of {0}", testWord);
        //m_TextToSpeech.GetPronunciation(OnGetPronunciation, testWord, VoiceType.en_US_Allison);

        // Get Customizations
        //Log.Debug("ExampleTextToSpeech", "Attempting to get a list of customizations");
        //m_TextToSpeech.GetCustomizations(OnGetCustomizations);

        //	Create Customization
        //Log.Debug("ExampleTextToSpeech", "Attempting to create a customization");
        //string customizationName = "unity-example-customization";
        //string customizationLanguage = "en-US";
        //string customizationDescription = "A text to speech voice customization created within Unity.";
        //m_TextToSpeech.CreateCustomization(OnCreateCustomization, customizationName, customizationLanguage, customizationDescription);

        //	Delete Customization
        //Log.Debug("ExampleTextToSpeech", "Attempting to delete a customization");
        //string customizationIdentifierToDelete = "1476ea80-5355-4911-ac99-ba39162a2d34";
        //if (!m_TextToSpeech.DeleteCustomization(OnDeleteCustomization, customizationIdentifierToDelete))
        //	Log.Debug("ExampleTextToSpeech", "Failed to delete custom voice model!");

        //	Get Customization
        //Log.Debug("ExampleTextToSpeech", "Attempting to get a customization");
        //string customizationIdentifierToGet = "1476ea80-5355-4911-ac99-ba39162a2d34";
        //if (!m_TextToSpeech.GetCustomization(OnGetCustomization, customizationIdentifierToGet))
        //	Log.Debug("ExampleTextToSpeech", "Failed to get custom voice model!");

        //	Update Customization
        Log.Debug("ExampleTextToSpeech", "Attempting to update a customization");
        Word word0 = new Word();

        word0.word        = "hello";
        word0.translation = "hullo";
        Word word1 = new Word();

        word1.word        = "goodbye";
        word1.translation = "gbye";
        Word word2 = new Word();

        word2.word        = "hi";
        word2.translation = "ohiooo";
        Word[]            words             = { word0, word1, word2 };
        CustomVoiceUpdate customVoiceUpdate = new CustomVoiceUpdate();

        customVoiceUpdate.words       = words;
        customVoiceUpdate.description = "My updated description";
        customVoiceUpdate.name        = "My updated name";
        string customizationIdToUpdate = "1476ea80-5355-4911-ac99-ba39162a2d34";

        if (!m_TextToSpeech.UpdateCustomization(OnUpdateCustomization, customizationIdToUpdate, customVoiceUpdate))
        {
            Log.Debug("ExampleTextToSpeech", "Failed to update customization!");
        }

        //	Get Customization Words
        //Log.Debug("ExampleTextToSpeech", "Attempting to get a customization's words");
        //string customIdentifierToGetWords = "1476ea80-5355-4911-ac99-ba39162a2d34";
        //if (!m_TextToSpeech.GetCustomizationWords(OnGetCustomizationWords, customIdentifierToGetWords))
        //	Log.Debug("ExampleTextToSpeech", "Failed to get {0} words!", customIdentifierToGetWords);

        //	Add Customization Words
        //Log.Debug("ExampleTextToSpeech", "Attempting to add words to a customization");
        //string customIdentifierToAddWords = "1476ea80-5355-4911-ac99-ba39162a2d34";
        //Words words = new Words();
        //Word word0 = new Word();
        //word0.word = "bananna";
        //word0.translation = "bunanna";
        //Word word1 = new Word();
        //word1.word = "orange";
        //word1.translation = "arange";
        //Word word2 = new Word();
        //word2.word = "tomato";
        //word2.translation = "tomahto";
        //Word[] wordArray = { word0, word1, word2 };
        //words.words = wordArray;
        //if (!m_TextToSpeech.AddCustomizationWords(OnAddCustomizationWords, customIdentifierToAddWords, words))
        //	Log.Debug("ExampleTextToSpeech", "Failed to add words to {0}!", customIdentifierToAddWords);

        //	Delete Customization Word
        //Log.Debug("ExampleTextToSpeech", "Attempting to delete customization word from custom voice model.");
        //string customIdentifierToDeleteWord = "1476ea80-5355-4911-ac99-ba39162a2d34";
        //string wordToDelete = "goodbye";
        //if (!m_TextToSpeech.DeleteCustomizationWord(OnDeleteCustomizationWord, customIdentifierToDeleteWord, wordToDelete))
        //	Log.Debug("ExampleTextToSpeech", "Failed to delete {0} from {1}!", wordToDelete, customIdentifierToDeleteWord);

        //	Get Customization Word
        //Log.Debug("ExampleTextToSpeech", "Attempting to get the translation of a custom voice model's word.");
        //string customIdentifierToGetWord = "1476ea80-5355-4911-ac99-ba39162a2d34";
        //string customIdentifierWord = "hello";
        //if (!m_TextToSpeech.GetCustomizationWord(OnGetCustomizationWord, customIdentifierToGetWord, customIdentifierWord))
        //	Log.Debug("ExampleTextToSpeech", "Failed to get the translation of {0} from {1}!", customIdentifierWord, customIdentifierToGetWord);

        //	Add Customization Word - This is not working. The PUT method is not supported by Unity.
        //Log.Debug("ExampleTextToSpeech", "Attempting to add a single word and translation to a custom voice model.");
        //string customIdentifierToAddWordAndTranslation = "1476ea80-5355-4911-ac99-ba39162a2d34";
        //string word = "grasshopper";
        //string translation = "guhrasshoppe";
        //if (!m_TextToSpeech.AddCustomizationWord(OnAddCustomizationWord, customIdentifierToAddWordAndTranslation, word, translation))
        //	Log.Debug("ExampleTextToSpeech", "Failed to add {0}/{1} to {2}!", word, translation, customIdentifierToAddWordAndTranslation);


        //m_TextToSpeech.Voice = VoiceType.en_US_Allison;
        //m_TextToSpeech.ToSpeech(m_TestString, HandleToSpeechCallback, true);
    }
Пример #52
0
        public override IEnumerable <Tuple <ShapeNode, ShapeNode> > Apply(Match <Word, ShapeNode> match, Word output)
        {
            Shape            shape      = _segments.Shape;
            var              mappings   = new List <Tuple <ShapeNode, ShapeNode> >();
            Span <ShapeNode> outputSpan = shape.CopyTo(shape.SpanFactory.Create(shape.First, shape.Last), output.Shape);

            foreach (ShapeNode outputNode in output.Shape.GetNodes(outputSpan))
            {
                mappings.Add(Tuple.Create((ShapeNode)null, outputNode));
            }
            return(mappings);
        }
Пример #53
0
 public IEnumerable <IWordCategory> GetMatchingWords(Word word)
 {
     return(this.contractions.Where(contraction => contraction.Text == word.Value));
 }
 bool IPhonologicalPatternSubruleSpec.IsApplicable(Word input)
 {
     return(true);
 }
Пример #55
0
        /// <summary>
        /// Given a S7 variable type (Bool, Word, DWord, etc.), it converts the bytes in the appropriate C# format.
        /// </summary>
        /// <param name="varType"></param>
        /// <param name="bytes"></param>
        /// <param name="varCount"></param>
        /// <param name="bitAdr"></param>
        /// <returns></returns>
        private object ParseBytes(VarType varType, byte[] bytes, int varCount, byte bitAdr = 0)
        {
            if (bytes == null || bytes.Length == 0)
            {
                return(null);
            }

            switch (varType)
            {
            case VarType.Byte:
                if (varCount == 1)
                {
                    return(bytes[0]);
                }
                else
                {
                    return(bytes);
                }

            case VarType.Word:
                if (varCount == 1)
                {
                    return(Word.FromByteArray(bytes));
                }
                else
                {
                    return(Word.ToArray(bytes));
                }

            case VarType.Int:
                if (varCount == 1)
                {
                    return(Int.FromByteArray(bytes));
                }
                else
                {
                    return(Int.ToArray(bytes));
                }

            case VarType.DWord:
                if (varCount == 1)
                {
                    return(DWord.FromByteArray(bytes));
                }
                else
                {
                    return(DWord.ToArray(bytes));
                }

            case VarType.DInt:
                if (varCount == 1)
                {
                    return(DInt.FromByteArray(bytes));
                }
                else
                {
                    return(DInt.ToArray(bytes));
                }

            case VarType.Real:
                if (varCount == 1)
                {
                    return(Types.Double.FromByteArray(bytes));
                }
                else
                {
                    return(Types.Double.ToArray(bytes));
                }

            case VarType.String:
                return(Types.String.FromByteArray(bytes));

            case VarType.StringEx:
                return(StringEx.FromByteArray(bytes));

            case VarType.Timer:
                if (varCount == 1)
                {
                    return(Timer.FromByteArray(bytes));
                }
                else
                {
                    return(Timer.ToArray(bytes));
                }

            case VarType.Counter:
                if (varCount == 1)
                {
                    return(Counter.FromByteArray(bytes));
                }
                else
                {
                    return(Counter.ToArray(bytes));
                }

            case VarType.Bit:
                if (varCount == 1)
                {
                    if (bitAdr > 7)
                    {
                        return(null);
                    }
                    else
                    {
                        return(Bit.FromByte(bytes[0], bitAdr));
                    }
                }
                else
                {
                    return(Bit.ToBitArray(bytes));
                }

            default:
                return(null);
            }
        }
Пример #56
0
    public void TypeLetter(char letter)
    {
        //Debug.Log("list of letters looks like:");
        //for (int i = 0; i < 5; i++) {
        //    Debug.Log(mWordSpawner.letters[i]);
        //}

        Debug.Log("Letter typed = " + letter);

        //typed all 5 letters
        if (letterIndex >= 5)
        {
            mHasActiveWord = false;
            mActiveWord    = null; //ignore that word now
            letterIndex    = 0;
        }

        //too long, word gone
        if (mTimer <= -5.0f)
        {
            mHasActiveWord = false;
            mActiveWord    = null;
            letterIndex    = 0;
        }

        //DEBUG
        if (mWordSpawner.letters.Count == 0)
        {
            Debug.Log("letters list is empty");
        }

        if (mHasActiveWord)
        {
            if (mActiveWord.GetNextLetter() == letter)
            {
                //Destroy(letterIntances[letterIndex].gameObject); //does this work?

                Debug.Log("LetterIndex = " + letterIndex);

                //check for null, cuz the letters destroy themselves after going past, but still end up saved in list.
                if (mWordSpawner.letters[letterIndex] != null)   //if not null
                {
                    Destroy(mWordSpawner.letters[letterIndex].gameObject);
                    letterIndex++;
                }

                //mActiveWord.TypeLetter();
            }
        }

        //else { //else if no word active, get the next matching active word
        //    foreach (Word word in mWords) {
        //        if (word.GetNextLetter() == letter) {
        //            mActiveWord = word;
        //            Debug.Log("New active word: " + mActiveWord.word);
        //            mHasActiveWord = true;
        //            word.TypeLetter(); //remove that letter from that word
        //            break;
        //        }
        //    }
        //}

        //redundant code?
        //if we completely typed that word
        //if (mHasActiveWord && mActiveWord.Completed()) {
        //    mHasActiveWord = false;
        //    letterIndex = 0; //reset letter index to 0 to be ready for new word
        //    //mWords.Remove(mActiveWord);
        //}
    }
Пример #57
0
 public Word(Word word)
 {
     this.word        = word.word;
     this.initialWord = word.initialWord;
     this.amount      = word.amount;
 }
Пример #58
0
        public void WordConstructor_ConstructsAWord_Word()
        {
            Word newWord = new Word("bunny");

            Assert.AreEqual(typeof(Word), newWord.GetType());
        }
Пример #59
0
        //Override the OnPrintPage to provide the printing logic for the document
        protected override void OnPrintPage(PrintPageEventArgs ev)
        {
            float lpp         = 0;
            float yPos        = 0;
            int   count       = 0;
            float leftMargin  = ev.MarginBounds.Left;
            float rightMargin = ev.MarginBounds.Right;
            float topMargin   = ev.MarginBounds.Top;

            //ev.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;

            if (rc == null)
            {
                Document.ParseAll();
                Document.ParseAll(true);


                rc = new RowCollection();
                foreach (Row r in Document)
                {
                    bool  hasbreak = false;
                    float x        = leftMargin;
                    Row   newRow   = new Row();
                    rc.Add(newRow);
                    foreach (Word w in r)
                    {
                        Font f = fontNormal;
                        if (w.Style != null)
                        {
                            FontStyle fs = 0;

                            if (w.Style.Bold)
                            {
                                fs |= FontStyle.Bold;
                            }

                            if (w.Style.Italic)
                            {
                                fs |= FontStyle.Italic;
                            }

                            if (w.Style.Underline)
                            {
                                fs |= FontStyle.Underline;
                            }

                            f = new Font("Courier new", 8, fs);
                        }
                        SizeF sf = ev.Graphics.MeasureString(w.Text, f);
                        if (x + sf.Width > rightMargin)
                        {
                            char chr = (char)0xbf;
                            Word br  = new Word();
                            br.Text    = chr + "";
                            br.InfoTip = "break char";
                            newRow.Add(br);
                            hasbreak = true;



                            newRow = new Row();
                            rc.Add(newRow);
                            x = leftMargin;
                        }
                        x += sf.Width;
                        newRow.Add(w);
                    }
                    if (hasbreak)
                    {
                        rc.Add(new Row());
                    }
                }
            }
            //------------------------------------------------------

            base.OnPrintPage(ev);



            lpp = ev.MarginBounds.Height / fontNormal.GetHeight(ev.Graphics);



            while (count < lpp && (RowIndex < rc.Count))
            {
                float x = leftMargin;
                yPos = topMargin + (count * fontNormal.GetHeight(ev.Graphics));

                Row r = rc[RowIndex];

                foreach (Word w in r)
                {
                    if (w.InfoTip != null && w.InfoTip == "break char")
                    {
                        ev.Graphics.DrawString(w.Text, fontBreak, Brushes.Black, x, yPos, new StringFormat());
                    }
                    else
                    {
                        SizeF sf = ev.Graphics.MeasureString(w.Text, fontNormal);

                        if (w.Text != null && (".,:;".IndexOf(w.Text) >= 0))
                        {
                            sf.Width = 6;
                            x       -= 4;
                        }
                        if (w.Text == "\t")
                        {
                            sf.Width = ev.Graphics.MeasureString("...", fontNormal).Width;
                        }


                        Color c = Color.Black;
                        Font  f = fontNormal;
                        if (w.Style != null)
                        {
                            c = w.Style.ForeColor;
                            FontStyle fs = 0;

                            if (w.Style.Bold)
                            {
                                fs |= FontStyle.Bold;
                            }

                            if (w.Style.Italic)
                            {
                                fs |= FontStyle.Italic;
                            }

                            if (w.Style.Underline)
                            {
                                fs |= FontStyle.Underline;
                            }

                            f = new Font("Courier new", 8, fs);

                            if (!w.Style.Transparent)
                            {
                                Color bg = w.Style.BackColor;
                                ev.Graphics.FillRectangle(new SolidBrush(bg), x, yPos, sf.Width, fontNormal.GetHeight(ev.Graphics));
                            }
                        }

                        c = Color.FromArgb(c.R, c.G, c.B);



                        ev.Graphics.DrawString(w.Text, f, new SolidBrush(c), x, yPos, new StringFormat());
                        x += sf.Width;
                    }
                }

                count++;
                RowIndex++;
            }

            //If we have more lines then print another page
            if (RowIndex < rc.Count)
            {
                ev.HasMorePages = true;
            }
            else
            {
                ev.HasMorePages = false;
            }
        }
Пример #60
0
 public WordViewModel()
 {
     Word = new Word();
 }