private void btnSelectAll_Click(object sender, EventArgs e) { var pctb = (PictureBox)tbcMain.SelectedTab.Controls[0]; var ti = TileHandler.GetTileImage((TileTab)tbcMain.SelectedIndex); if (TileHandler.SelectedTiles.Count != ti.NumberOfTiles) { TileHandler.SelectAll((TileTab)tbcMain.SelectedIndex); } else { TileHandler.DeselectAll((TileTab)tbcMain.SelectedIndex); } ReloadSelectedTilesPanel(); pctb.Invalidate(); }