DrawRect / FillRect not implemented in .net 2.0?
I have tried to make simple game with simple GDI+ graphics and during my tries I have found that I am unable to draw or fill rectangle inside OnPaint method
When I am drawiing just simple line with same parameters line is drawn correctly
My OnPaint Code Looks Like this
| |
Pen PlatformPen =new Pen(Color.White, 4); Brush PlatformBrush =new SolidBrush(Color.FromArgb(128, Color.WhiteSmoke)); e.Graphics.FillRectangle(PlatformBrush, Platforma.Offset.X, Platforma.Offset.Y, Platforma.CurrentSize.Width, Platforma.CurrentSize.Height); e.Graphics.DrawRectangle(PlatformPen, Platforma.Offset.X, Platforma.Offset.Y, Platforma.CurrentSize.Width, Platforma.CurrentSize.Height); e.Graphics.DrawLine(PlatformPen, Platforma.Offset.X, Platforma.Offset.Y, Platforma.CurrentSize.Width, Platforma.CurrentSize.Height); PlatformPen.Dispose(); PlatformBrush.Dispose();
|
I change you code a little and tried it on a form and it worked fine:
| | private void Form1_Paint(object sender, PaintEventArgs e) { Pen PlatformPen = new Pen(Color.White, 4); Brush PlatformBrush = new SolidBrush(Color.FromArgb(128, Color.Aqua)); e.Graphics.FillRectangle(PlatformBrush, ClientRectangle); e.Graphics.DrawRectangle(PlatformPen, ClientRectangle); PlatformPen.Dispose(); PlatformBrush.Dispose(); } |
The only thing I can think of is your calculatations for the height and width are wrong.