private void DeleteButton_Click(object sender, RoutedEventArgs e) { // make sure "Me" isn't selected if (PlayersListView.SelectedIndex != 0) { // remove selected from playersdata, select last element, then focus back // (for convenience in case user wants to delete all of them quickly) PlayersData.RemoveAt(PlayersListView.SelectedIndex); PlayersListView.SelectedIndex = PlayersData.Count - 1; PlayersListView.Focus(); } }
protected void FilterPlayer(string sbText) { PlayersListView.BeginRefresh(); if (string.IsNullOrWhiteSpace(sbText)) { PlayersListView.ItemsSource = viewModel.players; } else { PlayersListView.ItemsSource = viewModel.players.Where(x => x.FullName.ToLower().Contains(sbText.ToLower())); } PlayersListView.EndRefresh(); }
protected override void OnAppearing() { base.OnAppearing(); if (PlayersListView.ItemsSource == null) { PlayersListView.BeginRefresh(); viewModel.LoadPlayersCommand.Execute(null); PlayersListView.ItemsSource = viewModel.players; PlayersListView.EndRefresh(); } else { FilterPlayer(sbPlayers.Text); } }
private void SearchBar_TextChanged(object sender, TextChangedEventArgs e) { PlayersListView.BeginRefresh(); if (!string.IsNullOrWhiteSpace(e.NewTextValue)) { PlayersListView.ItemsSource = HelperClass.AllPlayers.Where(x => x.FirstName.ToLower().Contains(e.NewTextValue.ToLower()) || x.LastName.ToLower().Contains(e.NewTextValue.ToLower())).OrderBy(x => x.FirstName).ThenBy(x => x.LastName); } else { PlayersListView.ItemsSource = HelperClass.AllPlayers.OrderBy(x => x.FirstName).ThenBy(x => x.LastName); } PlayersListView.EndRefresh(); }
private void PreviousPlayersListView_ItemClick(object sender, ItemClickEventArgs e) { PlayersPageViewModel.instance.AddExistingPlayerButton(e.ClickedItem as Player); PlayersListView.Focus(FocusState.Pointer); }
// This method just filters the ListViews private void SearchButton_Click(object sender, EventArgs e) { PlayersListView.Clear(); GuildsListView.Clear(); string player_filter = SearchPlayerTextBox.Text.Trim(); if (!player_filter.Equals("")) { foreach (Player p in player_roster) { player_roster.Sort((x, y) => x.Name.CompareTo(y.Name)); if (p.Name.ToUpper().Contains(player_filter.ToUpper())) { PlayersListView.Items.Add(p.ToString()); } } } else { foreach (Player p in player_roster) { player_roster.Sort((x, y) => x.Name.CompareTo(y.Name)); PlayersListView.Items.Add(p.ToString()); } } string guild_filter = SearchGuildTextBox.Text.Trim(); if (!guild_filter.Equals("")) { foreach (Guild g in guild_roster) { guild_roster.Sort((x, y) => x.Name.CompareTo(y.Name)); if (g.Server.ToUpper().Contains(guild_filter.ToUpper())) { GuildsListView.Items.Add(g.ToString()); } } } else { foreach (Guild g in guild_roster) { guild_roster.Sort((x, y) => x.Name.CompareTo(y.Name)); GuildsListView.Items.Add(g.ToString()); } } OutputListView.Clear(); if (selected_player != null) { OutputListView.Items.Add(selected_player.ToString()); } if (selected_guild != null) { OutputListView.Items.Add(selected_guild.ToString()); } if (selected_player == null && selected_guild == null) // Both null { // Error messge... OutputListView.Clear(); OutputListView.Items.Add("Nothing was a match for your filtering criteria"); } }
private void AddPlayerButton_Click(object sender, EventArgs e) { bool all_fields_selected = true; if (PlayerNameTextBox.Text.Equals("") && all_fields_selected == true) { all_fields_selected = false; OutputListView.Clear(); OutputListView.Items.Add("Please enter a name."); } else if (RoleComboBox.Text.Equals("") && all_fields_selected == true) { all_fields_selected = false; OutputListView.Clear(); OutputListView.Items.Add("Please chose a role."); } else if (RaceComboBox.Text.Equals("") && all_fields_selected == true) { all_fields_selected = false; OutputListView.Clear(); OutputListView.Items.Add("Please chose a race."); } else if (ClassComboBox.Text.Equals("") && all_fields_selected == true) { all_fields_selected = false; OutputListView.Clear(); OutputListView.Items.Add("Please chose a class."); } else { OutputListView.Clear(); all_fields_selected = true; Random random = new Random(); string id = Player.getID() + ""; string guildId = ""; string name = PlayerNameTextBox.Text; string race = RaceComboBox.Text; string class_String = ClassComboBox.Text; string role = RoleComboBox.Text; switch (random.Next(0, 12)) { case 0: guildId = "475186"; break; case 1: guildId = "748513"; break; case 2: guildId = "154793"; break; case 3: guildId = "928126"; break; case 4: guildId = "513487"; break; case 5: guildId = "864722"; break; case 6: guildId = "185470"; break; case 7: guildId = "726518"; break; case 8: guildId = "623818"; break; case 9: guildId = "019274"; break; case 10: guildId = "028671"; break; case 11: guildId = "267481"; break; } Player player = new Player(id, name, race, class_String, "0", "0", guildId); player_roster.Add(player); player_roster.Sort((x, y) => x.Name.CompareTo(y.Name)); PlayersListView.Clear(); foreach (Player p in player_roster) { PlayersListView.Items.Add(p.ToString()); } } }