public TableLayout(PaintedTiles paintedTiles, int tileCountOnTable, int columnCount) { if (paintedTiles == null) { throw new ArgumentNullException("paintedTiles"); } if (paintedTiles.Count < tileCountOnTable) { throw new ArgumentOutOfRangeException("tileCountOnTable", tileCountOnTable, "Number of places on the table must smaller or equal than number of available tiles (paintedTiles)!"); } this.paintedTiles = paintedTiles; this.tileCountOnTable = tileCountOnTable; this.columnCount = columnCount; this.physicalLayout = this.BuildPhysicalLayout(); // preallocating arrays to store available tiles at every single recursion level independently this.availableTilesInLevels = new int[this.tileCountOnTable][]; for (int i = 0; i < this.tileCountOnTable; i++) { // number of available tiles = number of paintedTiles - already placed tiles on table at the level of recursion this.availableTilesInLevels[i] = new int[this.PaintedTileCount - i]; } this.actualTileSequence = new TileSequence(this.tileCountOnTable); this.resultTileSequences = new List <TileSequence>(); }
public Size DrawTileSequence(Graphics graph, TileSequence tileSequenceToDraw) { var tileSize = new Size(); for (int i = 0; i < tileSequenceToDraw.Count; i++) { var containerState = graph.BeginContainer(); var paintedTile = this.paintedTiles[tileSequenceToDraw[i].TileId]; tileSize = new Size(paintedTile.TileTemplate.FrameRectangle.Width, paintedTile.TileTemplate.FrameRectangle.Height); graph.TranslateTransform( this.physicalLayout[i].X * tileSize.Width, this.physicalLayout[i].Y * tileSize.Height); paintedTile.Rotation = tileSequenceToDraw[i].Rotation; paintedTile.DrawTile(graph); graph.EndContainer(containerState); } return(new Size( tileSize.Width * this.columnCount, tileSize.Height * ((int)Math.Floor((double)tileSequenceToDraw.Count / (double)this.columnCount)))); }
public object Clone() { // deep clone var clone = new TileSequence(this.Count); for (int i = 0; i < this.Count; i++) { clone[i] = (TileSequenceItem)this[i].Clone(); } return(clone); }