private Polygon AddCell(Honeycomb.Cell <long> cell, int cols, int rows, double width, double height, double cellSize) { Point pt = ConvertCellCoords(cell, cols, rows, width, height, cellSize); var hexagon = CreateHexagon(pt, cellSize); honeycombPanel.Children.Add(hexagon); cells[cell.Key] = hexagon; return(hexagon); }
private Point ConvertCellCoords(Honeycomb.Cell <long> cell, int cols, int rows, double width, double height, double cellSize) { var pt = new Point(); // re-origin to top-left int x = cell.Column - walkerViewModel.Honeycomb.Left; int y = walkerViewModel.Honeycomb.Top - cell.Row; // offsets from top and left double xOffset = cellSize * 2; double yOffset = cellSize; // axis factors double xFactor = Math.Min((width - (2 * xOffset)) / cols, (height - (2 * yOffset)) / rows); double yFactor = xFactor; // pt.X = (x * xFactor * 1.5) + xOffset; pt.Y = (y * (yFactor / 1.25)) + yOffset; return(pt); }