private void frmPaint_KeyDown(object sender, KeyEventArgs e) { if (e.KeyData == Keys.Return) { byte[] b = new byte[2]; b[0] = 5; b[1] = GP.ID; GP.Send(b); } else { if (e.KeyData == Keys.Space) { using (ColorDialog ColorPicker = new ColorDialog()) { if (ColorPicker.ShowDialog() == DialogResult.OK) { GP.PlayerList[GP.ID].Couleur = ColorPicker.Color.ToArgb(); GP.Send(TramePreGen.InfoJoueur(GP.PlayerList[GP.ID], GP.ID, GP.PacketID)); } } } else { GP.PlayerList[GP.ID].Position = new Point(0, 0); GP.Send(TramePreGen.InfoJoueur(GP.PlayerList[GP.ID], GP.ID, GP.PacketID)); } } }
private void timer1_Tick(object sender, EventArgs e) { Invoke(new Action(() => { Graphics g = this.CreateGraphics(); for (byte i = 1; i <= GP.PlayerCount; i++)////////////////////////////////////+ 1 { int X = 0, Y = 0; X = GP.PlayerList[i].Position.X; Y = GP.PlayerList[i].Position.Y; g.FillEllipse(new SolidBrush(Color.FromArgb(GP.PlayerList[i].Couleur)), X - 10, Y - 10, 20, 20); /*rtb1.Text += a.ToString() + "x:" + c.ToString() + "y\n"; * rtb1.SelectionStart = rtb1.Text.Length; * rtb1.ScrollToCaret();*/ if (X == 0 && Y == 0) { GP.PlayerList[i].Position = new Point(1, 1); GP.Send(TramePreGen.InfoJoueur(GP.PlayerList[i], i, GP.PacketID)); this.Refresh(); } } g.DrawString(GP.ID.ToString(), new Font("Arial", 16), new SolidBrush(Color.Black), 10, 10); if (MouseButtons == MouseButtons.Left)//mouse) { GP.PlayerList[GP.ID].Position = this.PointToClient(Cursor.Position); GP.Send(TramePreGen.InfoJoueur(GP.PlayerList[GP.ID], GP.ID, GP.PacketID)); } if (update) { this.Invalidate(); } })); }