From b0d3e59a755491a80d8eb3aac534af312d476398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Thu, 8 May 2014 01:00:42 +0200 Subject: [PATCH] Gui flackert jetzt beim neu zeichnen nicht mehr --- src/Gui/Gui.cs | 1 - src/Gui/MapPanel.cs | 8 +++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Gui/Gui.cs b/src/Gui/Gui.cs index d96ea2a..a9e5a93 100644 --- a/src/Gui/Gui.cs +++ b/src/Gui/Gui.cs @@ -74,7 +74,6 @@ namespace WorldOfPeacecraft ChatPanel.Location = new Point (MapPanel.Width, 0); ChatPanel.Size = new Size (ChatWidth, MapPanel.Height); this.ResumeLayout(); - this.PerformLayout(); ChatPanel.UpdateData (); this.Refresh(); })); diff --git a/src/Gui/MapPanel.cs b/src/Gui/MapPanel.cs index 8fb5091..82a6965 100644 --- a/src/Gui/MapPanel.cs +++ b/src/Gui/MapPanel.cs @@ -25,8 +25,8 @@ namespace WorldOfPeacecraft public MapPanel (IBackend backend) { + SetStyle (ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); Backend = backend; - this.Paint += DoPaint; this.PreviewKeyDown += board_KeyPress; BowAndArrow = Image.FromFile (ImagesFolder + "bow-and-arrow.png", false); Dragon1 = Image.FromFile (ImagesFolder + "dragon1.png"); @@ -76,15 +76,13 @@ namespace WorldOfPeacecraft Backend.MoveTo (targetX, targetY); } - public void DoPaint (object source, PaintEventArgs args) + protected override void OnPaint (PaintEventArgs e) { - BufferedGraphics buffer = BufferedGraphicsManager.Current.Allocate (this.CreateGraphics (), this.DisplayRectangle); - Graphics g = buffer.Graphics; + Graphics g = e.Graphics; lock (Backend) { PaintMap (g); PaintEntities (g); } - buffer.Render(); } public void PaintMap (Graphics g)