Permalink
Browse files

- Fix.

  • Loading branch information...
TOM_RUS
TOM_RUS committed Jan 15, 2012
1 parent b665216 commit 667e27a77b33cdc67fc1dcf336946c92d82e0e1f
Showing with 243 additions and 34 deletions.
  1. +1 −1 WCPAPI/ArenaLadder.cs
  2. +17 −11 WowArenaLadder/MainForm.Designer.cs
  3. +86 −17 WowArenaLadder/MainForm.cs
  4. +70 −0 WowArenaLadder/Properties/Resources.Designer.cs
  5. +39 −5 WowArenaLadder/Properties/Resources.resx
  6. +30 −0 WowArenaLadder/WowArenaLadder.csproj
  7. BIN WowArenaLadder/images/classes/classes_deathknight.png
  8. BIN WowArenaLadder/images/classes/classes_druid.png
  9. BIN WowArenaLadder/images/classes/classes_hunter.png
  10. BIN WowArenaLadder/images/classes/classes_mage.png
  11. BIN WowArenaLadder/images/classes/classes_paladin.png
  12. BIN WowArenaLadder/images/classes/classes_priest.png
  13. BIN WowArenaLadder/images/classes/classes_rogue.png
  14. BIN WowArenaLadder/images/classes/classes_shaman.png
  15. BIN WowArenaLadder/images/classes/classes_warlock.png
  16. BIN WowArenaLadder/images/classes/classes_warrior.png
  17. BIN WowArenaLadder/images/races/races_bloodelf-female.png
  18. BIN WowArenaLadder/images/races/races_bloodelf-male.png
  19. BIN WowArenaLadder/images/races/races_draenei-female.png
  20. BIN WowArenaLadder/images/races/races_draenei-male.png
  21. BIN WowArenaLadder/images/races/races_dwarf-female.png
  22. BIN WowArenaLadder/images/races/races_dwarf-male.png
  23. BIN WowArenaLadder/images/races/races_gnome-female.png
  24. BIN WowArenaLadder/images/races/races_gnome-male.png
  25. BIN WowArenaLadder/images/races/races_goblin-female.png
  26. BIN WowArenaLadder/images/races/races_goblin-male.png
  27. BIN WowArenaLadder/images/races/races_human-female.png
  28. BIN WowArenaLadder/images/races/races_human-male.png
  29. BIN WowArenaLadder/images/races/races_nightelf-female.png
  30. BIN WowArenaLadder/images/races/races_nightelf-male.png
  31. BIN WowArenaLadder/images/races/races_orc-female.png
  32. BIN WowArenaLadder/images/races/races_orc-male.png
  33. BIN WowArenaLadder/images/races/races_tauren-female.png
  34. BIN WowArenaLadder/images/races/races_tauren-male.png
  35. BIN WowArenaLadder/images/races/races_troll-female.png
  36. BIN WowArenaLadder/images/races/races_troll-male.png
  37. BIN WowArenaLadder/images/races/races_undead-female.png
  38. BIN WowArenaLadder/images/races/races_undead-male.png
  39. BIN WowArenaLadder/images/races/races_worgen-female.png
  40. BIN WowArenaLadder/images/races/races_worgen-male.png
