Rectangle GetSelectionRectArea()
{
if (selectedLines != null)
{
int j = selectedLines.Count;
//first
if (j > 0)
{
CssBox ownerCssBox = null;
CssBox rootbox = null;
float fx1 = 0, fy1 = 0; //left top
RectangleF selArea = RectangleF.Empty;
//if (j ==1)
//{
//}
for (int i = 0; i < j; ++i)
{
var line = selectedLines[i];
if (line.OwnerBox != ownerCssBox)
{
ownerCssBox = line.OwnerBox;
rootbox = ownerCssBox.GetGlobalLocationRelativeToRoot(out fx1, out fy1);
}
if (i == 0)
{
selArea = new RectangleF(fx1,
fy1 + line.CachedLineTop,
line.CachedLineContentWidth,
line.CacheLineHeight);
}
else
{
selArea = RectangleF.Union(selArea,
new RectangleF(fx1,
fy1 + line.CachedLineTop,
line.CachedLineContentWidth,
line.CacheLineHeight));
}
}
//if want to debug then send a big rect
//Console.WriteLine(new Rectangle((int)selArea.X, (int)selArea.Y, (int)selArea.Width, (int)selArea.Height).ToString());
//return new Rectangle(0, 0, 800, 600);
return new Rectangle((int)selArea.X, (int)selArea.Y, (int)selArea.Width, (int)selArea.Height);
}
}
return Rectangle.Empty;
}
//======================================================================================