Hi Stoyo,
I realise that this problem may be out of your area of control, but I thought I'd mention it, in case you can provide some insight, or have seen it before.
I am trying to get a sorted list of the Boxes on a chart, first by their X, then Y, coordinates, for example
{0,1} {0,2} {0,3} {1,0} {1,3} etc
I decided to use LINQ for Objects for its simplicity.
First to get a List that LINQ could work with I added a method (performance-wise, not an ideal start. If I can get it working, I'll probably eventually override the GetEnumerator() method and add an orderBy Extension):
private static List<Box> GetBoxesAsList(FlowChart chart)
{
List<Box> boxes = new List<Box>();
foreach (Box box in chart.Boxes)
{
boxes.Add(box);
}
return boxes;
}
This returns a List of Type Box, and in the debugger their positions are apparently in a random (in fact order of added) order.
I then added an extension method to the chart
public static List<Box> GetBoxesByPosition(this FlowChart chart, Orientation orientation)
{
if (orientation == Orientation.Auto)
orientation = Orientation.Horizontal;
var result = from b in chart.GetBoxesAsList()
orderby orientation == Orientation.Horizontal ? b.BoundingRect.X : b.BoundingRect.Y,
orientation == Orientation.Horizontal ? b.BoundingRect.Y : b.BoundingRect.X
select b;
return result.ToList<Box>();
}
but the outcome always gave me a list of Boxes at position (5.0, 5.0) (they were different boxes, just with their positions reset)
To see if I was mucking something up with my orierntation condition, or the double order, I first tried
orderby b.BoundingRect.X, b.BoundingRect.Y
and
orderby b.BoundingRect.X
but still every box was getting its position reset to (5.0, 5.0)
I thought I'd try simple lambda (I can't believe I used the term 'simple' and the term 'lambda' next to each other)
return GetBoxesAsList(chart).OrderBy(p => p.BoundingRect.X).ThenBy(p => p.BoundingRect.Y).ToList();
but still 5,5
I even tried specifying p.BoundingRect.Location.X and Y, but by then I was getting the strong impression that I was just doing the same thing over and over in a different way.
I am wondering if the Location Coordinates 5.0, 5.0 give any hints to what might be going on.
I am now facing the realisation that I am going to have to code up my own sorting algorithm
![Sad Sad](https://mindfusion.eu/yabbfiles/Templates/Forum/default/sad.gif)
dammit
Thanks in advance for any advice you may give
JC