internal void RefreshGrid()
{
Point currSelection = grid.SelectionIndex;
GetSortedGridElements(refreshGrid_scratch);
for (int i = 0; i < grid.ActualDimensions.Y; ++i)
{
UIGridShareHubElement elem = grid.Get(0, i) as UIGridShareHubElement;
elem.Selected = false;
if (!refreshGrid_scratch.Contains(elem))
{
BokuGame.Unload(elem);
}
}
grid.Clear();
for (int i = 0; i < refreshGrid_scratch.Count; ++i)
{
grid.Add(refreshGrid_scratch[i], 0, grid.ActualDimensions.Y);
BokuGame.Load(refreshGrid_scratch[i]);
}
grid.Dirty = true;
// Try to preserve selection index.
// We might want to try to relocate the selected element if it moved instead.
if (grid.ActualDimensions.Y > currSelection.Y)
{
grid.SelectionIndex = new Point(0, currSelection.Y);
}
else if (grid.ActualDimensions.Y > 0)
{
grid.SelectionIndex = new Point(0, grid.ActualDimensions.Y - 1);
}
Matrix parentMatrix = Matrix.Identity;
grid.Update(ref parentMatrix);
}