protected override void OnPaint(PaintEventArgs e) { Graphics dc = e.Graphics; if (splat == true) { _splat.DrawImage(dc); } else { } _sign.DrawImage(dc); _scoreFrame.DrawImage(dc); #if My_Debug TextFormatFlags flags = TextFormatFlags.Left | TextFormatFlags.EndEllipsis; Font _font = new System.Drawing.Font("Stencil", 12, FontStyle.Regular); TextRenderer.DrawText(dc, "X=" + _cursX.ToString() + ":" + "Y=" + _cursY.ToString(), _font, new Rectangle(0, 0, 120, 20), SystemColors.ControlText, flags); #endif _mole.DrawImage(dc); base.OnPaint(e); }
protected override void OnPaint(PaintEventArgs e) { Graphics dc = e.Graphics; if (splat == true) { _splat.DrawImage(dc); } else { _mole.DrawImage(dc); } _sign.DrawImage(dc); _scoreframe.DrawImage(dc); #if My_Debug TextFormatFlags flag = TextFormatFlags.Left | TextFormatFlags.EndEllipsis; Font _fontt = new System.Drawing.Font("Stencil", 12, FontStyle.Regular); TextRenderer.DrawText(dc, "X = " + _cursX.ToString() + ":" + "Y=" + _cursY.ToString(), _fontt, new Rectangle(0, 0, 120, 20), SystemColors.ControlText, flag); #endif TextFormatFlags flags = TextFormatFlags.Left; Font _font = new System.Drawing.Font("Stencil", 14, FontStyle.Regular); TextRenderer.DrawText(e.Graphics, "Shots :" + _totalShots.ToString(), _font, new Rectangle(40, 62, 120, 20), SystemColors.ControlText, flags); TextRenderer.DrawText(e.Graphics, "Misses :" + _hits.ToString(), _font, new Rectangle(40, 82, 120, 20), SystemColors.ControlText, flags); TextRenderer.DrawText(e.Graphics, "Hits :" + _misses.ToString(), _font, new Rectangle(40, 102, 120, 20), SystemColors.ControlText, flags); TextRenderer.DrawText(e.Graphics, "Avg :" + _averageHits.ToString("F0") + "%", _font, new Rectangle(40, 122, 120, 20), SystemColors.ControlText, flags); base.OnPaint(e); }
//using OnPaint() method to draw objects on game background //using System.Drawing ( GDI+) protected override void OnPaint(PaintEventArgs e) { Graphics dc = e.Graphics; //if splat == true then draw object _splat if (splat == true) { _splat.DrawImage(dc); } //else draw _mole object else { _mole.DrawImage(dc); } //_splat.DrawImage(dc); //always draw _sign and _scoreframe object as they are at fixed position during game _sign.DrawImage(dc); _scoreframe.DrawImage(dc); #if My_Debug TextFormatFlags flag = TextFormatFlags.Left | TextFormatFlags.EndEllipsis; Font _fontt = new System.Drawing.Font("Stencil", 12, FontStyle.Regular); TextRenderer.DrawText(dc, "X = " + _cursX.ToString() + ":" + "Y=" + _cursY.ToString(), _fontt, new Rectangle(0, 0, 120, 20), SystemColors.ControlText, flag); #endif //Put score on screen TextFormatFlags flags = TextFormatFlags.Left; Font _font = new System.Drawing.Font("Stencil", 14, FontStyle.Regular); TextRenderer.DrawText(e.Graphics, "Shots :" + _totalShots.ToString(), _font, new Rectangle(40, 62, 120, 20), SystemColors.ControlText, flags); TextRenderer.DrawText(e.Graphics, "Misses :" + _hits.ToString(), _font, new Rectangle(40, 82, 120, 20), SystemColors.ControlText, flags); TextRenderer.DrawText(e.Graphics, "Hits :" + _misses.ToString(), _font, new Rectangle(40, 102, 120, 20), SystemColors.ControlText, flags); TextRenderer.DrawText(e.Graphics, "Avg :" + _averageHits.ToString("F0") + "%", _font, new Rectangle(40, 122, 120, 20), SystemColors.ControlText, flags); base.OnPaint(e); }