33 lines
955 B
C#
33 lines
955 B
C#
using System.Drawing;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Forms;
|
|
|
|
namespace WorldOfPeacecraft
|
|
{
|
|
public class OnlinePlayerList : Panel
|
|
{
|
|
private IBackend Backend;
|
|
|
|
public OnlinePlayerList(IBackend backend)
|
|
{
|
|
this.Backend = backend;
|
|
SetStyle (ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
|
|
Font = new Font(Font, FontStyle.Bold);
|
|
}
|
|
|
|
protected override void OnPaint (PaintEventArgs e)
|
|
{
|
|
base.OnPaint (e);
|
|
Graphics g = e.Graphics;
|
|
g.FillRectangle (new SolidBrush (Color.White), this.DisplayRectangle);
|
|
g.DrawRectangle (new Pen(new SolidBrush (Color.Black)), 0, 0, Width - 1, Height - 1);
|
|
IEnumerable<IPlayer> players = Backend.GetPlayers ();
|
|
int count = 0;
|
|
Brush brush = new SolidBrush(Color.Black);
|
|
foreach (IPlayer player in players) {
|
|
g.DrawString(player.GetName(), Font, brush, 20, 10 + 20 * count);
|
|
count++;
|
|
}
|
|
}
|
|
}
|
|
} |