using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
namespace Inet.Viewer.Data
{
///
/// Represents a subsequence of characters in a text block.
///
public class TextBlockRange
{
private TextBlock block;
private RectangleF bbox;
private int startIndex;
private int endIndex;
///
/// Creates an instance.
///
/// the text block
/// the first character of the subsequence
/// the last character of the subsequence
public TextBlockRange(TextBlock block, int startIndex, int endIndex)
{
this.block = block;
this.startIndex = startIndex;
this.endIndex = endIndex;
this.SubString = block.Text.Substring(startIndex, endIndex - startIndex);
// compute the bounding box from the individual character bounding boxes
bbox = block.CharacterBounds[startIndex];
for (int i = 1 + startIndex; i < endIndex; i++)
{
bbox = RectangleF.Union(bbox, block.CharacterBounds[i]);
}
}
///
/// The bounding box of the character subsequence.
///
public System.Drawing.RectangleF BBox { get { return bbox; } }
///
/// The string of the character subsequeunce.
///
public string SubString { get; set; }
}
}