Ejemplo n.º 1
0
            private void InitFromColourControlItems(IEnumerable<ColourControlItem> items)
            {
                foreach (var colourControlItem in items)
                {
                    ProcessColourControlItem(colourControlItem);
                }
                StoreCurrentIfPresent();

                if (_cachedPrefixInstructions.Any())
                {
                    var lastWord = new SplitWord(0, 0, string.Empty);
                    lastWord.AddPrefixInstructions(_cachedPrefixInstructions);
                    Words.Add(lastWord);
                }
            }
Ejemplo n.º 2
0
            private void ProcessColourControlItem(ColourControlItem colourControlItem)
            {
                if (colourControlItem.PrefixAffinity && string.IsNullOrEmpty(colourControlItem.Text))
                {
                    _cachedPrefixInstructions.AddRange(colourControlItem.Instructions);

                    StoreCurrentIfPresent();
                    return;
                }

                if (!string.IsNullOrEmpty(colourControlItem.Text))
                {
                    StoreCurrentIfPresent();

                    var splitWords = SplitWords(colourControlItem.Text, _tabLength);
                    if (splitWords.Any())
                    {
                        splitWords.First().AddPrefixInstructions(_cachedPrefixInstructions);
                        _cachedPrefixInstructions.Clear();
                    }

                    if (splitWords.Length > 1)
                        Words.AddRange(splitWords.Take(splitWords.Length - 1));

                    _current = splitWords[splitWords.Length - 1];
                }
                else if (InstructionIsNewLineOnly(colourControlItem))
                {
                    StoreCurrentIfPresent();
                    _current = new SplitWord(0, 0, string.Empty);
                    _current.AddPrefixInstructions(_cachedPrefixInstructions);
                    _current.AddSuffixInstructions(colourControlItem.Instructions);
                    _cachedPrefixInstructions.Clear();
                }
                else
                    AddSuffixInstructionsToCurrent(colourControlItem.Instructions);
            }
Ejemplo n.º 3
0
            private void AddSuffixInstructionsToCurrent(List<ColourControlItem.ControlInstruction> instructions)
            {
                if (_current == null)
                {
                    _current = new SplitWord(0, 0, string.Empty);
                    _current.AddPrefixInstructions(_cachedPrefixInstructions);
                    _cachedPrefixInstructions.Clear();
                }

                _current.AddSuffixInstructions(instructions);
            }