private void BtnCreate_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; m_board = new CBoard(NudWidth.Value, NudHeight.Value); m_color_gnrtr = new CColorGenerator(); PnlInit.Enabled = false; draw_board(); Cursor = Cursors.Default; }
/* --------------------------------------------------------------------------------- *\ * Description: * Paint and count all islands * * Parameters: * CBoard _board: * CColorGenerator _color_generator: * * Returns int: \* --------------------------------------------------------------------------------- */ public static int paint(CBoard _board, CColorGenerator _color_generator) { int n_isle_count = 0; for (int y = 0; y < _board.height; y++) { for (int x = 0; x < _board.width; x++) { int n_pixel_ind = _board.pixel_ind(x, y); if (!_board.is_black_pixel(n_pixel_ind)) { continue; } n_isle_count++; paint_isle(x, y, n_pixel_ind, _color_generator.generate_color(), _board); } } return(n_isle_count); }