public void XmppConnectOnOnPresence(object sender, Presence pres)
 {
     try
     {
         if (pres.GetAttribute("name") == "Facebook User")
         {
             return;
         }
         Core.Presences.Add(pres);
         try
         {
             var chatItem = new ChatPlayerItem
             {
                 Group = pres.GetAttribute("group"),
                 IsOnline = true,
                 Jid = new Jid(pres.GetAttribute("jid")),
                 Messages = new List<string>(),
                 Username = pres.GetAttribute("name")
             };
             Core.AllPlayers.Add(pres.GetAttribute("name"), chatItem);
         }
         catch
         {
             var item = Core.AllPlayers[pres.GetAttribute("name")];
             Core.AllPlayers.Remove(pres.GetAttribute("name"));
             item.IsOnline = true;
             Core.AllPlayers.Add(pres.GetAttribute("name"), item);
         }
     }
     catch
     {
         //MessageBox.Show(ex.ToString());
     }
 }
 public void xmpp_OnRosterItem(object sender, RosterItem item)
 {
     try
     {
         Core.UserList.Add(item);
         Core.RunOnUiThread(() =>
             {
                 if (item.GetAttribute("name") == "Facebook User")
                 {
                     return;
                 }
                 try
                 {
                     var chatItem = new ChatPlayerItem
                     {
                         Group = item.GetAttribute("group"),
                         Jid = item.Jid,
                         Messages = new List<string>(),
                         Username = item.GetAttribute("name")
                     };
                     Core.AllPlayers.Add(item.GetAttribute("name"), chatItem);
                 }
                 catch
                 {
                     var itemPlayer = Core.AllPlayers[item.GetAttribute("name")];
                     Core.AllPlayers.Remove(item.GetAttribute("name"));
                     Core.AllPlayers.Add(item.GetAttribute("name"), itemPlayer);
                 }
                 var control = new PlayerChatControl
                 {
                     _playerNameLabel = { Content = item.GetAttribute("name") },
                     Tag = Core.AllPlayers[item.GetAttribute("name")]
                 };
                 Core.PlayerChatControls.Add(item.GetAttribute("jid"), control);
             });
     }
     catch
     {
         //MessageBox.Show(ex.ToString());
     }
 }
 private void LoginButtonClick(object sender, RoutedEventArgs e)
 {
     Core.Username = _usernameTextBox._waterTextbox.Text;
     Core.Password = _passwordBox.Password;
     Core.XmppConnect = new XmppClientConnection("chat.facebook.com") { Port = 5222 };
     Core.XmppConnect.OnRosterItem += xmpp_OnRosterItem;
     Core.XmppConnect.OnRosterItem += (o, g) =>
     {
         if (g.GetAttribute("name") == "Facebook User")
             return;
         var containsGroup = false;
         foreach (var group in Core.Groups.Where(group => g.GetAttribute("group") == @group.GroupName))
             containsGroup = true;
         if (!containsGroup)
             Core.Groups.Add(new Group(g.GetAttribute("group")));
         var item = new ChatPlayerItem
         {
             Jid = g.Jid,
             Group = g.GetAttribute("group"),
             Username = g.GetAttribute("name")
         };
         foreach (var items in Core.Presences.Where(items => items.GetAttribute("name") == g.GetAttribute("name")))
         {
             item.IsOnline = true;
         }
         if (!Core.AllPlayers.ContainsKey(g.GetAttribute("name")))
             Core.AllPlayers.Add(g.GetAttribute("name"), item);
     };
     Core.XmppConnect.OnPresence += XmppConnectOnOnPresence;
     Core.XmppConnect.OnLogin += xmppConnect_OnLogin;
     Core.XmppConnect.OnMessage += Core.xmppConnect_OnMessage;
     Core.XmppConnect.Open(Core.Username, Core.Password);
 }
        private void ChatPlayerMouseOver(object sender, MouseEventArgs e)
        {
            ChatPlayer     item       = (ChatPlayer)sender;
            ChatPlayerItem playerItem = (ChatPlayerItem)item.Tag;

            if (PlayerItem == null)
            {
                PlayerItem = new LargeChatPlayer();
                Client.MainGrid.Children.Add(PlayerItem);
                Panel.SetZIndex(PlayerItem, 5);
                PlayerItem.Tag = playerItem;
                PlayerItem.PlayerName.Content   = playerItem.Username;
                PlayerItem.PlayerLeague.Content = playerItem.LeagueTier + " " + playerItem.LeagueDivision;
                PlayerItem.PlayerStatus.Text    = playerItem.Status;
                if (playerItem.RankedWins == 0)
                {
                    PlayerItem.PlayerWins.Content = playerItem.Wins + " Normal Wins";
                }
                else
                {
                    PlayerItem.PlayerWins.Content = playerItem.RankedWins + " Ranked Wins";
                }
                PlayerItem.LevelLabel.Content        = playerItem.Level;
                PlayerItem.UsingLegendary.Visibility = playerItem.UsingLegendary ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden;

                //PlayerItem.Dev.Visibility = playerItem.IsLegendaryDev ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden;
                var uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", playerItem.ProfileIcon + ".png"), UriKind.RelativeOrAbsolute);
                PlayerItem.ProfileImage.Source = new BitmapImage(uriSource);
                if (playerItem.Status != null)
                {
                }
                else if (playerItem.Status == null)
                {
                    Client.hidelegendaryaddition = true;
                }
                else
                {
                    PlayerItem.PlayerStatus.Text = "";
                }

                if (playerItem.GameStatus != "outOfGame")
                {
                    TimeSpan elapsed = new TimeSpan();
                    if (playerItem.Timestamp != 0)
                    {
                        elapsed = DateTime.Now.Subtract(Client.JavaTimeStampToDateTime(playerItem.Timestamp));
                    }
                    switch (playerItem.GameStatus)
                    {
                    case "inGame":
                        champions InGameChamp = champions.GetChampion(playerItem.Champion);
                        if (InGameChamp != null)
                        {
                            PlayerItem.InGameStatus.Text = "In Game" + Environment.NewLine +
                                                           "Playing as " + InGameChamp.displayName + Environment.NewLine +
                                                           "For " + string.Format("{0} Minutes and {1} Seconds", elapsed.Minutes, elapsed.Seconds);
                        }
                        else
                        {
                            PlayerItem.InGameStatus.Text = "In Game";
                        }
                        break;

                    case "hostingPracticeGame":
                        PlayerItem.InGameStatus.Text = "Creating Custom Game";
                        break;

                    case "inQueue":
                        PlayerItem.InGameStatus.Text = "In Queue" + Environment.NewLine +
                                                       "For " + string.Format("{0} Minutes and {1} Seconds", elapsed.Minutes, elapsed.Seconds);
                        break;

                    case "spectating":
                        PlayerItem.InGameStatus.Text = "Spectating";
                        break;

                    case "championSelect":
                        PlayerItem.InGameStatus.Text = "In Champion Select" + Environment.NewLine +
                                                       "For " + string.Format("{0} Minutes and {1} Seconds", elapsed.Minutes, elapsed.Seconds);
                        break;
                    }
                    PlayerItem.InGameStatus.Visibility = System.Windows.Visibility.Visible;
                }

                PlayerItem.Width = 250;
                PlayerItem.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                PlayerItem.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
            }

            Point  MouseLocation = e.GetPosition(Client.MainGrid);
            double YMargin       = MouseLocation.Y;

            if (YMargin + 195 > Client.MainGrid.ActualHeight)
            {
                YMargin = Client.MainGrid.ActualHeight - 195;
            }
            PlayerItem.Margin = new Thickness(0, YMargin, 250, 0);
        }