Example #1
0
 public void ObtenirConectatsResposta(string missatge)
 {
     try
     {
         DelegadoParaEscribir delegado = new DelegadoParaEscribir(PosaDataGriedView);
         LlistaConectats.Invoke(delegado, new object[] { missatge });
     }
     catch (ArgumentOutOfRangeException)
     {
         MessageBox.Show("El missatge es incorrecte");
     }
     LlistaConectats.ClearSelection();
 }
Example #2
0
        public void RegistrarResposta(string missatge)
        {
            // Funcio que processa la resposta a la peticio de registrarse


            if (Convert.ToInt32(missatge) == 1)
            {
                MessageBox.Show("Usuari Registrat i connectat.");
                this.BackColor = Color.Lime;
            }
            else if (Convert.ToInt32(missatge) == 2)
            {
                MessageBox.Show("Ja existeix aquest usuari.");
                Tancar_connexio();
            }
            LlistaConectats.ClearSelection();
        }
Example #3
0
        public void EntrarResposta(string missatge)
        {
            // Funció que processa la resposta a Entrar


            if (Convert.ToInt32(missatge) == 1)
            {
                MessageBox.Show("Existeix l'usuari i coincideix la contrasenya");
                //this.BackColor = Color.Lime;
            }
            else if (Convert.ToInt32(missatge) == 2)
            {
                MessageBox.Show("Existeix l'usuari però no coincideix la contrasenya");
                Tancar_connexio();
            }
            else if (Convert.ToInt32(missatge) == 3)
            {
                MessageBox.Show("No existeix l'usuari");
                //Mensaje de desconexión
                Tancar_connexio();
            }
            LlistaConectats.ClearSelection();
        }
Example #4
0
        private void Botó_Convidar_Click(object sender, EventArgs e)
        {
            string[] Seleccionats = new string[100];
            int      marcadas     = LlistaConectats.SelectedRows.Count;
            int      i            = 1;
            int      row          = 0;
            int      j            = 0;

            while (i < Usuaris.Length - 1)
            {
                if (LlistaConectats.Rows[row].Cells[0].Style.BackColor == Color.Blue)
                {
                    Seleccionats[j] = Usuaris[i];
                    j = j + 1;
                    LlistaConectats.Rows[row].Cells[0].Style.BackColor = Color.White;
                    row = row + 1;
                }
                i = i + 1;
            }
            LlistaConectats.ClearSelection();

            if (Seleccionats[0] != null)
            {
                NumSeleccionats = NumSeleccionats + j;

                if ((NumSeleccionats > 3) || (NumSeleccionats == 2))
                {
                    MessageBox.Show("Només podeu ser 2 o 4 en una partida, torna a intentar-ho o comença la partida");
                    NumSeleccionats = NumSeleccionats - j;
                }
                else
                {
                    MessageBox.Show("Estas creant una partida nova");
                    ID_Partida = contador_IDs + 1;
                    MessageBox.Show("Estas creant una partida nova amb ID = " + Convert.ToString(ID_Partida));

                    //Enviem el missatge
                    int    u       = 0;
                    string mensaje = "8";
                    mensaje = mensaje + "/" + Convert.ToString(ID_Partida);
                    // Envia al servidor la ID de la partida
                    while (Seleccionats[u] != null)
                    {
                        mensaje = mensaje + "/" + Seleccionats[u];
                        MessageBox.Show(mensaje);
                        u = u + 1;
                        NumJugadorsEquip = NumSeleccionats + 1;
                    }
                    if (NumSeleccionats == 1) //com que estem al cas de un contra 1 hem de omplir els dos noms que queden amb un 0 => 8/ID_partida/nom/0/0
                    {
                        mensaje          = mensaje + "/0/0";
                        NumJugadorsEquip = 2;
                    }

                    byte[] msg = System.Text.Encoding.ASCII.GetBytes(mensaje);
                    server.Send(msg);
                }
            }
            else
            {
                MessageBox.Show("No hi ha cap persona seleccionada per convidar");
            }
        }