Пример #1
0
        private static void NameDisplayModeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            UserCtrlFriendItem fi = d as UserCtrlFriendItem;

            fi.NameDisplayMode = (NameDisplayMode)e.NewValue;
            fi.SetDisplayMode(fi, fi.NickName, fi.Remarks, fi.NameDisplayMode);
        }
Пример #2
0
        private static void OnIconUriChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            UserCtrlFriendItem friendItem = d as UserCtrlFriendItem;

            if (e.NewValue != e.OldValue)
            {
                SetIconImageSource(friendItem, e.NewValue.ToString());
            }
        }
Пример #3
0
 void SetDisplayMode(UserCtrlFriendItem fi, string nickName, string remarks, NameDisplayMode nameDisplayMode)
 {
     if (nameDisplayMode == NameDisplayMode.NickName || string.IsNullOrEmpty(remarks))
     {
         fi.CtrlNickName.Visibility = Visibility.Visible;
         if (fi.IsVip)
         {
             fi.CtrlNickName.Foreground = new SolidColorBrush(Colors.Red);
         }
         else
         {
             fi.CtrlNickName.Foreground = new SolidColorBrush(Colors.Black);
         }
         fi.CtrlRemarks.Visibility = Visibility.Collapsed;
     }
     else if (nameDisplayMode == NameDisplayMode.Remarks)
     {
         fi.CtrlNickName.Visibility = Visibility.Collapsed;
         fi.CtrlRemarks.Visibility  = Visibility.Visible;
         if (fi.IsVip)
         {
             fi.CtrlRemarks.Foreground = new SolidColorBrush(Colors.Red);
         }
         else
         {
             fi.CtrlRemarks.Foreground = new SolidColorBrush(Colors.Black);
         }
         fi.CtrlRemarks.SetBinding(TextBlock.TextProperty, new Binding("Remarks")
         {
             Source = fi
         });
     }
     else if (nameDisplayMode == (NameDisplayMode.NameAndNickName))
     {
         fi.CtrlNickName.Visibility = Visibility.Visible;
         if (fi.IsVip)
         {
             fi.CtrlNickName.Foreground = new SolidColorBrush(Colors.Red);
         }
         else
         {
             fi.CtrlNickName.Foreground = new SolidColorBrush(Colors.Black);
         }
         fi.CtrlRemarks.Visibility = Visibility.Visible;
         fi.CtrlRemarks.SetBinding(TextBlock.TextProperty, new Binding("Remarks")
         {
             Source = fi, StringFormat = "({0})"
         });
     }
 }
Пример #4
0
        private static void SetIconImageSource(UserCtrlFriendItem friendItem, string value)
        {
            BitmapImage image = new BitmapImage();

            image.BeginInit();

            image.UriSource = new System.Uri(value);

            image.DecodePixelWidth  = (int)friendItem.IconSize.Width;
            image.DecodePixelHeight = (int)friendItem.IconSize.Height;

            image.EndInit();

            image.Freeze();


            friendItem.IconPath = image;
        }