public void RenderTopPlayedChampions(ChampionStatInfo[] topChampions) { ViewAggregatedStatsButton.IsEnabled = false; TopChampionsListView.Items.Clear(); if (!topChampions.Any()) { return; } TopChampionsLabel.Content = "Top Champions (" + topChampions[0].TotalGamesPlayed + " Ranked Games)"; foreach (var info in topChampions) { ViewAggregatedStatsButton.IsEnabled = true; if (!(Math.Abs(info.ChampionId) > 0)) { continue; } var champion = champions.GetChampion(Convert.ToInt32(info.ChampionId)); var player = new ChatPlayer { LevelLabel = {Visibility = Visibility.Hidden}, PlayerName = {Content = champion.displayName}, PlayerStatus = {Content = info.TotalGamesPlayed + " games played"}, ProfileImage = {Source = champions.GetChampion(champion.id).icon}, Background = new SolidColorBrush(Color.FromArgb(102, 80, 80, 80)), Height = 52, Width = 278 }; TopChampionsListView.Items.Add(player); } }
private void UpdateChat(object sender, ElapsedEventArgs e) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { AvailablePlayerListView.Items.Clear(); InvitedPlayerListView.Items.Clear(); foreach (var chatPlayerPair in Client.AllPlayers.ToArray()) { if (chatPlayerPair.Value.Level == 0) continue; var player = new ChatPlayer { Width = 250, Tag = chatPlayerPair.Value, DataContext = chatPlayerPair.Value }; var playerItem = (ChatPlayerItem) player.Tag; player.PlayerName.Content = playerItem.Username; player.PlayerStatus.Content = playerItem.Status; player.PlayerId.Content = playerItem.Id; player.LevelLabel.Content = chatPlayerPair.Value.Level; string UriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", chatPlayerPair.Value.ProfileIcon + ".png"); player.ProfileImage.Source = Client.GetImage(UriSource); //Show available players if (chatPlayerPair.Value.GameStatus != "outOfGame") continue; bool shouldBreak = false; KeyValuePair<string, ChatPlayerItem> pair = chatPlayerPair; foreach (InvitePlayer invitePlayer in from object x in Client.InviteListView.Items select x as InvitePlayer into invitePlayer where (string) invitePlayer.PlayerLabel.Content == pair.Value.Username where (string) invitePlayer.StatusLabel.Content == "Accepted" select invitePlayer) shouldBreak = true; if (shouldBreak) continue; if (invitedPlayers.Contains(chatPlayerPair.Value.Id)) InvitedPlayerListView.Items.Add(player); else AvailablePlayerListView.Items.Add(player); } })); }
private void UpdateChat(object sender, System.Timers.ElapsedEventArgs e) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { AvailablePlayerListView.Items.Clear(); InvitedPlayerListView.Items.Clear(); foreach (KeyValuePair<string, ChatPlayerItem> ChatPlayerPair in Client.AllPlayers.ToArray()) { if (ChatPlayerPair.Value.Level != 0) { ChatPlayer player = new ChatPlayer(); player.Width = 250; player.Tag = ChatPlayerPair.Value; player.DataContext = ChatPlayerPair.Value; ChatPlayerItem playerItem = (ChatPlayerItem)player.Tag; player.PlayerName.Content = playerItem.Username; player.PlayerStatus.Content = playerItem.Status; player.PlayerId.Content = playerItem.Id; player.LevelLabel.Content = ChatPlayerPair.Value.Level; var uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", ChatPlayerPair.Value.ProfileIcon + ".png"); player.ProfileImage.Source = Client.GetImage(uriSource); //Show available players if (ChatPlayerPair.Value.GameStatus != "outOfGame") continue; bool ShouldBreak = false; foreach (var x in Client.InviteListView.Items) { InvitePlayer invitePlayer = x as InvitePlayer; if ((string)invitePlayer.PlayerLabel.Content == ChatPlayerPair.Value.Username) if ((string)invitePlayer.StatusLabel.Content == "Accepted") ShouldBreak = true; } if (ShouldBreak) continue; if (invitedPlayers.Contains(ChatPlayerPair.Value.Id)) { InvitedPlayerListView.Items.Add(player); } else { AvailablePlayerListView.Items.Add(player); } } } })); }
public void RenderTopPlayedChampions(ChampionStatInfo[] TopChampions) { ViewAggregatedStatsButton.IsEnabled = false; TopChampionsListView.Items.Clear(); if (TopChampions.Count() > 0) { TopChampionsLabel.Content = "Top Champions (" + TopChampions[0].TotalGamesPlayed + " Ranked Games)"; foreach (ChampionStatInfo info in TopChampions) { ViewAggregatedStatsButton.IsEnabled = true; if (info.ChampionId != 0.0) { ChatPlayer player = new ChatPlayer(); champions Champion = champions.GetChampion(Convert.ToInt32(info.ChampionId)); player.LevelLabel.Visibility = System.Windows.Visibility.Hidden; player.PlayerName.Content = Champion.displayName; player.PlayerStatus.Content = info.TotalGamesPlayed + " games played"; player.ProfileImage.Source = champions.GetChampion(Champion.id).icon; TopChampionsListView.Items.Add(player); } } } }
private void UpdateChat(object sender, System.Timers.ElapsedEventArgs e) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { if (Client.CurrentStatus != StatusBox.Text && StatusBox.Text != "Set your status message") { Client.CurrentStatus = StatusBox.Text; } else if (StatusBox.Text == "Set your status message") { Client.CurrentStatus = "Online"; } Properties.Settings.Default.StatusMsg = StatusBox.Text; Properties.Settings.Default.Save(); if (Client.UpdatePlayers) { Client.UpdatePlayers = false; ChatListView.Items.Clear(); Expander testExpander = new Expander(); ListView testGrid = new ListView(); testGrid.HorizontalAlignment = HorizontalAlignment.Stretch; testGrid.VerticalAlignment = VerticalAlignment.Stretch; testGrid.Foreground = Brushes.White; testGrid.Background = null; testGrid.BorderBrush = null; testGrid.SelectionChanged += ChatListView_SelectionChanged; foreach (KeyValuePair<string, ChatPlayerItem> ChatPlayerPair in Client.AllPlayers.ToArray()) { ChatPlayer player = new ChatPlayer(); player.Tag = ChatPlayerPair.Value; player.DataContext = ChatPlayerPair.Value; player.ContextMenu = (ContextMenu)Resources["PlayerChatMenu"]; if (ChatPlayerPair.Value.Level != 0) { player.Width = 250; BrushConverter bc = new BrushConverter(); Brush brush = (Brush)bc.ConvertFrom("#FFFFFFFF"); player.PlayerStatus.Foreground = brush; var uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", ChatPlayerPair.Value.ProfileIcon + ".png"); player.ProfileImage.Source = Client.GetImage(uriSource); if (ChatPlayerPair.Value.GameStatus != "outOfGame") { switch (ChatPlayerPair.Value.GameStatus) { case "inGame": champions InGameChamp = champions.GetChampion(ChatPlayerPair.Value.Champion); if (InGameChamp != null) player.PlayerStatus.Content = "In Game as " + InGameChamp.displayName; else player.PlayerStatus.Content = "In Game"; break; case "hostingPracticeGame": player.PlayerStatus.Content = "Creating Custom Game"; break; case "inQueue": player.PlayerStatus.Content = "In Queue"; break; case "spectating": player.PlayerStatus.Content = "Spectating"; break; case "championSelect": player.PlayerStatus.Content = "In Champion Select"; break; } brush = (Brush)bc.ConvertFrom("#FFFFFF99"); player.PlayerStatus.Foreground = brush; } player.MouseMove += ChatPlayerMouseOver; player.MouseLeave += player_MouseLeave; } else { player.Width = 250; player.Height = 30; player.PlayerName.Margin = new Thickness(5, 2.5, 0, 0); player.LevelLabel.Visibility = System.Windows.Visibility.Hidden; player.ProfileImage.Visibility = System.Windows.Visibility.Hidden; } testGrid.Items.Add(player); } testExpander.Content = testGrid; ChatListView.Items.Add(testExpander); } })); }
private void GotStats(AggregatedStats stats) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { SelectedAggregatedStats = stats; ViewAggregatedStatsButton.IsEnabled = false; TopChampionsListView.Items.Clear(); List<AggregatedChampion> ChampionStats = new List<AggregatedChampion>(); int i = 0; if (SelectedAggregatedStats.LifetimeStatistics.Count() > 0) { foreach (AggregatedStat stat in SelectedAggregatedStats.LifetimeStatistics) { AggregatedChampion Champion = null; Champion = ChampionStats.Find(x => x.ChampionId == stat.ChampionId); if (Champion == null) { Champion = new AggregatedChampion(); Champion.ChampionId = stat.ChampionId; ChampionStats.Add(Champion); } var type = typeof(AggregatedChampion); string fieldName = Client.TitleCaseString(stat.StatType.Replace('_', ' ')).Replace(" ", ""); var f = type.GetField(fieldName); f.SetValue(Champion, stat.Value); } ChampionStats.Sort((x, y) => y.TotalSessionsPlayed.CompareTo(x.TotalSessionsPlayed)); foreach (AggregatedChampion info in ChampionStats) { if (i++ > 6) break; ViewAggregatedStatsButton.IsEnabled = true; if (info.ChampionId != 0.0) { ChatPlayer player = new ChatPlayer(); champions Champion = champions.GetChampion(Convert.ToInt32(info.ChampionId)); player.LevelLabel.Visibility = System.Windows.Visibility.Hidden; player.PlayerName.Content = Champion.displayName; player.PlayerStatus.Content = info.TotalSessionsPlayed + " games played"; player.ProfileImage.Source = champions.GetChampion(Champion.id).icon; TopChampionsListView.Items.Add(player); } } } })); }
private void UpdateChat(object sender, ElapsedEventArgs e) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async () => { if (Client.CurrentStatus != StatusBox.Text && StatusBox.Text != "Set your status message") Client.CurrentStatus = StatusBox.Text; else if (StatusBox.Text == "Set your status message") Client.CurrentStatus = "Online"; Settings.Default.StatusMsg = StatusBox.Text; Settings.Default.Save(); if (!Client.UpdatePlayers) return; Client.UpdatePlayers = false; ChatListView.Children.Clear(); #region "Groups" while (!Client.loadedGroups) { await Task.Delay(1000); } foreach (Group g in Client.Groups) { var playersListView = new ListView { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalContentAlignment = VerticalAlignment.Stretch }; playersListView.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled); playersListView.Foreground = Brushes.White; playersListView.Background = null; playersListView.BorderBrush = null; playersListView.MouseDoubleClick += PlayersListView_MouseDoubleClick; playersListView.SelectionChanged += ChatListView_SelectionChanged; playersListView.PreviewMouseWheel += PlayersListView_PreviewMouseWheel; int players = 0; foreach (var chatPlayerPair in Client.AllPlayers.ToArray().OrderBy(u => u.Value.Username)) { var player = new ChatPlayer { Tag = chatPlayerPair.Value, DataContext = chatPlayerPair.Value, ContextMenu = (ContextMenu)Resources["PlayerChatMenu"], PlayerName = { Content = chatPlayerPair.Value.Username }, LevelLabel = { Content = chatPlayerPair.Value.Level } }; var bc = new BrushConverter(); var brush = (Brush)bc.ConvertFrom("#FFFFFFFF"); player.PlayerStatus.Content = chatPlayerPair.Value.Status; player.PlayerStatus.Foreground = brush; if (chatPlayerPair.Value.IsOnline && g.GroupName == chatPlayerPair.Value.Group) { player.Width = 250; bc = new BrushConverter(); brush = (Brush)bc.ConvertFrom("#FFFFFFFF"); player.PlayerStatus.Foreground = brush; string UriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", chatPlayerPair.Value.ProfileIcon + ".png"); player.ProfileImage.Source = Client.GetImage(UriSource); if (chatPlayerPair.Value.GameStatus != "outOfGame") { switch (chatPlayerPair.Value.GameStatus) { case "inGame": champions inGameChamp = champions.GetChampion(chatPlayerPair.Value.Champion); if (inGameChamp != null) player.PlayerStatus.Content = "In Game as " + inGameChamp.displayName; else player.PlayerStatus.Content = "In Game"; break; case "hostingPracticeGame": player.PlayerStatus.Content = "Creating Custom Game"; break; case "inQueue": player.PlayerStatus.Content = "In Queue"; break; case "spectating": player.PlayerStatus.Content = "Spectating"; break; case "championSelect": player.PlayerStatus.Content = "In Champion Select"; break; case "hostingRankedGame": player.PlayerStatus.Content = "Creating Ranked Game"; break; case "teamSelect": player.PlayerStatus.Content = "In Team Select"; break; case "hostingNormalGame": player.PlayerStatus.Content = "Creating Normal Game"; break; case "hostingCoopVsAIGame": player.PlayerStatus.Content = "Creating Co-op vs. AI Game"; break; case "inTeamBuilder": player.PlayerStatus.Content = "In Team Builder"; break; case "tutorial": player.PlayerStatus.Content = "In Tutorial"; break; } brush = (Brush)bc.ConvertFrom("#FFFFFF99"); player.PlayerStatus.Foreground = brush; } player.MouseRightButtonDown += player_MouseRightButtonDown; player.MouseMove += ChatPlayerMouseOver; player.MouseLeave += player_MouseLeave; playersListView.Items.Add(player); players++; } else if (!chatPlayerPair.Value.IsOnline && g.GroupName == "Offline") { player.Width = 250; player.Height = 30; player.PlayerName.Margin = new Thickness(5, 2.5, 0, 0); player.LevelLabel.Visibility = Visibility.Hidden; player.ProfileImage.Visibility = Visibility.Hidden; playersListView.Items.Add(player); players++; } } var groupControl = new ChatGroup { Width = 230, PlayersLabel = { Content = players }, NameLabel = { Content = g.GroupName } }; groupControl.GroupListView.Children.Add(playersListView); if (g.IsOpen) { groupControl.ExpandLabel.Content = "-"; groupControl.GroupListView.Visibility = Visibility.Visible; } if (!string.IsNullOrEmpty(g.GroupName)) ChatListView.Children.Add(groupControl); else Client.Log("Removed a group"); } #endregion if (ChatListView.Children.Count > 0 && ChatListView.Children[0] is ChatGroup && loaded) { //Stop droping 100 times (ChatListView.Children[0] as ChatGroup).GroupGrid_MouseDown(null, null); loaded = true; } })); }
private void UpdateChat(object sender, System.Timers.ElapsedEventArgs e) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { if (Client.CurrentStatus != StatusBox.Text && StatusBox.Text != "Set your status message") { Client.CurrentStatus = StatusBox.Text; } else if (StatusBox.Text == "Set your status message") { Client.CurrentStatus = "Online"; } Properties.Settings.Default.StatusMsg = StatusBox.Text; Properties.Settings.Default.Save(); if (Client.UpdatePlayers) { Client.UpdatePlayers = false; ChatListView.Items.Clear(); foreach (KeyValuePair<string, ChatPlayerItem> ChatPlayerPair in Client.AllPlayers.ToArray()) { if (ChatPlayerPair.Value.Level != 0) { ChatPlayer player = new ChatPlayer(); player.Width = 250; player.Tag = ChatPlayerPair.Value; player.PlayerName.Content = ChatPlayerPair.Value.Username; player.LevelLabel.Content = ChatPlayerPair.Value.Level; BrushConverter bc = new BrushConverter(); Brush brush = (Brush)bc.ConvertFrom("#FFFFFFFF"); player.PlayerStatus.Content = ChatPlayerPair.Value.Status; player.PlayerStatus.Foreground = brush; var uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", ChatPlayerPair.Value.ProfileIcon + ".png"); player.ProfileImage.Source = Client.GetImage(uriSource); if (ChatPlayerPair.Value.GameStatus != "outOfGame") { switch (ChatPlayerPair.Value.GameStatus) { case "inGame": champions InGameChamp = champions.GetChampion(ChatPlayerPair.Value.Champion); if (InGameChamp != null) player.PlayerStatus.Content = "In Game as " + InGameChamp.displayName; else player.PlayerStatus.Content = "In Game"; break; case "hostingPracticeGame": player.PlayerStatus.Content = "Creating Custom Game"; break; case "inQueue": player.PlayerStatus.Content = "In Queue"; break; case "spectating": player.PlayerStatus.Content = "Spectating"; break; case "championSelect": player.PlayerStatus.Content = "In Champion Select"; break; } brush = (Brush)bc.ConvertFrom("#FFFFFF99"); player.PlayerStatus.Foreground = brush; } player.ContextMenu = (ContextMenu)Resources["PlayerChatMenu"]; player.MouseMove += ChatPlayerMouseOver; player.MouseLeave += player_MouseLeave; ChatListView.Items.Add(player); } } } })); }
private void UpdateChat(object sender, System.Timers.ElapsedEventArgs e) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { if (Client.CurrentStatus != StatusBox.Text && StatusBox.Text != "Set your status message") { Client.CurrentStatus = StatusBox.Text; } else if (StatusBox.Text == "Set your status message") { Client.CurrentStatus = "Online"; } Properties.Settings.Default.StatusMsg = StatusBox.Text; Properties.Settings.Default.Save(); if (Client.UpdatePlayers) { Client.UpdatePlayers = false; ChatListView.Children.Clear(); foreach (Group g in Client.Groups) { ListView PlayersListView = new ListView(); PlayersListView.HorizontalAlignment = HorizontalAlignment.Stretch; PlayersListView.VerticalContentAlignment = VerticalAlignment.Stretch; PlayersListView.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled); PlayersListView.Foreground = Brushes.White; PlayersListView.Background = null; PlayersListView.BorderBrush = null; PlayersListView.SelectionChanged += ChatListView_SelectionChanged; PlayersListView.PreviewMouseWheel += PlayersListView_PreviewMouseWheel; int Players = 0; foreach (KeyValuePair<string, ChatPlayerItem> ChatPlayerPair in Client.AllPlayers.ToArray()) { ChatPlayer player = new ChatPlayer(); player.Tag = ChatPlayerPair.Value; player.DataContext = ChatPlayerPair.Value; player.ContextMenu = (ContextMenu)Resources["PlayerChatMenu"]; if (ChatPlayerPair.Value.IsOnline && g.GroupName == ChatPlayerPair.Value.Group) { player.Width = 250; BrushConverter bc = new BrushConverter(); Brush brush = (Brush)bc.ConvertFrom("#FFFFFFFF"); player.PlayerStatus.Foreground = brush; var uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", ChatPlayerPair.Value.ProfileIcon + ".png"); player.ProfileImage.Source = Client.GetImage(uriSource); if (ChatPlayerPair.Value.GameStatus != "outOfGame") { switch (ChatPlayerPair.Value.GameStatus) { case "inGame": champions InGameChamp = champions.GetChampion(ChatPlayerPair.Value.Champion); if (InGameChamp != null) player.PlayerStatus.Content = "In Game as " + InGameChamp.displayName; else player.PlayerStatus.Content = "In Game"; break; case "hostingPracticeGame": player.PlayerStatus.Content = "Creating Custom Game"; break; case "inQueue": player.PlayerStatus.Content = "In Queue"; break; case "spectating": player.PlayerStatus.Content = "Spectating"; break; case "championSelect": player.PlayerStatus.Content = "In Champion Select"; break; } brush = (Brush)bc.ConvertFrom("#FFFFFF99"); player.PlayerStatus.Foreground = brush; } player.MouseMove += ChatPlayerMouseOver; player.MouseLeave += player_MouseLeave; PlayersListView.Items.Add(player); Players++; } else if (!ChatPlayerPair.Value.IsOnline && g.GroupName == "Offline") { player.Width = 250; player.Height = 30; player.PlayerName.Margin = new Thickness(5, 2.5, 0, 0); player.LevelLabel.Visibility = System.Windows.Visibility.Hidden; player.ProfileImage.Visibility = System.Windows.Visibility.Hidden; PlayersListView.Items.Add(player); Players++; } } ChatGroup GroupControl = new ChatGroup(); GroupControl.Width = 230; GroupControl.PlayersLabel.Content = Players; GroupControl.NameLabel.Content = g.GroupName; GroupControl.GroupListView.Children.Add(PlayersListView); if (g.IsOpen) { GroupControl.ExpandLabel.Content = "-"; GroupControl.GroupListView.Visibility = System.Windows.Visibility.Visible; } ChatListView.Children.Add(GroupControl); } } })); }
private void GotStats(AggregatedStats stats) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { selectedAggregatedStats = stats; ViewAggregatedStatsButton.IsEnabled = false; TopChampionsListView.Items.Clear(); var championStats = new List<AggregatedChampion>(); var i = 0; if (selectedAggregatedStats.LifetimeStatistics == null) { return; } if (!selectedAggregatedStats.LifetimeStatistics.Any()) { return; } foreach (var stat in selectedAggregatedStats.LifetimeStatistics) { var champion = championStats.Find(x => Math.Abs(x.ChampionId - stat.ChampionId) < .00001); if (champion == null) { champion = new AggregatedChampion { ChampionId = stat.ChampionId }; championStats.Add(champion); } var type = typeof (AggregatedChampion); var fieldName = Client.TitleCaseString(stat.StatType.Replace('_', ' ')).Replace(" ", string.Empty); var f = type.GetField(fieldName); if (f == null) Client.Log(fieldName, "NewStatType"); else f.SetValue(champion, stat.Value); } championStats.Sort((x, y) => y.TotalSessionsPlayed.CompareTo(x.TotalSessionsPlayed)); foreach (var info in championStats.TakeWhile(info => i++ <= 6)) { ViewAggregatedStatsButton.IsEnabled = true; if (!(Math.Abs(info.ChampionId) > 0)) { continue; } var champion = champions.GetChampion(Convert.ToInt32(info.ChampionId)); var player = new ChatPlayer { LevelLabel = {Visibility = Visibility.Hidden}, PlayerName = {Content = champion.displayName}, PlayerStatus = {Content = info.TotalSessionsPlayed + " games played"}, ProfileImage = {Source = champions.GetChampion(champion.id).icon}, Background = new SolidColorBrush(Color.FromArgb(102, 80, 80, 80)), Width = 270 }; TopChampionsListView.Items.Add(player); } })); }