private void Button_Click_Registrar(object sender, RoutedEventArgs e) { if (TxtNombre.Text.Trim().Equals("")) { TxtNombre.PlaceholderText = "Escribe un nombre"; TxtNombre.Text = ""; } else if (CBSkin.SelectedIndex < 0) { CBSkin.PlaceholderText = "Elige una Skin"; } else if (CBRango.SelectedIndex < 0) { CBRango.PlaceholderText = "Elige el Rango del usuario"; } else { DateTimeOffset fecha = DPFecha.Date; try { int dinero = 0; try { dinero = Int32.Parse(TxtDinero.Text); } catch { } Jugador Nuevo = new Jugador(TxtNombre.Text, "Assets/" + CBSkin.SelectedItem.ToString() + ".Skin.png", (Rango)(CBRango.SelectedItem), dinero, fecha.Day, fecha.Month, fecha.Year); if (editando == null) { AdminJugs.GetJugadores().Add(Nuevo); } else { int index = AdminJugs.GetJugadores().IndexOf(editando); AdminJugs.GetJugadores().Insert(index, Nuevo); AdminJugs.GetJugadores().Remove(editando); } AdminJugs.GuardarJugadores(); Frame.Navigate(typeof(NuevoJugRegistrado), (editando == null ? 0 : 1) + Nuevo.Nombre); Frame.BackStack.RemoveAt(Frame.BackStack.Count - 1); } catch (Exception error) { BtnAgregar.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 255, 0, 0)); BtnAgregar.Content = error.Message; } } }
private async void MostrarConfirmarBorrar(int index) { Jugador objetivo = ListaJugadores.ElementAt(index); ContentDialog confirmarDialog = new ContentDialog { Title = "¿Borrar definitivamente a " + objetivo.Nombre + "?", Content = "Esta acción no podrá deshacerse y el cambio se guardará inmediatamente.", PrimaryButtonText = "Borrar definitivamente", SecondaryButtonText = "Cancelar" }; ContentDialogResult result = await confirmarDialog.ShowAsync(); if (result.Equals(ContentDialogResult.Primary)) { AdminJugs.GetJugadores().Remove(objetivo); AdminJugs.GuardarJugadores(); GVVerJugs.ItemsSource = AdminJugs.GetJugadores(); Frame.Navigate(typeof(VerJugadores), null, new SuppressNavigationTransitionInfo()); Frame.BackStack.RemoveAt(Frame.BackStack.Count - 1); } }