示例#1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            DelegadoParaMostrar d1 = new DelegadoParaMostrar(NoVisibleLbl);

            label3.Invoke(d1, new Object[] {});
            labcolor.Invoke(d1, new Object[] {});
            numeroLbl.Invoke(d1, new Object[] { });

            DelegadoParaMostrar d2 = new DelegadoParaMostrar(NoVisibleTxt);

            Fecha.Invoke(d2, new Object[] { });

            DelegadoParaMostrar d3 = new DelegadoParaMostrar(NoVisibleBoton);

            Ganador.Invoke(d3, new Object[] { });

            DelegadoParaMostrar d4 = new DelegadoParaMostrar(NoVisiblePanel);

            tablero.Invoke(d4, new Object[] { });

            DelegadoParaMostrar d5 = new DelegadoParaMostrar(NoVisibleData);

            dataGridView1.Invoke(d5, new Object[] { });

            DelegadoParaMostrar d15 = new DelegadoParaMostrar(CrearChatNoVisible);

            chatlabel.Invoke(d15, new Object[] { });
        }
示例#2
0
        private void AtenderServidor()
        {
            while (true)
            {
                //Recibimos mensaje del servidor
                byte[] msg2 = new byte[80];
                server.Receive(msg2);
                string msg5 = Encoding.ASCII.GetString(msg2).Split('\0')[0];
                //MessageBox.Show("mensaje recibido " + msg5 + nombre + "finmensaje");
                string[] trozos = msg5.Split('/');

                int codigo = Convert.ToInt32(trozos[0]);

                string mensaje = trozos[1];
                string mensajevuelta;
                string mensajevuelta2;
                string mensajecrear;
                string Nombreconv;

                switch (codigo)
                {
                case 1:      // LogIn
                    DelegadoParaMostrar d6 = new DelegadoParaMostrar(VisiblelblCase1);
                    label3.Invoke(d6, new Object[] {});
                    DelegadoParaMostrar d7 = new DelegadoParaMostrar(VisibleTxtCase1);
                    Fecha.Invoke(d7, new Object[] {});
                    DelegadoParaMostrar d8 = new DelegadoParaMostrar(VisibleBotonCase1);
                    Ganador.Invoke(d8, new Object[] {});


                    MessageBox.Show("Estas dentro: " + mensaje);
                    break;

                case 2:      // Edad media de los ganadores con ese color

                    MessageBox.Show("Edad media: " + mensaje);
                    break;

                case 3:      // Ganador en esa fecha

                    MessageBox.Show("El ganador es: " + mensaje);
                    break;

                case 4:      // Tanto por ciento de partidas ganadas

                    MessageBox.Show("Tanto por ciento de partidas ganadas con ese color es: " + mensaje);
                    break;

                case 5:     // listadeconectados
                    //MessageBox.Show("Se ha conectado lista: " + mensaje);
                    string[] partes       = Encoding.ASCII.GetString(msg2).Split('/');
                    string   mensajefinal = partes[1].Split('\0')[0];
                    string[] mensaje2     = mensajefinal.Split('|');

                    DelegadoParaEscribir dele = new DelegadoParaEscribir(EscribeConectados);
                    dataGridView1.Invoke(dele, new Object[] { mensaje2 });


                    break;

                case 6:     //Muestra si se ha aceptado la peticion

                    mensajevuelta = trozos[1].Split('\0')[0];
                    acepta        = trozos[2].Split('\0')[0];

                    DelegadoParaMostrar   d9  = new DelegadoParaMostrar(VisiblePanelIf);
                    DelegadoParaEscribir2 d10 = new DelegadoParaEscribir2(EscribeBox2);


                    if ((mensajevuelta == "Acepta") && (acepta != nombre.Text))
                    {
                        panel2.Invoke(d9, new Object[] {});

                        textBox2.Invoke(d10, new Object[] { acepta + " acepta la inviacion" });
                    }
                    else if ((mensajevuelta == "Rechazar") && (acepta != nombre.Text))
                    {
                        panel2.Invoke(d9, new Object[] { });
                        textBox2.Invoke(d10, new Object[] { acepta + " rechaza la inviacion" });
                    }
                    else
                    {
                        MessageBox.Show("Yo no me puedo autoinvitar");
                    }
                    break;

                case 7:     //Invitar

                    mensajevuelta   = trozos[1].Split('\0')[0];
                    NombreInvitador = trozos[2].Split('\0')[0];


                    DelegadoParaMostrar   d11 = new DelegadoParaMostrar(VisibleCase7);
                    DelegadoParaEscribir2 d12 = new DelegadoParaEscribir2(EscribeBox3);
                    DelegadoParaMostrar   d13 = new DelegadoParaMostrar(NoVisiblePanel1);
                    DelegadoParaMostrar   d17 = new DelegadoParaMostrar(VisiblePanel);


                    if (mensajevuelta == "Invitado")
                    {
                        tablero.Invoke(d17, new Object[] { });
                        panel1.Invoke(d11, new Object[] { });
                        InvitadortextBox3.Invoke(d12, new Object[] { NombreInvitador });
                    }
                    else
                    {
                        tablero.Invoke(d17, new Object[] { });
                        panel1.Invoke(d13, new Object[] { });
                    }
                    break;

                case 8:     // Recibo una frase chat
                    mensajevuelta = trozos[1].Split('\0')[0];
                    Nombreconv    = trozos[2].Split('\0')[0];
                    DelegadoParaEscribir2 d16 = new DelegadoParaEscribir2(EscribeChat);
                    Chatlbl.Invoke(d16, new Object[] { Chatlbl.Text + Nombreconv + ":" + mensajevuelta + "\n" });

                    break;

                case 9:     //Mostramos CHAT



                    id             = idposible;
                    mensajevuelta  = trozos[1].Split('\0')[0];
                    mensajevuelta2 = trozos[2].Split('\0')[0];
                    string[] mensajeinvitados = mensajevuelta2.Split('|');

                    if (mensajevuelta == "crear")
                    {
                        DelegadoParaMostrar d14 = new DelegadoParaMostrar(CrearChatVisible);
                        chatlabel.Invoke(d14, new Object[] { });

                        DelegadoParaMostrarLabel d18 = new DelegadoParaMostrarLabel(MostrarLabelrojo);
                        nombreRojo.Invoke(d18, new Object[] { mensajeinvitados });
                    }

                    else
                    {
                        MessageBox.Show("No se ha podido enviar nah :V");
                    }



                    break;

                case 10:     //Enviamos posibe IDP

                    idposible = Convert.ToInt32(trozos[1].Split('\0')[0]);

                    break;

                case 11:     //Iniciar Partida

                    id            = idposible;
                    mensajevuelta = trozos[1].Split('\0')[0];
                    string[] mensajejugadores = trozos[1].Split('|');
                    numerojugadores = (mensajejugadores.Length - 1);

                    for (int i = 0; i < (mensajejugadores.Length - 1); i++)
                    {
                        vectorjugadores[i] = mensajejugadores[i + 1];
                    }

                    vectorposiciones[0] = 130;
                    vectorposiciones[1] = 131;
                    vectorposiciones[2] = 132;
                    vectorposiciones[3] = 133;

                    // Se prepara el inicio de la Partida
                    DelegadoParaMostrarLabel d100 = new DelegadoParaMostrarLabel(MostrarLabels);
                    nombreRojo.Invoke(d100, new Object[] { vectorjugadores });

                    DelegadoParaMostrar d102 = new DelegadoParaMostrar(InicioPartida);
                    nombreRojo.Invoke(d102, new Object[] {});

                    DelegadoParaMostrar jug2 = new DelegadoParaMostrar(VisibleParaJugar);
                    button4.Invoke(jug2, new Object[] { });
                    numeroLbl.Invoke(jug2, new Object[] { });
                    turno = 0;
                    DelegadoParaEscribir2 jug1 = new DelegadoParaEscribir2(EscribeLabelturno);
                    turnoLbl.Invoke(jug1, new Object[] { vectorjugadores[turno] });


                    break;

                case 12:     // Recibe los turnos y las posiciones de las fichas con el dado


                    turno = Convert.ToInt32(trozos[1]);
                    DelegadoParaEscribir2 jug12 = new DelegadoParaEscribir2(EscribeLabelturno);
                    turnoLbl.Invoke(jug12, new Object[] { vectorjugadores[turno] });

                    turno2        = Convert.ToInt32(trozos[2]);
                    mensajevuelta = trozos[3].Split('\0')[0];
                    string[] mensajeposiciones = trozos[3].Split('|');

                    for (int i = 0; i < (mensajeposiciones.Length); i++)
                    {
                        vectorposiciones[i] = Convert.ToInt32(mensajeposiciones[i]);
                    }


                    DelegadoParaFicha d21 = new DelegadoParaFicha(MostraFicha);
                    ficharoja.Invoke(d21, new Object[] { vectorposiciones });

                    break;

                case 13:      // El registro satisfactorio o no y el Borrado de usuarios

                    MessageBox.Show(nombre.Text + ": " + mensaje);
                    break;

                case 14:     //Se recibe el turno y las posiciones de los jugadores al iniciar partida


                    mensajevuelta = trozos[2].Split('\0')[0];
                    string[] mensajeposiciones2 = trozos[2].Split('|');

                    for (int i = 0; i < (mensajeposiciones2.Length); i++)
                    {
                        vectorposiciones[i] = Convert.ToInt32(mensajeposiciones2[i]);
                    }



                    DelegadoParaFicha d23 = new DelegadoParaFicha(MostraFicha);
                    ficharoja.Invoke(d23, new Object[] { vectorposiciones });

                    break;

                case 15:     //FIN PARTIDA

                    MessageBox.Show(nombre.Text + ": " + mensaje);
                    DelegadoParaFinalizar d101 = new DelegadoParaFinalizar(FinPartida);
                    nombreRojo.Invoke(d101, new Object[] {});


                    break;
                }
            }
        }
