private IEnumerable<List<Point>> GetNeighboringColors(int x, int y)
{
var results = new List<List<Point>>();
var result = new List<Point>();
results.Add(result);
var currentPoint = new Point { X = x, Y = y };
this._colorsProcessed[x, y] = true;
result.Add(currentPoint);
var processQueue = new List<Point> { currentPoint };
int i = 0;
while (processQueue.Count > i)
{
Point neighbor = processQueue.ElementAt(i);
i++;
foreach (Point newNeighbor in this.GetMatchingUnprocessedDirectNeighbors(neighbor.X, neighbor.Y))
{
this._colorsProcessed[newNeighbor.X, newNeighbor.Y] = true;
if (!AreDirectNeighbors(result.Last(), newNeighbor))
{
result = new List<Point>();
results.Add(result);
}
processQueue.Insert(i, newNeighbor);
result.Add(newNeighbor);
}
}
return results;
}