private void App_TypingHandler(object sender, App.TypingArgs e)
 {
     if (DisplayedMember != null)
     {
         if (e.UserId == DisplayedMember.Raw.User.Id)
         {
             DisplayedMember.IsTyping = e.Typing && e.ChnId == App.CurrentChannelId;
             if (DisplayedMember.IsTyping)
             {
                 ShowTyping.Begin();
             }
             else
             {
                 HideTyping.Begin();
             }
         }
     }
     else
     {
         App.TypingHandler -= App_TypingHandler;
     }
 }
        private void OnPropertyChanged(DependencyObject d, DependencyProperty prop)
        {
            if (DisplayedMember == null)
            {
                return;
            }
            if (DisplayedMember.IsTyping)
            {
                ShowTyping.Begin();
            }
            else
            {
                HideTyping.Begin();
            }

            if (DisplayedMember.Raw.Roles.Count() > 0)
            {
                username.Foreground = Common.IntToColor(LocalState.Guilds[App.CurrentGuildId].roles[DisplayedMember.Raw.Roles.First()].Color);
            }
            else
            {
                username.Foreground = (SolidColorBrush)App.Current.Resources["Foreground"];
            }

            if (DisplayedMember.Raw.Nick != null)
            {
                username.Text = DisplayedMember.Raw.Nick;
            }
            else if (DisplayedMember.Raw.User.Username != null)
            {
                username.Text = DisplayedMember.Raw.User.Username;
            }
            else
            {
                username.Text = "";
            }

            Avatar.ImageSource = new BitmapImage(Common.AvatarUri(DisplayedMember.Raw.User.Avatar, DisplayedMember.Raw.User.Id));

            if (DisplayedMember.Raw.User.Avatar != null)
            {
                AvatarBG.Fill = Common.GetSolidColorBrush("#00000000");
            }
            else
            {
                AvatarBG.Fill = Common.DiscriminatorColor(DisplayedMember.Raw.User.Discriminator);
            }

            if (DisplayedMember.status.Status != null && DisplayedMember.status.Status != "invisible")
            {
                rectangle.Fill = (SolidColorBrush)App.Current.Resources[DisplayedMember.status.Status];
            }
            else if (DisplayedMember.status.Status == "invisible")
            {
                rectangle.Fill = (SolidColorBrush)App.Current.Resources["offline"];
            }
            if (DisplayedMember.status.Game != null)
            {
                playing.Visibility = Visibility.Visible;
                game.Visibility    = Visibility.Visible;
                game.Text          = DisplayedMember.status.Game.Value.Name;

                if (DisplayedMember.status.Game.Value.State != null || DisplayedMember.status.Game.Value.Details != null || DisplayedMember.status.Game.Value.SessionId != null)
                {
                    game.Opacity    = 1;
                    rich.Visibility = Visibility.Visible;
                    switch (DisplayedMember.status.Game.Value.Type)
                    {
                    case 0:
                        playing.Text = "Playing"; break;

                    case 1:
                        playing.Text = "Streaming"; break;

                    case 2:
                        playing.Text = "Listening to"; break;
                    }
                }
                else
                {
                    game.Opacity    = 0.6;
                    rich.Visibility = Visibility.Collapsed;
                }
            }
            else
            {
                playing.Visibility = Visibility.Collapsed;
                rich.Visibility    = Visibility.Collapsed;
                game.Visibility    = Visibility.Collapsed;
            }
            if (DisplayedMember.Raw.User.Bot)
            {
                BotIndicator.Visibility = Visibility.Visible;
            }
            else
            {
                BotIndicator.Visibility = Visibility.Collapsed;
            }
        }