Пример #1
0
        public void AddSpan(int index, int length, string lang, string style, string url)
        {
            var span = new FormatSpan {
                Index = index, Length = length, Lang = lang, Class = style, LinkURL = url
            };

            _spans.Add(span);
        }
Пример #2
0
 private static void AdjustSpan(FormatSpan span, int location, int length)
 {
     if (span.Length <= 0)
     {
         return;                         // we've already deleted all the characters in the span.
     }
     if (location > span.Index + span.Length || length == 0)
     {
         return;                         // the change doesn't affect the span.
     }
     // Adding characters to the end of the span is probably desireable if they differ.
     if (length > 0)
     {
         // Inserting characters is fairly easy to deal with.
         if (location <= span.Index)
         {
             span.Index += length;
         }
         else
         {
             span.Length += length;
         }
     }
     // The span changes only if the deletion starts before the end of the span.
     else if (location < span.Index + span.Length)
     {
         // Deleting characters has a number of cases to deal with.
         // Remember, length is a negative number here!
         if (location < span.Index)
         {
             if (span.Index + length >= location)
             {
                 span.Index += length;
             }
             else
             {
                 int before = span.Index - location;
                 span.Index   = location;
                 span.Length += (before + length);
             }
         }
         else
         {
             span.Length += length;
             if (span.Length < location - span.Index)
             {
                 span.Length = location - span.Index;
             }
         }
     }
 }
Пример #3
0
    private static FormatSpan?HighlightSpan(FormatSpan currentHighlight, List <Cell> cells, int cellIndex, int endPosition)
    {
        var highlightedFullWidthOffset = 0;
        int i;

        for (i = cellIndex; i < Math.Min(endPosition + currentHighlight.Length + highlightedFullWidthOffset, cells.Count); i++)
        {
            highlightedFullWidthOffset += cells[i].ElementWidth - 1;
            cells[i].Formatting         = currentHighlight.Formatting;
        }
        if (i != cells.Count)
        {
            return(null);
        }

        return(currentHighlight);
    }