I have a list of Objects which have a location [Rect].
I then select from this list, all Rects that fall inside a 'Column' (Left>x1 && Right<x2)
What I need to to now is find all Rects that are (roughly) in-line horizontally with each item in that list.
The only way I have found so far is to iterate over the list and check each rect individually for its Top value, but I feel this should be a lambda function.
Iterating code is as follows:
// Find all shapes on the page within these bounds
var BottomLeft = new Point(50, 45);
var TopRight = new Point(430, 770);
var allRects = allShapes.Where(sh => sh.BoundingBox.Bottom >= BottomLeft.Y
&& sh.BoundingBox.Left >= BottomLeft.X
&& sh.BoundingBox.Top <= TopRight.Y
&& sh.BoundingBox.Right <= TopRight.X).OrderByDescending(tb => tb.BoundingBox.Top);
// Select the rightmost column
var Col = allRects.Where(rt => rt.BoundingBox.Left > 365);
foreach (var rt in Col)
{
var rct = allRects.Where(tb => Math.Abs(tb.BoundingBox.Top - rt.BoundingBox.Top) < 2);
/// etc...
}
How would I convert the foreach loop into a lambda query?
etc...is the most important part to understand what your expected result is.