Esempio n. 1
0
        private void LeaveGuildButton_Click(object sender, EventArgs e)
        {
            int count = PlayersListView.SelectedItems.Count;
            int i     = 0;

            OutputListView.Clear();

            while (i < count)
            {
                try
                {
                    string player_item = PlayersListView.SelectedItems[i].Text;

                    StringBuilder playerSelectionBuilder = new StringBuilder();

                    foreach (char ch in player_item.ToCharArray())
                    {
                        if (ch == ' ')

                        {
                            break;
                        }
                        playerSelectionBuilder.Append(ch);
                    }

                    string playerName = playerSelectionBuilder.ToString().Trim();

                    foreach (Player P in player_roster)
                    {
                        if (P.Name.Equals(playerName))
                        {
                            selected_player = P;

                            break;
                        }
                    }
                    string original_guild = getGuildString(selected_player.GuildID);

                    selected_player.GuildID = "";

                    OutputListView.Items.Add(selected_player.Name + " has left " + original_guild + "\n");
                }
                catch (ArgumentOutOfRangeException aoorexc)
                {
                    //
                    OutputListView.Clear();
                    OutputListView.Items.Add("You need to ensure a Player has been selected.");
                }
                i++;
            }
        }
Esempio n. 2
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);
            }
        }
Esempio n. 3
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)
     {
         //
     }
 }
Esempio n. 4
0
        private void JoinGuildButton_Click(object sender, EventArgs e)
        {
            try
            {
                string player_item = PlayersListView.SelectedItems[0].Text;

                string guild_item = GuildsListView.SelectedItems[0].Text;

                StringBuilder playerSelectionBuilder = new StringBuilder();

                foreach (char ch in player_item.ToCharArray())
                {
                    if (ch == ' ')

                    {
                        break;
                    }
                    playerSelectionBuilder.Append(ch);
                }

                string playerName = playerSelectionBuilder.ToString().Trim();

                foreach (Player P in player_roster)
                {
                    if (P.Name.Equals(playerName))
                    {
                        selected_player = P;

                        break;
                    }
                }
                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();
                Console.WriteLine("Got the players/guilds : " + selected_player.Name + "  " + selected_guild.Name);
                selected_player.GuildID = selected_guild.ID;
                OutputListView.Items.Add(selected_player.Name + " has joined " + selected_guild.Name + "-" + selected_guild.Server + "! \n");
            }
            catch (ArgumentOutOfRangeException aoorexc)
            {
                //
                OutputListView.Clear();
                OutputListView.Items.Add("You need to ensure both a Player and Guild have been selected.");
            }
        }
Esempio n. 5
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");
            }
        }
Esempio n. 6
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());
                }
            }
        }
Esempio n. 7
0
        private void printGuild_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();
                List <Player> members = new List <Player>();
                foreach (Player p in player_roster)
                {
                    if (p.GuildID.Equals(selected_guild.ID))
                    {
                        members.Add(p);
                    }
                }
                StringBuilder header_text = new StringBuilder(String.Format("Guild Listing for {0, -30}      [{1}] \n", selected_guild.Name, selected_guild.Server.ToString()));

                OutputListView.Items.Add(header_text.ToString());
                members.Sort((x, y) => x.Name.CompareTo(y.Name));
                OutputListView.Items.Add("--------------------------------------------------------------------------------------------\n");
                foreach (Player p in members)
                {
                    StringBuilder outputBuilder = new StringBuilder(String.Format("\nName: {0, -40} Race: {1, -40} Level: {2, -10} Guild: {3, 40} \n", p.Name, getRaceString(p.Race), p.Level, selected_guild));

                    ColumnHeader header = new ColumnHeader();
                    header.Text = "";
                    header.Name = "col1";
                    OutputListView.Columns.Add(header);
                    // Then
                    OutputListView.Scrollable = true;
                    for (int i = 0; i < this.OutputListView.Columns.Count - 1; i++)
                    {
                        this.OutputListView.AutoResizeColumn(i, ColumnHeaderAutoResizeStyle.ColumnContent);
                    }
                    //OutputListView.Columns[OutputListView.Columns.Count - 1].Width = -2;
                    //OutputListView.Columns[0].Width = 800;
                    OutputListView.View = System.Windows.Forms.View.Details;
                    OutputListView.Items.Add(outputBuilder.ToString());
                }
            }
            catch (ArgumentOutOfRangeException aoorexc)
            {
                //
            }
        }
Esempio n. 8
0
        private void WriteOutput(string str)
        {
            CommLog(str);

            if (OutputListView.Items.Count == 0)
            {
                Helper.ControlInvokeRequired(OutputListView, () =>
                {
                    OutputListView.Items.Add(new ListViewItem(""));
                });
            }

            for (int i = 0; i < str.Length; i++)
            {
                char chr = str[i];
                switch (chr)
                {
                case '\r':
                    _currentXpos = 0;
                    break;

                case '\n':
                    // newline
                    Helper.ControlInvokeRequired(OutputListView, () =>
                    {
                        OutputListView.Items[OutputListView.Items.Count - 1] = new ListViewItem(_currentLine);
                        OutputListView.Items.Add(new ListViewItem(""));
                    });

                    if (_currentXpos > 0)
                    {
                        _currentLine = new string(' ', _currentXpos);
                    }
                    else
                    {
                        _currentLine = "";
                    }
                    break;

                default:
                    if (_currentXpos < _currentLine.Length)
                    {
                        char[] ch = _currentLine.ToCharArray();
                        ch[_currentXpos] = chr;
                        _currentLine     = new string(ch);
                    }
                    else
                    {
                        _currentLine += chr;
                    }
                    _currentXpos++;
                    break;
                }
            }

            Helper.ControlInvokeRequired(OutputListView, () =>
            {
                OutputListView.Items[OutputListView.Items.Count - 1] = new ListViewItem(_currentLine);
                OutputListView.EnsureVisible(OutputListView.Items.Count - 1);
            });
        }