Exemplo n.º 1
0
        private void CharacterReceived(Website.CharInfo Character)
        {
            if (Character.Name == string.Empty)
            {
                MessageBox.Show("Character doesn't exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Cursor = Cursors.Default; //Reset cursor to deafult
                return;
            }

            foreach (Website.CharInfo MemberChar in Members)
            {
                if (MemberChar.Name == Character.Name)
                {
                    MessageBox.Show("Character is already at the list", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Cursor = Cursors.Default; //Reset cursor to deafult
                    return;
                }
            }

            Members.Add(Character);

            MembersList.Invoke(new EventHandler(delegate
            {
                //Update the ListView
                MembersList.Items.Add(new ListViewItem(new string[] {
                    Character.Name,
                    Character.GuildName,
                    Character.GuildNickName
                }));
            }));
            this.Invoke(new EventHandler(delegate
            {
                this.Cursor = Cursors.Default; //Reset cursor to deafult
            }));
        }
Exemplo n.º 2
0
        private void GuildMembersReceived(List <Website.CharInfo> GuildMembers)
        {
            if (GuildMembers.Count == 0)
            {
                MessageBox.Show("Guild doesn't exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Cursor = Cursors.Default; //Reset cursor to deafult
                return;
            }
            bool AlreadyInList = false;

            foreach (Website.CharInfo Character in GuildMembers)
            {
                foreach (Website.CharInfo MemberChar in Members)
                {
                    if (MemberChar.Name == Character.Name)
                    {
                        MessageBox.Show("Character " + Character.Name + " is already at the list.", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        AlreadyInList = true;
                        break;
                    }
                }
                if (!AlreadyInList)
                {
                    Members.Add(Character);

                    MembersList.Invoke(new EventHandler(delegate
                    {
                        //Update the ListView
                        MembersList.Items.Add(new ListViewItem(new string[] {
                            Character.Name,
                            Character.GuildName,
                            Character.GuildNickName
                        }));
                    }));
                }
                AlreadyInList = false;
            }
            this.Invoke(new EventHandler(delegate
            {
                this.Cursor = Cursors.Default; //Reset cursor to deafult
            }));
        }