예제 #1
0
        // 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");
            }
        }
예제 #2
0
        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());
                }
            }
        }