Ejemplo n.º 1
0
 /// <summary>Clears and the reloads all the Tiles contained in the control.</summary>
 private void RegenerateTiles()
 {
     this.Children.Clear();
     for (int x = -1; x < _columns; ++x)
     {
         for (int y = -1; y < _rows; ++y)
         {
             Tile tile = _mapControlFactory.GetTile(this.Zoom, this.LeftTile + x, this.TopTile + y);
             tile.Column = x;
             tile.Row = y;
             Canvas.SetLeft(tile, _mapControlFactory.TileGenerator.TileSize * x);
             Canvas.SetTop(tile, _mapControlFactory.TileGenerator.TileSize * y);
             this.Children.Add(tile);
         }
     }
     _baseTile = (Tile)this.Children[0];
 }
Ejemplo n.º 2
0
 /// <summary>Repositions the Tiles after any changes.</summary>
 /// <param name="changeTile">Called on every Tile to allow changes to be made to its position.</param>
 private void ChangeTiles(Action<Tile> changeTile)
 {
     _baseTile = (Tile)this.Children[0]; // We need something to compare to so set it to the first.
     for (int i = 0; i < this.Children.Count; ++i)
     {
         Tile tile = (Tile)this.Children[i];
         changeTile(tile);
         Canvas.SetLeft(tile, _mapControlFactory.TileGenerator.TileSize * tile.Column);
         Canvas.SetTop(tile, _mapControlFactory.TileGenerator.TileSize * tile.Row);
         if (tile.TileX <= _baseTile.TileX && tile.TileY <= _baseTile.TileY) // Find the upper left tile
         {
             _baseTile = tile;
         }
     }
 }