/// <summary> /// Evento del boton unirse /// </summary> /// <param name="sender">Propiedad del evento</param> /// <param name="e">Propiedad del evento</param> private void BotonUnirse(object sender, RoutedEventArgs e) { IngresarCodigo(); bool estadisticaCreada = false; if (servidor.ComprobarCodigoPartida(codigoPartida)) { try { servidor.CrearEstadisticaPartida(partida, jugador); estadisticaCreada = true; } catch (CommunicationException ex) { MessageBox.Show("No existe partida en curso"); } if (estadisticaCreada) { PrePartida ventanaPrePartida = new PrePartida(jugadoresConectados, jugador, codigoPartida); ventanaPrePartida.Show(); Window.GetWindow(this).Close(); } } else { MessageBox.Show("El codigo no corresponde a ninguna partida en curso"); } }
public PrePartida(Jugador jugador, string codigoPartida) { this.jugador = jugador; contexto = new InstanceContext(this); servidor = new ProxyPartida.PartidaServiceClient(contexto); //contextoJuego = new InstanceContext(this); //servidorJuego = new ProxyJuego.JuegoServiceClient(contextoJuego); WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; InitializeComponent(); jugadoresConectados = new ObservableCollection <Jugador>(); numerosOrdenCartas = new ObservableCollection <int>(); if (servidor.ComprobarCodigoPartida(codigoPartida)) { servidor.AgregarJugador(jugador); servidor.GenerarOrdenCartas(); } else { MessageBox.Show("El codigo no corresponde a ninguna partida en curso"); } jugadoresUnidos.Items.Clear(); jugadoresUnidos.ItemsSource = jugadoresConectados; }