kstanoev
1/28/2015 - 9:16 AM

ArrangeOverride of the HoneycombPanel

ArrangeOverride of the HoneycombPanel

protected override Size ArrangeOverride(Size finalSize)
{
	int row, column;
	double x, y, height, width;

	for (int i = 0; i < this.Children.Count; i++)
	{
		height = this.Children[i].DesiredSize.Height;
		width = COS_30_DEGREE * height;
		row = HoneycombPanel.GetRow(this.Children[i]);
		column = HoneycombPanel.GetColumn(this.Children[i]);

		x = row % 2 == 0 ? column * width : (0.5 * width + column * width);
		y = 0.75 * row * height;

		this.Children[i].Arrange(new Rect(new Point(x, y), this.Children[i].DesiredSize));
	}

	return base.ArrangeOverride(finalSize);
}