예제 #1
0
        private void AddGuildButton_Click(object sender, EventArgs e)
        {
            bool all_fields_selected = true;

            if (GuildNameTextBox.Text.Equals("") && all_fields_selected == true)
            {
                all_fields_selected = false;
                OutputListView.Clear();
                OutputListView.Items.Add("Please enter a guild.");
            }
            else if (ServerComboBox.Text.Equals("") && all_fields_selected == true)
            {
                all_fields_selected = false;
                OutputListView.Clear();
                OutputListView.Items.Add("Please select a server.");
            }
            else if (GuildTypeComboBox.Text.Equals("") && all_fields_selected == true)
            {
                all_fields_selected = false;
                OutputListView.Clear();
                OutputListView.Items.Add("Please select a guild type.");
            }
            else
            {
                all_fields_selected = true;
                Random random = new Random();
                string id     = Guild.getID() + "";
                string name   = GuildNameTextBox.Text;
                string server = ServerComboBox.Text;
                string type   = GuildTypeComboBox.Text;

                Guild guild = new Guild(id, name, server);
                guild_roster.Add(guild);
                guild_roster.Sort((x, y) => x.Name.CompareTo(y.Name));
                GuildsListView.Clear();
                foreach (Guild g in guild_roster)
                {
                    GuildsListView.Items.Add(g.ToString());
                }
                SearchGuildTextBox.AutoCompleteCustomSource.Add(guild.Server);
                customGuilds.Add(id, name);
            }
        }
예제 #2
0
 private void DisbandGuildButton_Click(object sender, EventArgs e)
 {
     try
     {
         string        guild_item            = GuildsListView.SelectedItems[0].Text;
         StringBuilder guildSelectionBuilder = new StringBuilder();
         foreach (char ch
                  in guild_item.ToCharArray())
         {
             if (ch == '[')
             {
                 break;
             }
             guildSelectionBuilder.Append(ch);
         }
         string guildName = guildSelectionBuilder.ToString().Trim();
         foreach (Guild G in guild_roster)
         {
             if (G.Name.Equals(guildName))
             {
                 selected_guild = G;
                 break;
             }
         }
         OutputListView.Clear();
         int           players_removed = 0;
         List <Player> removals        = new List <Player>();
         foreach (Player p in player_roster)
         {
             if (p.GuildID.Equals(selected_guild.ID))
             {
                 p.GuildID = "";
                 removals.Add(p);
                 players_removed++;
                 Console.WriteLine(p.Name + " is leaving " + selected_guild.Name);
             }
         }
         bool removed;
         do
         {
             removed = false;
             foreach (Guild G in guild_roster)
             {
                 if (G.ID.Equals(selected_guild.ID))
                 {
                     removed = true;
                     guild_roster.Remove(G);
                     break;
                 }
             }
         }while (removed);
         OutputListView.Items.Add(players_removed + " player have been disbanded from " + selected_guild.Name);
         foreach (Player p in removals)
         {
             OutputListView.Items.Add(p.ToString());
         }
         GuildsListView.Clear();
         foreach (Guild G in guild_roster)
         {
             GuildsListView.Items.Add(G.ToString());
         }
     }
     catch (ArgumentOutOfRangeException aoorexc)
     {
         //
     }
 }
예제 #3
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");
            }
        }