Esempio n. 1
0
        private void OnPropertyChanged(DependencyObject d, DependencyProperty prop)
        {
            if (prop == IsSelectedProperty)
            {
                // Toggle Selection indicator
                if (IsSelected)
                {
                    SelectIndicator.Fade(1, 200).Start();
                }
                else
                {
                    SelectIndicator.Fade(0, 200).Start();
                }
            }
            if (prop == IsUnreadProperty)
            {
                // Update unread indicator visibilty
                if (IsUnread && !IsMuted)
                {
                    UnreadIndicator.Visibility = Visibility.Visible;
                }
                else
                {
                    UnreadIndicator.Visibility = Visibility.Collapsed;
                }
            }
            if (prop == IsMutedProperty)
            {
                // Update muted icon
                if (IsMuted && Storage.Settings.ServerMuteIcons)
                {
                    MutedIcon.Visibility = Visibility.Visible;
                    ShowMute.Begin();
                }
                else
                {
                    HideMute.Begin();
                }

                // Override unread
                if (IsMuted)
                {
                    UnreadIndicator.Visibility = Visibility.Collapsed;
                }
                else if (IsUnread)
                {
                    UnreadIndicator.Visibility = Visibility.Visible;
                }
            }
            if (prop == NotificationCountProperty)
            {
                // Update notification visiblity
                if (NotificationCount > 0)
                {
                    NotificationCounter.Text = NotificationCount.ToString();
                    ShowBadge.Begin();
                    UnreadIndicator.Background = (SolidColorBrush)App.Current.Resources["Blurple"];
                    UnreadIndicator.Opacity    = 1;
                }
                else
                {
                    HideBadge.Begin();
                    UnreadIndicator.Background = (SolidColorBrush)App.Current.Resources["InvertedBG"];
                    UnreadIndicator.Opacity    = 0.75;
                }
            }
            if (prop == GuildNameProperty)
            {
                // Update Tooltip
                ToolTipService.SetToolTip(this, GuildName);
            }
            if (prop == ImageUrlProperty)
            {
                // Update Icon
                if (ImageUrl != "empty" && ImageUrl != "")
                {
                    GuildImageBrush.ImageSource = new BitmapImage(new Uri(ImageUrl));
                    TextIcon.Text       = "";
                    TextIcon.Visibility = Visibility.Collapsed;
                }
                else if (ImageUrl == "empty")
                {
                    GuildImageBrush.ImageSource = null;
                    if (GuildName != "")
                    {
                        TextIcon.Text = String.Join("", Regex.Matches(GuildName, @"(?<=^|[ \-_|+=~])\w")
                                                    .Cast <Match>()
                                                    .Select(m => m.Value)
                                                    .ToArray());
                        TextIcon.Visibility = Visibility.Visible;
                    }
                }
            }
            if (prop == IdProperty)
            {
                // Update DM Guild status
                if (Id != null && Id == "@me")
                {
                    DMView.Visibility             = Visibility.Visible;
                    GuildImageBackdrop.Visibility = Visibility.Collapsed;
                }
                else
                {
                    DMView.Visibility             = Visibility.Collapsed;
                    GuildImageBackdrop.Visibility = Visibility.Visible;
                }
            }
            if (prop == IsValidProperty)
            {
                // Update Invalid Guild Overlay
                InvalidOverlay.Visibility = IsValid ? Visibility.Collapsed : Visibility.Visible;
            }
        }
Esempio n. 2
0
        private void OnPropertyChanged(DependencyObject d, DependencyProperty prop)
        {
            if (prop == DisplayedUserProperty)
            {
                member = LocalState.Guilds[App.CurrentGuildId].members[DisplayedUser.UserId];

                username.Text = member.User.Username;

                AvatarBrush.ImageSource = new BitmapImage(Common.AvatarUri(member.User.Avatar, member.User.Id));

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


                //if (DisplayedFriend.UserStatus != null)
                //    status.Fill = (SolidColorBrush)App.Current.Resources[DisplayedFriend.UserStatus];
                //if (!Session.Online)
                //{
                //    status.Visibility = Visibility.Collapsed;
                //}

                if (DisplayedUser.SelfDeaf || DisplayedUser.ServerDeaf)
                {
                    if (DisplayedUser.ServerDeaf)
                    {
                        ServerDeaf.Begin();
                    }
                    else
                    {
                        LocalDeaf.Begin();
                    }
                    ShowDeaf.Begin();
                }
                else
                {
                    HideDeaf.Begin();
                }

                if (DisplayedUser.SelfMute || DisplayedUser.ServerMute)
                {
                    if (DisplayedUser.ServerMute)
                    {
                        ServerMute.Begin();
                    }
                    else
                    {
                        LocalMute.Begin();
                    }
                    ShowMute.Begin();
                }
                else
                {
                    HideMute.Begin();
                }

                //discriminator.Text = "#" + DisplayedFriend.User.Discriminator;
            }
        }