private void PaintCanvas_MouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { linePointsX.Add(e.GetPosition(PaintCanvas).X); linePointsY.Add(e.GetPosition(PaintCanvas).Y); if (linePointsX.Count >= 20) { Packets.PictionaryPaintPacket packet = new Packets.PictionaryPaintPacket(linePointsX, linePointsY, newLine); newLine = true; if (paintTool == PaintTool.Eraser) { packet.SetPenColour(Colors.White.ScR, Colors.White.ScG, Colors.White.ScB, Colors.White.ScA); } if (paintTool == PaintTool.Pen) { packet.SetPenColour(penColor.ScR, penColor.ScG, penColor.ScB, penColor.ScA); } clientManager.UdpSendDataToServer(packet); linePointsX.Clear(); linePointsY.Clear(); } } if (e.LeftButton == MouseButtonState.Released) { newLine = false; if (linePointsX.Count != 0) { Packets.PictionaryPaintPacket packet = new Packets.PictionaryPaintPacket(linePointsX, linePointsY, true); if (paintTool == PaintTool.Eraser) { packet.SetPenColour(Colors.White.ScR, Colors.White.ScG, Colors.White.ScB, Colors.White.ScA); } if (paintTool == PaintTool.Pen) { packet.SetPenColour(penColor.ScR, penColor.ScG, penColor.ScB, penColor.ScA); } clientManager.UdpSendDataToServer(packet); linePointsX.Clear(); linePointsY.Clear(); } } }