BattleShip.GameBoard.Display C# (CSharp) Метод

Display() публичный Метод

Drawing the board game
public Display ( PaintEventArgs pe ) : void
pe PaintEventArgs Element graphics
Результат void
        public void Display(PaintEventArgs pe)
        {
            foreach (casePlatform c in this.Board)
                c.DisplayCase(pe.Graphics);

            foreach (Label l in this.Coordinates)
                pe.Graphics.DrawString(l.Text, l.Font, new SolidBrush(Color.Red), new Point(l.Location.X + l.Size.Width / 2 - (int)(l.Font.Size / 2), l.Location.Y + l.Size.Height / 2 - (int)(l.Font.Size / 2)));

            pe.Graphics.DrawString(LblPlayer.Text, LblPlayer.Font, new SolidBrush(Color.Black), LblPlayer.Location);

            pe.Graphics.FillEllipse(new SolidBrush(this.ElipseColor), this.Location.X, this.Location.Y, 20, 20);
        }

Usage Example

Пример #1
0
        /// <summary>
        /// Display each platform + ship
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            platAlly.Display(e);
            platEnemy.Display(e);


            foreach (Ship ship in ships)
            {
                ship.drawShip(e.Graphics);
            }

            /*if (!gameInProgress)
             * {
             *  foreach (Cendre c in cendres)
             *  {
             *      c.OnPaint(e);
             *  }
             * }*/

            if (gameover != null)
            {
                gameover.Draw(e);
            }
        }