/// <summary>
        /// Setup the grid view
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CompareHighscoresForm_Load(object sender, EventArgs e)
        {
            if (Owner != null)
            {
                Location = new Point(Owner.Location.X + Owner.Width / 2 - Width / 2,
                                     Owner.Location.Y + Owner.Height / 2 - Height / 2);
            }

            foreach (string skill in Highscores.Skills)
            {
                int yourLevel  = yourHighscores.GetLevelForSkill(skill);
                int theirLevel = theirHighscores.GetLevelForSkill(skill);

                int yourXp  = yourHighscores.GetExperienceForSkill(skill);
                int theirXp = theirHighscores.GetExperienceForSkill(skill);

                bool youHigher = yourLevel > theirLevel;
                bool tie       = yourLevel == theirLevel;

                //Initialize row
                int             index           = levelsGridView.Rows.Add();
                DataGridViewRow dataGridViewRow = levelsGridView.Rows[index];
                dataGridViewRow.Cells[0].Value       = skill;
                dataGridViewRow.Cells[1].Value       = yourLevel;
                dataGridViewRow.Cells[1].ToolTipText = $"XP: {yourXp}";
                dataGridViewRow.Cells[2].Value       = theirLevel;
                dataGridViewRow.Cells[2].ToolTipText = $"XP: {theirXp}";

                //Set cell colors
                dataGridViewRow.Cells[1].Style.BackColor = youHigher ? Color.Green : tie ? Color.LightGray : Color.Red;
                dataGridViewRow.Cells[2].Style.BackColor = youHigher ? Color.Red : tie ? Color.LightGray : Color.Green;

                levelsGridView.Refresh();
            }
        }
Exemplo n.º 2
0
 private void setupLabels()
 {
     foreach (string skillName in highscores.playerSkillLevels.Keys)
     {
         Label      skillLabel = (Label)Controls.Find(skillName + "Label", true).FirstOrDefault();
         PictureBox skillIcon  = (PictureBox)Controls.Find(skillName + "Icon", true).FirstOrDefault();
         if (skillLabel != null)
         {
             string prefix = skillName == "overall" ? "Overall: " : "";
             skillLabel.Text = $"{prefix}{highscores.playerSkillLevels[skillName].Level.ToString()}";
             xpTooltip.SetToolTip(skillLabel, $"XP: {highscores.GetExperienceForSkill(skillName)}");
             if (skillIcon != null)
             {
                 xpTooltip.SetToolTip(skillIcon, $"XP: {highscores.GetExperienceForSkill(skillName)}");
             }
         }
     }
 }