View
@@ -7,7 +7,7 @@ public class ArenaLadder
{
#pragma warning disable 0649
[DataMember(Name = "arenateam")]
- public ArenaTeam[] ArenaTeam { get; private set; }
+ public ArenaTeam[] ArenaTeams { get; private set; }
#pragma warning restore 0649
}
}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -1,4 +1,8 @@
using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Drawing;
+using System.Linq;
using System.Windows.Forms;
using WCPAPI;
@@ -7,7 +11,6 @@ namespace WowArenaLadder
public partial class Form1 : Form
{
private ListViewColumnSorter columnSorter;
- private ArenaLadder m_ladder;
private ApiClient m_client;
private string m_battlegroup;
private string m_size = "2v2";
@@ -61,8 +64,6 @@ private void QueryBGs()
void bgToolStripItem_Click(object sender, EventArgs e)
{
- ladderView.Items.Clear();
-
foreach (ToolStripMenuItem bg in battlegroupToolStripMenuItem.DropDownItems)
{
if (bg != sender)
@@ -82,26 +83,25 @@ private void listView1_ColumnClick(object sender, ColumnClickEventArgs e)
ladderView.Sort();
}
- private ListViewItem CreateListViewItemByIndex(int index)
+ private ListViewItem CreateListViewItemFromTeam(ArenaTeam team)
{
- var team = m_ladder.ArenaTeam[index];
-
- return new ListViewItem(new string[]
+ var item = new ListViewItem(new string[]
{
team.Ranking.ToString(),
team.Name,
team.Realm,
team.Side,
- team.GamesWon.ToString(),
- team.GamesLost.ToString(),
- team.Rating.ToString()
+ team.SessionGamesWon.ToString(),
+ team.SessionGamesLost.ToString(),
+ team.Rating.ToString(),
});
+
+ item.Tag = team;
+ return item;
}
private void teamSizeToolStripMenuItem_Click(object sender, EventArgs e)
{
- ladderView.Items.Clear();
-
foreach (ToolStripMenuItem region in teamSizeToolStripMenuItem.DropDownItems)
if (region != sender)
region.Checked = false;
@@ -113,14 +113,83 @@ private void teamSizeToolStripMenuItem_Click(object sender, EventArgs e)
private void QueryData()
{
- m_ladder = m_client.GetArenaLadder(m_battlegroup, m_size, 2000);
+ var ladder = m_client.GetArenaLadder(m_battlegroup, m_size, 2000);
- if (m_ladder.ArenaTeam == null)
+ if (ladder.ArenaTeams == null)
return;
- int i = 0;
- foreach (var team in m_ladder.ArenaTeam)
- ladderView.Items.Add(CreateListViewItemByIndex(i++));
+ ladderView.BeginUpdate();
+
+ ladderView.Items.Clear();
+
+ foreach (var team in ladder.ArenaTeams)
+ ladderView.Items.Add(CreateListViewItemFromTeam(team));
+
+ ladderView.EndUpdate();
+ }
+
+ private void ladderView_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
+ {
+ e.DrawDefault = true;
+ }
+
+ private static Dictionary<CharacterClass, Image> ImageByClass = new Dictionary<CharacterClass, Image>
+ {
+ { CharacterClass.Warrior, Properties.Resources.classes_warrior },
+ { CharacterClass.Paladin, Properties.Resources.classes_paladin },
+ { CharacterClass.Hunter, Properties.Resources.classes_hunter },
+ { CharacterClass.Rogue, Properties.Resources.classes_rogue },
+ { CharacterClass.Priest, Properties.Resources.classes_priest },
+ { CharacterClass.DeathKnight, Properties.Resources.classes_deathknight },
+ { CharacterClass.Shaman, Properties.Resources.classes_shaman },
+ { CharacterClass.Mage, Properties.Resources.classes_mage },
+ { CharacterClass.Warlock, Properties.Resources.classes_warlock },
+ { CharacterClass.Druid, Properties.Resources.classes_druid }
+ };
+
+ private void ladderView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
+ {
+ if (e.ColumnIndex == 1)
+ {
+ if ((e.ItemState & ListViewItemStates.Selected) != 0)
+ e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds);
+
+ e.Graphics.DrawString(e.SubItem.Text, ladderView.Font, new SolidBrush(ladderView.ForeColor), e.Bounds);
+
+ var team = e.Item.Tag as ArenaTeam;
+
+ var sortedMembers = team.Members.OrderByDescending(k => k.PersonalRating).ToArray();
+
+ var height = e.Bounds.Height;
+
+ for (int i = 0; i < team.TeamSize && i < sortedMembers.Length; ++i)
+ e.Graphics.DrawImage(ImageByClass[sortedMembers[i].Character.Class], e.Bounds.Right - (i + 1) * height, e.Bounds.Y, height, height);
+ }
+ else
+ e.DrawDefault = true;
+ }
+
+ private void ladderView_MouseMove(object sender, MouseEventArgs e)
+ {
+ ListViewItem item = ladderView.GetItemAt(e.X, e.Y);
+ if (item != null)
+ ladderView.Invalidate(item.Bounds);
+ }
+
+ private void ladderView_SizeChanged(object sender, EventArgs e)
+ {
+ ladderView.Invalidate();
+ }
+
+ private void ladderView_MouseDoubleClick(object sender, MouseEventArgs e)
+ {
+ ListViewItem item = ladderView.GetItemAt(e.X, e.Y);
+ if (item != null)
+ {
+ var team = item.Tag as ArenaTeam;
+
+ Process.Start(String.Format("http://eu.battle.net/wow/en/arena/{0}/{1}v{1}/{2}/", team.Realm, team.TeamSize, team.Name));
+ }
}
}
}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 667e27a

Please sign in to comment.