public Window(Game game) { this.Game = game; InitializeComponent(); // Give the game panel borders PanelGame.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; // ..and THEN find out the resolution GameWidth = PanelGame.ClientSize.Width - 2; GameHeight = PanelGame.ClientSize.Height - 2; Console.WriteLine("{0} {1} {2} {3}", GameWidth, GameHeight, PanelGame.Width, PanelGame.Height); // Create buffered graphics bufferContext = BufferedGraphicsManager.Current; bufferGraphics = bufferContext.Allocate(PanelGame.CreateGraphics(), new System.Drawing.Rectangle(0, 0, GameWidth, GameHeight)); // Get a Graphics object this.Graphics = bufferGraphics.Graphics; this.panelGraphics = this.PanelGame.CreateGraphics(); SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true); }
private void Form1_Load(object sender, EventArgs e) { GameGore = new Core(); GameGore.G = PanelGame.CreateGraphics(); }