Exemplo n.º 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;
            }
        }
Exemplo n.º 2
0
 private void InsertSpaceNegotiationSpans()
 {
     if (_spaceNegotiationList != null)
     {
         NormalizedSpan span = _startNode;
         foreach (SpaceNegotiation negotiation in _spaceNegotiationList)
         {
             TextRun textRun = new TextEmbeddedSpace(negotiation.Size);
             span = span.AddNode(new NormalizedSpan(textRun, (Int32)negotiation.TextPosition));
             _virtualCharacterPositions.Add(((Int32)negotiation.TextPosition) - _startCharacterIndex);
         }
     }
 }
Exemplo n.º 3
0
		public NormalizedSpan AddNode(NormalizedSpan span)
		{
			if (span.StartCharacterIndex > (this.StartCharacterIndex + this.Length))
			{
				return this.Next.AddNode(span);
			}
			if (_canSplitOrMerge && (span.StartCharacterIndex < (this.StartCharacterIndex + this.Length)))
			{
				Int32 startCharacterIndex = span.StartCharacterIndex;
				NormalizedSpan span2 = new NormalizedSpan(_text.Substring(startCharacterIndex - this.StartCharacterIndex), _classification, startCharacterIndex, _properties);
				_length = startCharacterIndex - this.StartCharacterIndex;
				_text = _text.Substring(0, _length);
				this.AddNode(span);
				return span.AddNode(span2);
			}
			span.Previous = this;
			if (this.Next != null)
			{
				span.Next = this.Next;
				this.Next.Previous = span;
			}
			this.Next = span;
			return span;
		}
Exemplo n.º 4
0
 public NormalizedSpan AddNode(NormalizedSpan span)
 {
     if (span.StartCharacterIndex > (this.StartCharacterIndex + this.Length))
     {
         return(this.Next.AddNode(span));
     }
     if (_canSplitOrMerge && (span.StartCharacterIndex < (this.StartCharacterIndex + this.Length)))
     {
         Int32          startCharacterIndex = span.StartCharacterIndex;
         NormalizedSpan span2 = new NormalizedSpan(_text.Substring(startCharacterIndex - this.StartCharacterIndex), _classification, startCharacterIndex, _properties);
         _length = startCharacterIndex - this.StartCharacterIndex;
         _text   = _text.Substring(0, _length);
         this.AddNode(span);
         return(span.AddNode(span2));
     }
     span.Previous = this;
     if (this.Next != null)
     {
         span.Next          = this.Next;
         this.Next.Previous = span;
     }
     this.Next = span;
     return(span);
 }
		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;
			}
		}