private void GameFormMode1_Paint(object sender, PaintEventArgs e) { if (next_game_shown) { AnotherGame.Show(); } else { AnotherGame.Hide(); } // draw playing area // it goes first by the colls - X for (int i = 0; i < this.settings.cols; i++) { for (int j = 0; j < this.settings.rows; j++) { Pen blackPen = new Pen(Color.Black, 1); e.Graphics.DrawRectangle(blackPen, i * this.settings.cell_size + INDENT_X, j * this.settings.cell_size + INDENT_Y, this.settings.cell_size, this.settings.cell_size); } } // draw blocks foreach (Block block in positionedBlocks) { block.Kresli(e.Graphics); } if (showWin) { Graphics g = e.Graphics; Bitmap main_image = new Bitmap("smile.png"); next_game_shown = true; Color backColor = main_image.GetPixel(1, 1); main_image.MakeTransparent(backColor); e.Graphics.DrawImage( main_image, this.Width - 100, 0, 64, 64); } }
private void GameFormMode2_Paint(object sender, PaintEventArgs e) { if (next_game_shown) { AnotherGame.Show(); } else { AnotherGame.Hide(); } // map block id to its color foreach (Block block in this.settings.blocks) { if (!idcolor_map.ContainsKey(block.id)) { idcolor_map.Add(block.id, block.color); } } Control control = (Control)sender; int local_indentX = INDENT_X + (settings.cols * settings.cell_size) + settings.cell_size; int local_indentY = INDENT_Y; for (int i = 0; i < this.settings.cols; i++) { for (int j = 0; j < this.settings.rows; j++) { // draw playing area Pen blackPen = new Pen(Color.Black, 1); e.Graphics.DrawRectangle(blackPen, i * this.settings.cell_size + INDENT_X, j * this.settings.cell_size + INDENT_Y, this.settings.cell_size, this.settings.cell_size); // draw final state example area e.Graphics.DrawRectangle(blackPen, i * this.settings.cell_size + local_indentX, j * this.settings.cell_size + local_indentY, this.settings.cell_size, this.settings.cell_size); if (idcolor_map.ContainsKey(settings.playground[j, i])) { Color c = idcolor_map[settings.playground[j, i]]; Brush brush = new SolidBrush(c); e.Graphics.FillRectangle(brush, i * this.settings.cell_size + local_indentX, j * this.settings.cell_size + local_indentY, this.settings.cell_size, this.settings.cell_size); } } } // draw blocks last foreach (Block block in settings.blocks) { block.Kresli(e.Graphics); } if (showWin) { Graphics g = e.Graphics; Bitmap main_image = new Bitmap("smile.png"); next_game_shown = true; Color backColor = main_image.GetPixel(1, 1); main_image.MakeTransparent(backColor); e.Graphics.DrawImage( main_image, this.Width - 100, 0, 64, 64); } }