Exemplo n.º 1
0
 private void OnCreateMouseClick(object sender, MouseClickEventArgs e)
 {
     if (box[0].Text().Length > 0 && box[1].Text().Length > 0)
     {
         name = box[1].Text();
         try
         {
             port = Convert.ToInt32(box[0].Text());
             StartButton.MouseClick += OnStartMouseClick;
             createButton.MouseClick -= OnCreateMouseClick;
             isCreate = true;
             box[0].IsSelect = false;
             box[1].IsSelect = false;
             serveur = new Serveur("test",port,100);
             serveur.Start();
             localClient = new Client(name,true);
             localClient.Connect("127.0.0.1", port);
             localClient.SendData();
             localClient.StartReadThread();
             //localClient.StartWaitStart();
             box.Add(new TextBox(new Vector2(Bounds.X + 20, box[0].Bound.Bottom + 10), 20, 10,
                                 TexturesManager.Menu, Color.Blue, Color.Red));
         }
         catch (Exception)
         {
             box[0].RemoveAll();
         }
     }
 }
Exemplo n.º 2
0
 private void OnJoinMouseClick(object sender, MouseClickEventArgs e)
 {
     if (box[0].Text().Length > 0 && box[1].Text().Length > 0 && box[2].Text().Length > 0)
     {
         name = box[1].Text();
         try
         {
             port = Convert.ToInt32(box[0].Text());
             joinButton.MouseClick -= OnJoinMouseClick;
             box[0].IsSelect = false;
             box[1].IsSelect = false;
             box[2].IsSelect = false;
             IsJoin = true;
             box.Add(new TextBox(new Vector2(Bounds.X + 20, box[2].Bound.Bottom + 10), 20, 10,
                                 TexturesManager.Menu, Color.Blue, Color.Red));
             client = new Client(name);
             client.Connect(box[2].Text(),port);
             client.SendData();
             client.StartReadThread();
             //client.StartWaitStart();
         }
         catch (Exception)
         {
             box[0].RemoveAll();
         }
     }
 }