public partial class GameForm : Form { Form parentF = null; Bitmap bitmap = null; Graphics bitmapGraphics = null; SolidBrush blackSBrush = null; int gameRectW = 0; int gameRectH = 0; Map map = null; public GameForm(Form parentF) { this.parentF = parentF; InitializeComponent(); InitializePaintbox(); InitializateMap(); Repaint(); parentF.Visible = false; } private void InitializePaintbox() { gameRectW = 760; bitmap = new Bitmap(gameRectW, gameRectH); bitmapGraphics = Graphics.FromImage(bitmap); blackSBrush = new SolidBrush(Color.Black); } private void Repaint() { bitmapGraphics.FillRectangle(blackSBrush, 0, 0, gameRectW, gameRectH); map.Repaint(bitmapGraphics); gamePictureBox.BackgroundImage = bitmap; } private void InitializateMap() { map = new Map(8,8,60); } private void GameForm_FormClosing(object sender, FormClosingEventArgs e){ parentF.Visible = true; } }