示例#3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            DelegadoParaMostrar d1 = new DelegadoParaMostrar(NoVisibleLbl);

            label3.Invoke(d1, new Object[] {});
            labcolor.Invoke(d1, new Object[] {});
            numeroLbl.Invoke(d1, new Object[] { });

            DelegadoParaMostrar d2 = new DelegadoParaMostrar(NoVisibleTxt);

            Fecha.Invoke(d2, new Object[] { });

            DelegadoParaMostrar d3 = new DelegadoParaMostrar(NoVisibleBoton);

            Ganador.Invoke(d3, new Object[] { });

            DelegadoParaMostrar d4 = new DelegadoParaMostrar(NoVisiblePanel);

            tablero.Invoke(d4, new Object[] { });

            DelegadoParaMostrar d5 = new DelegadoParaMostrar(NoVisibleData);

            dataGridView1.Invoke(d5, new Object[] { });

            DelegadoParaMostrar d15 = new DelegadoParaMostrar(CrearChatNoVisible);

            chatlabel.Invoke(d15, new Object[] { });

            // posiciones del tablero
            tablero.Visible = true;
            posiciones.Add(new Point(183, 76));
            posiciones.Add(new Point(183, 95));
            posiciones.Add(new Point(188, 121));
            posiciones.Add(new Point(179, 135));
            posiciones.Add(new Point(162, 154));
            posiciones.Add(new Point(135, 158));
            posiciones.Add(new Point(110, 163));
            posiciones.Add(new Point(91, 163));
            posiciones.Add(new Point(70, 163));
            posiciones.Add(new Point(51, 163));
            posiciones.Add(new Point(28, 163));//10
            //10
            posiciones.Add(new Point(7, 163));
            posiciones.Add(new Point(7, 220));
            posiciones.Add(new Point(7, 281));
            posiciones.Add(new Point(27, 281));
            posiciones.Add(new Point(49, 281));
            posiciones.Add(new Point(69, 281));
            posiciones.Add(new Point(90, 281));
            posiciones.Add(new Point(111, 280));
            posiciones.Add(new Point(134, 284));
            posiciones.Add(new Point(155, 293)); //20
            //20
            posiciones.Add(new Point(169, 305));
            posiciones.Add(new Point(197, 315));
            posiciones.Add(new Point(208, 335));
            posiciones.Add(new Point(185, 357));
            posiciones.Add(new Point(183, 380));
            posiciones.Add(new Point(181, 405));
            posiciones.Add(new Point(181, 433));
            posiciones.Add(new Point(250, 435));
            posiciones.Add(new Point(321, 436));
            posiciones.Add(new Point(321, 421)); //30
            //30
            posiciones.Add(new Point(319, 405));
            posiciones.Add(new Point(318, 381));
            posiciones.Add(new Point(320, 368));
            posiciones.Add(new Point(296, 335));
            posiciones.Add(new Point(296, 315));
            posiciones.Add(new Point(328, 305));
            posiciones.Add(new Point(344, 293));
            posiciones.Add(new Point(364, 286));
            posiciones.Add(new Point(390, 284));
            posiciones.Add(new Point(410, 284));//40
            //40
            posiciones.Add(new Point(428, 285));
            posiciones.Add(new Point(451, 284));
            posiciones.Add(new Point(471, 284));
            posiciones.Add(new Point(494, 284));
            posiciones.Add(new Point(494, 220));
            posiciones.Add(new Point(494, 154));
            posiciones.Add(new Point(471, 154));
            posiciones.Add(new Point(451, 158));
            posiciones.Add(new Point(429, 163));
            posiciones.Add(new Point(408, 163)); //50
            //50
            posiciones.Add(new Point(380, 174));
            posiciones.Add(new Point(357, 172));
            posiciones.Add(new Point(340, 154));
            posiciones.Add(new Point(330, 135));
            posiciones.Add(new Point(319, 121));
            posiciones.Add(new Point(318, 95));
            posiciones.Add(new Point(318, 76));
            posiciones.Add(new Point(319, 55));
            posiciones.Add(new Point(320, 39));
            posiciones.Add(new Point(320, 20));//60
            //60
            posiciones.Add(new Point(320, 0));
            posiciones.Add(new Point(251, 0));
            posiciones.Add(new Point(181, 0));
            posiciones.Add(new Point(181, 20));
            posiciones.Add(new Point(181, 39));
            posiciones.Add(new Point(181, 55));//66
            //rojo 67
            posiciones.Add(new Point(250, 20));
            posiciones.Add(new Point(250, 39));
            posiciones.Add(new Point(253, 55));
            posiciones.Add(new Point(251, 76));
            posiciones.Add(new Point(251, 95));
            posiciones.Add(new Point(253, 112));
            posiciones.Add(new Point(253, 129));//73
            //verde 74
            posiciones.Add(new Point(471, 222));
            posiciones.Add(new Point(451, 222));
            posiciones.Add(new Point(430, 222));
            posiciones.Add(new Point(408, 222));
            posiciones.Add(new Point(387, 222));
            posiciones.Add(new Point(364, 222));
            posiciones.Add(new Point(344, 222));//80
            //azul 81
            posiciones.Add(new Point(249, 421));
            posiciones.Add(new Point(249, 405));
            posiciones.Add(new Point(249, 385));
            posiciones.Add(new Point(249, 365));
            posiciones.Add(new Point(249, 351));
            posiciones.Add(new Point(249, 335));
            posiciones.Add(new Point(249, 325));
            posiciones.Add(new Point(249, 301));//88
            //amarillo 89
            posiciones.Add(new Point(30, 224));
            posiciones.Add(new Point(50, 224));
            posiciones.Add(new Point(70, 224));
            posiciones.Add(new Point(90, 224));
            posiciones.Add(new Point(110, 224));
            posiciones.Add(new Point(132, 224));
            posiciones.Add(new Point(156, 224)); //95
            //centro
            posiciones.Add(new Point(250, 221)); //96
            posiciones.Add(new Point(250, 221)); //97
            posiciones.Add(new Point(250, 221)); //98
            posiciones.Add(new Point(250, 221)); //99
            posiciones.Add(new Point(250, 221)); //100
            posiciones.Add(new Point(250, 221)); //101
            posiciones.Add(new Point(250, 221)); //102
            posiciones.Add(new Point(250, 221)); //103
            //modifico
            posiciones.Add(new Point(250, 221)); //
            posiciones.Add(new Point(250, 221)); //103
            posiciones.Add(new Point(250, 221)); //103
            posiciones.Add(new Point(250, 221)); //103
            posiciones.Add(new Point(250, 221)); //103
            posiciones.Add(new Point(250, 221)); //103
            posiciones.Add(new Point(250, 221)); //103
            posiciones.Add(new Point(250, 221)); //103
            posiciones.Add(new Point(250, 221)); //103
            posiciones.Add(new Point(250, 221)); //103
            posiciones.Add(new Point(250, 221)); //103
            posiciones.Add(new Point(250, 221)); //115
            posiciones.Add(new Point(250, 221)); //115
            posiciones.Add(new Point(250, 221)); //115
            posiciones.Add(new Point(250, 221)); //115
            posiciones.Add(new Point(250, 221)); //115
            posiciones.Add(new Point(250, 221)); //115
            posiciones.Add(new Point(250, 221)); //115
            posiciones.Add(new Point(250, 221)); //122
            posiciones.Add(new Point(250, 221)); //123
            posiciones.Add(new Point(250, 221)); //124
            posiciones.Add(new Point(250, 221)); //125
            posiciones.Add(new Point(250, 221)); //126
            posiciones.Add(new Point(250, 221)); //127
            posiciones.Add(new Point(250, 221)); //128
            posiciones.Add(new Point(250, 221)); //129
            ////esquina roja
            //posiciones.Add(new Point(67, 46));//104
            ////esquina verde
            //posiciones.Add(new Point(442, 46));//105
            ////esquina azul
            //posiciones.Add(new Point(448, 392));//106
            ////esquna amarilla
            //posiciones.Add(new Point(63, 388));//107

            //esquina roja
            posiciones.Add(new Point(67, 46));   //130
            //esquina verde
            posiciones.Add(new Point(442, 46));  //131
            //esquina azul
            posiciones.Add(new Point(448, 392)); //132
            //esquna amarilla
            posiciones.Add(new Point(63, 388));  //133
        }
