Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            int           maxLen = 0, tmpLen = 0;
            DataTable     GridTable;
            WoWCharMounts myMounts;
            Dictionary <string, Mount> dict = new Dictionary <string, Mount>();

            if ((CharacterTextBox.Text == null) || (CharacterTextBox.Text.Length <= 0))
            {
                MessageBox.Show("Please enter a character name.");
                return;
            }

            if (ServerComboBox.Text == null || (ServerComboBox.Text.Length <= 0))
            {
                MessageBox.Show("Please pick a server name.");
            }

            // get the mounts for a specifc character
            myMounts = WoWCharMounts.getMountListForCharacter(ServerComboBox.Text, CharacterTextBox.Text, ACCESS_TOKEN);
            if (myMounts == null)
            {
                return;
            }

            myMounts.mounts.collected.Sort((x, y) => String.Compare(x.name, y.name));

            // Find what mounts are missing for this character and populate the list box
            var DiffMounts = AllMounts.mounts.Except(myMounts.mounts.collected);

            GridTable = (DataTable)dataGridView1.DataSource;
            GridTable.Clear();
            foreach (Mount mount in DiffMounts)
            {
                if (!dict.ContainsKey(mount.name))
                {
                    dict.Add(mount.name, mount);
                    GridTable.Rows.Add(mount.name, mount.isGround, mount.isFlying, mount.isAquatic, mount.isJumping);
                    tmpLen = TextRenderer.MeasureText(mount.name, dataGridView1.Font).Width;
                    if (tmpLen > maxLen)
                    {
                        maxLen = tmpLen;
                    }
                }
            }

            dataGridView1.Columns[0].Width = maxLen;
            return;
        }