public SelectChampOverlay(TeamQueuePage tqp)
        {
            InitializeComponent();
            teamQueuePage = tqp;
            ChampionSelectListView.Items.Clear();
            if (true)
            {
                ChampList = new List<ChampionDTO>(Client.PlayerChampions);
                ChampList.Sort(
                    (x, y) =>
                        string.Compare(champions.GetChampion(x.ChampionId)
                            .displayName, champions.GetChampion(y.ChampionId).displayName, StringComparison.Ordinal));

                foreach (ChampionDTO champ in ChampList)
                {
                    champions getChamp = champions.GetChampion(champ.ChampionId);
                    if ((!champ.Owned && !champ.FreeToPlay))
                        continue;

                    //Add to ListView
                    var item = new ListViewItem();
                    var championImage = new ChampionImage
                    {
                        ChampImage = {Source = champions.GetChampion(champ.ChampionId).icon}
                    };
                    if (champ.FreeToPlay)
                        championImage.FreeToPlayLabel.Visibility = Visibility.Visible;
                    championImage.Width = 64;
                    championImage.Height = 64;
                    item.Tag = champ.ChampionId;
                    item.Content = championImage.Content;
                    ChampionSelectListView.Items.Add(item);
                }
                var items = new ListViewItem();
                var img = new ChampionImage
                {
                    ChampImage = {Source = Client.GetImage("getNone")},
                    Width = 64,
                    Height = 64
                };
                items.Tag = 0;
                items.Content = img.Content;
                ChampionSelectListView.Items.Add(items);
            }
        }
 /// <summary>
 /// Render all champions
 /// </summary>
 /// <param name="RenderBans">Render champions for ban</param>
 internal void RenderChamps(bool RenderBans)
 {
     ChampionSelectListView.Items.Clear();
     if (!RenderBans)
     {
         foreach (ChampionDTO champ in ChampList)
         {
             champions getChamp = champions.GetChampion(champ.ChampionId);
             if ((champ.Owned || champ.FreeToPlay) && getChamp.displayName.ToLower().Contains(SearchTextBox.Text.ToLower()))
             {
                 //Add to ListView
                 ListViewItem item = new ListViewItem();
                 ChampionImage championImage = new ChampionImage();
                 championImage.ChampImage.Source = champions.GetChampion(champ.ChampionId).icon;
                 if (champ.FreeToPlay)
                     championImage.FreeToPlayLabel.Visibility = Visibility.Visible;
                 championImage.Width = 64;
                 championImage.Height = 64;
                 item.Tag = champ.ChampionId;
                 item.Content = championImage.Content;
                 ChampionSelectListView.Items.Add(item);
             }
         }
     }
     else
     {
         foreach (ChampionBanInfoDTO champ in ChampionsForBan)
         {
             champions getChamp = champions.GetChampion(champ.ChampionId);
             if (champ.EnemyOwned && getChamp.displayName.ToLower().Contains(SearchTextBox.Text.ToLower()))
             {
                 //Add to ListView
                 ListViewItem item = new ListViewItem();
                 ChampionImage championImage = new ChampionImage();
                 championImage.ChampImage.Source = champions.GetChampion(champ.ChampionId).icon;
                 championImage.Width = 64;
                 championImage.Height = 64;
                 item.Tag = champ.ChampionId;
                 item.Content = championImage.Content;
                 ChampionSelectListView.Items.Add(item);
             }
         }
     }
 }
        /// <summary>
        ///     Render all champions
        /// </summary>
        /// <param name="renderBans">Render champions for ban</param>
        internal void RenderChamps(bool renderBans)
        {
            ChampionSelectListView.Items.Clear();
            if (!renderBans)
            {
                foreach (ChampionDTO champ in ChampList)
                {
                    champions getChamp = champions.GetChampion(champ.ChampionId);
                    if (previousPage.GetType() == typeof(FactionsGameLobbyPage))
                    {
                        var page = previousPage as FactionsGameLobbyPage;
                        if (page != null)
                        {
                            LeftTeamLabel.Content = page.GetLeftTeam();
                            RightTeamLabel.Content = page.GetRightTeam();
                            string myTeam = (AreWePurpleSide) ? page.GetRightTeam() : page.GetLeftTeam();
                            switch (myTeam)
                            {
                                case "Ionia":
                                    if (!ioniaChampions.Contains(getChamp.displayName)) continue;
                                    break;
                                case "Bilgewater":
                                    if (!bilgewaterChampions.Contains(getChamp.displayName)) continue;
                                    break;
                                case "Freljord":
                                    if (!freljordChampions.Contains(getChamp.displayName)) continue;
                                    break;
                                case "Shadow Isles":
                                    if (!shadowIslesChampions.Contains(getChamp.displayName)) continue;
                                    break;
                                case "Demacia":
                                    if (!demaciaChampions.Contains(getChamp.displayName)) continue;
                                    break;
                                case "Noxus":
                                    if (!noxusChampions.Contains(getChamp.displayName)) continue;
                                    break;
                                case "Piltover":
                                    if (!piltoverChampions.Contains(getChamp.displayName)) continue;
                                    break;
                                case "Bandle City":
                                    if (!bandleCityChampions.Contains(getChamp.displayName)) continue;
                                    break;
                                case "Zaun":
                                    if (!zaunChampions.Contains(getChamp.displayName)) continue;
                                    break;
                                case "Void":
                                    if (!voidChampions.Contains(getChamp.displayName)) continue;
                                    break;
                                case "ShUrima":
                                    if (!shUrimaChampions.Contains(getChamp.displayName)) continue;
                                    break;
                                case "Discord":
                                    if (!discordChampions.Contains(getChamp.displayName)) continue;
                                    break;
                            }
                        }
                    }
                    if (((!champ.Owned && !champ.FreeToPlay) ||
                        !getChamp.displayName.ToLower().Contains(SearchTextBox.Text.ToLower())) &&
                        LatestDto.QueueTypeName != "COUNTER_PICK")
                        continue;

                    //Add to ListView
                    var item = new ListViewItem();
                    var championImage = new ChampionImage
                    {
                        ChampImage = { Source = champions.GetChampion(champ.ChampionId).icon }
                    };

                    if (champ.FreeToPlay || !champ.Active)
                        championImage.FreeToPlayLabel.Visibility = Visibility.Visible;

                    if (!champ.Active)
                    {
                        disabledCharacters.Add(champ.ChampionId);
                        championImage.FreeToPlayLabel.Content = "Disabled";
                        championImage.FreeToPlayLabel.FontSize = 11;
                    }

                    championImage.Width = 60;
                    championImage.Height = 60;
                    item.Tag = champ.ChampionId;
                    item.Content = championImage.Content;
                    ChampionSelectListView.Items.Add(item);
                }
            }
            else
            {
                foreach (ChampionBanInfoDTO champ in ChampionsForBan)
                {
                    champions getChamp = champions.GetChampion(champ.ChampionId);
                    if (!champ.EnemyOwned || !getChamp.displayName.ToLower().Contains(SearchTextBox.Text.ToLower()))
                        continue;

                    //Add to ListView
                    var item = new ListViewItem();
                    var championImage = new ChampionImage
                    {
                        ChampImage = { Source = champions.GetChampion(champ.ChampionId).icon },
                        Width = 60,
                        Height = 60
                    };
                    item.Tag = champ.ChampionId;
                    item.Content = championImage.Content;
                    ChampionSelectListView.Items.Add(item);
                }
            }
        }
 private void LoadStats()
 {
     ChampionSelectListView.Items.Clear();
     if (true)
     {
         ChampList = new List<ChampionDTO>(Client.PlayerChampions);
         foreach (ChampionDTO champ in ChampList)
         {
             champions getChamp = champions.GetChampion(champ.ChampionId);
             if ((champ.Owned || champ.FreeToPlay))
             {
                 //Add to ListView
                 var item = new ListViewItem();
                 var championImage = new ChampionImage();
                 championImage.ChampImage.Source = champions.GetChampion(champ.ChampionId).icon;
                 if (champ.FreeToPlay)
                     championImage.FreeToPlayLabel.Visibility = Visibility.Visible;
                 championImage.Width = 64;
                 championImage.Height = 64;
                 item.Tag = champ.ChampionId;
                 item.Content = championImage.Content;
                 ChampionSelectListView.Items.Add(item);
             }
         }
     }
 }
        private void SearchBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            ChampionSelectListView.Items.Clear();

            List<ChampionDTO> tempList = ChampList.ToList();

            if (SearchTextBox.Text != "Search" && !string.IsNullOrEmpty(SearchTextBox.Text))
            {
                tempList =
                    tempList.Where(
                        x =>
                            champions.GetChampion(x.ChampionId)
                                .displayName.ToLower()
                                .Contains(SearchTextBox.Text.ToLower())).ToList();
            }

            foreach (ChampionDTO champ in tempList)
            {
                champions getChamp = champions.GetChampion(champ.ChampionId);
                if ((!champ.Owned && !champ.FreeToPlay))
                    continue;

                //Add to ListView
                var item = new ListViewItem();
                var championImage = new ChampionImage
                {
                    ChampImage = {Source = champions.GetChampion(champ.ChampionId).icon}
                };
                if (champ.FreeToPlay)
                    championImage.FreeToPlayLabel.Visibility = Visibility.Visible;
                championImage.Width = 64;
                championImage.Height = 64;
                item.Tag = champ.ChampionId;
                item.Content = championImage.Content;
                ChampionSelectListView.Items.Add(item);
            }
        }
        private async void StartChampSelect()
        {
            Client.FocusClient();
            Champions = Client.PlayerChampions;
            MyMasteries = Client.LoginPacket.AllSummonerData.MasteryBook;
            MyRunes = Client.LoginPacket.AllSummonerData.SpellBook;

            
            int i = 0;
            foreach (MasteryBookPageDTO MasteryPage in MyMasteries.BookPages)
            {
                string MasteryPageName = MasteryPage.Name;
                if (MasteryPageName.StartsWith("@@"))
                {
                    MasteryPageName = "Mastery Page " + ++i;
                }
                MasteryComboBox.Items.Add(MasteryPageName);
                if (MasteryPage.Current)
                    MasteryComboBox.SelectedValue = MasteryPageName;
            }
            i = 0;
            foreach (SpellBookPageDTO RunePage in MyRunes.BookPages)
            {
                string RunePageName = RunePage.Name;
                if (RunePageName.StartsWith("@@"))
                {
                    RunePageName = "Rune Page " + ++i;
                }
                RuneComboBox.Items.Add(RunePageName);
                if (RunePage.Current)
                    RuneComboBox.SelectedValue = RunePageName;
            }
             

            QuickLoad = true;

            await Client.PVPNet.SetClientReceivedGameMessage(Client.GameID, "CHAMP_SELECT_CLIENT");
            GameDTO latestDTO = await Client.PVPNet.GetLatestGameTimerState(Client.GameID, Client.ChampSelectDTO.GameState, Client.ChampSelectDTO.PickTurn);
            configType = Client.LoginPacket.GameTypeConfigs.Find(x => x.Id == latestDTO.GameTypeConfigId);
            if (configType == null) //Invalid config... abort!
            {
                Client.PVPNet.OnMessageReceived -= ChampSelect_OnMessageReceived;
                await Client.PVPNet.QuitGame();
                Client.ClearPage(this);

                Client.SwitchPage(new MainPage());
                MessageOverlay overlay = new MessageOverlay();
                overlay.MessageTextBox.Text = "Invalid Config ID (" + latestDTO.GameTypeConfigId.ToString() + "). Report to Snowl [https://github.com/Snowl/LegendaryClient/issues/new]";
                overlay.MessageTitle.Content = "Invalid Config";
                Client.OverlayContainer.Content = overlay.Content;
                Client.OverlayContainer.Visibility = Visibility.Visible;
                return;
            }
            counter = configType.MainPickTimerDuration - 5; //Seems to be a 5 second inconsistancy with riot and what they actually provide
            CountdownTimer = new System.Windows.Forms.Timer();
            CountdownTimer.Tick += new EventHandler(CountdownTimer_Tick);
            CountdownTimer.Interval = 1000; // 1 second
            CountdownTimer.Start();

            LatestDto = latestDTO;

            string JID = Client.GetChatroomJID(latestDTO.RoomName.Replace("@sec", ""), latestDTO.RoomPassword, false);
            Chatroom = Client.ConfManager.GetRoom(new jabber.JID(JID));
            Chatroom.Nickname = Client.LoginPacket.AllSummonerData.Summoner.Name;
            Chatroom.OnRoomMessage += Chatroom_OnRoomMessage;
            Chatroom.OnParticipantJoin += Chatroom_OnParticipantJoin;
            Chatroom.Join(latestDTO.RoomPassword);

            List<ChampionDTO> champList = new List<ChampionDTO>(Champions);

            champList.Sort((x, y) => champions.GetChampion(x.ChampionId).displayName.CompareTo(champions.GetChampion(y.ChampionId).displayName));

            foreach (ChampionDTO champ in champList)
            {
                if (champ.Owned || champ.FreeToPlay)
                {
                    MyChamps.Add(champ);

                    //Add to ListView
                    ListViewItem item = new ListViewItem();
                    ChampionImage championImage = new ChampionImage();
                    championImage.ChampImage.Source = champions.GetChampion(champ.ChampionId).icon;
                    if (champ.FreeToPlay)
                        championImage.FreeToPlayLabel.Visibility = Visibility.Visible;
                    championImage.Width = 64;
                    championImage.Height = 64;
                    item.Tag = champ.ChampionId;
                    item.Content = championImage.Content;
                    ChampionSelectListView.Items.Add(item);
                }
            }

            ChampSelect_OnMessageReceived(this, latestDTO);
            Client.PVPNet.OnMessageReceived += ChampSelect_OnMessageReceived;
        }