示例#4
0
        private void AtenderServidor()
        {
            while (true)
            {
                //Recibimos mensaje del servidor
                byte[] msg2 = new byte[80];
                server.Receive(msg2);
                string[] trozos  = Encoding.ASCII.GetString(msg2).Split('/');
                int      codigo  = Convert.ToInt32(trozos[0]);
                string   mensaje = trozos[1].Split('\0')[0];
                string   mensajevuelta;
                string   Nombreconv;

                switch (codigo)
                {
                case 1:      // LogIn
                    DelegadoParaMostrar d6 = new DelegadoParaMostrar(VisiblelblCase1);
                    label3.Invoke(d6, new Object[] {});
                    DelegadoParaMostrar d7 = new DelegadoParaMostrar(VisibleTxtCase1);
                    Fecha.Invoke(d7, new Object[] {});
                    DelegadoParaMostrar d8 = new DelegadoParaMostrar(VisibleBotonCase1);
                    Ganador.Invoke(d8, new Object[] {});


                    MessageBox.Show("Estas dentro: " + mensaje);
                    break;

                case 2:      // Edad media de los ganadores con ese color

                    MessageBox.Show("Edad media: " + mensaje);
                    break;

                case 3:      // Ganador en esa fecha

                    MessageBox.Show("El ganador es: " + mensaje);
                    break;

                case 4:      // Tanto por ciento de partidas ganadas

                    MessageBox.Show("Tanto por ciento de partidas ganadas con ese color es: " + mensaje);
                    break;

                case 5:     // listadeconectados

                    string[] partes       = Encoding.ASCII.GetString(msg2).Split('/');
                    string   mensajefinal = partes[1].Split('\0')[0];
                    string[] mensaje2     = mensajefinal.Split('|');

                    DelegadoParaEscribir dele = new DelegadoParaEscribir(EscribeConectados);
                    dataGridView1.Invoke(dele, new Object[] { mensaje2 });

                    break;

                case 6:     //Muestra si se ha aceptado la peticion

                    mensajevuelta = trozos[1].Split('\0')[0];
                    acepta        = trozos[2].Split('\0')[0];

                    DelegadoParaMostrar   d9  = new DelegadoParaMostrar(VisiblePanelIf);
                    DelegadoParaEscribir2 d10 = new DelegadoParaEscribir2(EscribeBox2);


                    if (mensajevuelta == "Acepta")
                    {
                        panel2.Invoke(d9, new Object[] {});

                        textBox2.Invoke(d10, new Object[] { acepta + " acepta la inviacion" });
                    }
                    else
                    {
                        panel2.Invoke(d9, new Object[] { });
                        textBox2.Invoke(d10, new Object[] { acepta + " rechaza la inviacion" });
                    }

                    break;

                case 7:     //Invitar

                    mensajevuelta   = trozos[1].Split('\0')[0];
                    NombreInvitador = trozos[2].Split('\0')[0];


                    DelegadoParaMostrar   d11 = new DelegadoParaMostrar(VisibleCase7);
                    DelegadoParaEscribir2 d12 = new DelegadoParaEscribir2(EscribeBox3);
                    DelegadoParaMostrar   d13 = new DelegadoParaMostrar(NoVisiblePanel1);
                    DelegadoParaMostrar   d17 = new DelegadoParaMostrar(VisiblePanel);


                    if (mensajevuelta == "Invitado")
                    {
                        tablero.Invoke(d17, new Object[] { });
                        panel1.Invoke(d11, new Object[] { });
                        InvitadortextBox3.Invoke(d12, new Object[] { NombreInvitador });
                    }
                    else
                    {
                        tablero.Invoke(d17, new Object[] { });
                        panel1.Invoke(d13, new Object[] { });
                    }
                    break;

                case 8:     // Recibo una frase chat
                    mensajevuelta = trozos[1].Split('\0')[0];
                    Nombreconv    = trozos[2].Split('\0')[0];
                    DelegadoParaEscribir2 d16 = new DelegadoParaEscribir2(EscribeChat);
                    Chatlbl.Invoke(d16, new Object[] { Chatlbl.Text + Nombreconv + ":" + mensajevuelta + "\n" });

                    break;

                case 9:     //Mostramos CHAT

                    id            = idposible;
                    mensajevuelta = trozos[1].Split('\0')[0];

                    if (mensajevuelta == "crear")
                    {
                        DelegadoParaMostrar d14 = new DelegadoParaMostrar(CrearChatVisible);
                        chatlabel.Invoke(d14, new Object[] { });
                    }

                    else
                    {
                        MessageBox.Show("No se ha podido enviar nah :V");
                    }

                    break;

                case 10:     //Enviamos posibe IDP

                    idposible = Convert.ToInt32(trozos[1].Split('\0')[0]);

                    break;
                }
            }
        }