Exemple #1
0
        private void CreateNormalizedSpans()
        {
            Int32          startCharacterIndex = _startCharacterIndex;
            Int32          length = _text.Length;
            NormalizedSpan span   = new NormalizedSpan("", "_gap_", _startCharacterIndex, TextFormattingRunProperties.DefaultProperties);

            _startNode = span;
            for (Int32 i = 0; i < _classificationSpanList.Count; i++)
            {
                ClassificationSpan span2 = _classificationSpanList[i];
                Span span3 = span2.Span();
                if (span3.Start >= (_startCharacterIndex + length))
                {
                    break;
                }
                Int32 num4 = span3.Start - startCharacterIndex;
                if (num4 > 0)
                {
                    NormalizedSpan span4 = new NormalizedSpan(_text.Substring(startCharacterIndex - _startCharacterIndex, span3.Start - startCharacterIndex), "_gap_", startCharacterIndex, TextFormattingRunProperties.DefaultProperties);
                    span = span.AddNode(span4);
                    startCharacterIndex += num4;
                }
                else if (num4 < 0)
                {
                    Int32 num5 = span3.Length + num4;
                    if (num5 <= 0)
                    {
                        continue;
                    }
                    span3 = new Span(startCharacterIndex, num5);
                }
                if (span3.Length > 0)
                {
                    Int32 num6 = startCharacterIndex - _startCharacterIndex;
                    TextFormattingRunProperties textProperties = _classificationFormatMap.GetTextProperties(span2.Classification);
                    if ((span3.Length + num6) > length)
                    {
                        Int32          num7  = length - num6;
                        NormalizedSpan span5 = new NormalizedSpan(_text.Substring(span3.Start - _startCharacterIndex, num7), span2.Classification, span3.Start, textProperties);
                        span = span.AddNode(span5);
                        startCharacterIndex = _startCharacterIndex + length;
                        break;
                    }
                    NormalizedSpan span6 = new NormalizedSpan(_text.Substring(span3.Start - _startCharacterIndex, span3.Length), span2.Classification, span3.Start, textProperties);
                    span = span.AddNode(span6);
                    startCharacterIndex += span3.Length;
                }
            }
            if (startCharacterIndex < (_startCharacterIndex + length))
            {
                Int32          num8  = length - (startCharacterIndex - _startCharacterIndex);
                NormalizedSpan span7 = new NormalizedSpan(_text.Substring(startCharacterIndex - _startCharacterIndex, num8), "_gap_", startCharacterIndex, TextFormattingRunProperties.DefaultProperties);
                span = span.AddNode(span7);
            }
            if (_startNode.Next != null)
            {
                _startNode          = _startNode.Next;
                _startNode.Previous = null;
            }
        }