示例#1
0
 private static void SetImageSource(AvatarBox ab, ImageSource source)
 {
     if (ab.image != null)
     {
         ab.image.Source = source;
     }
 }
示例#2
0
 private static void SetInnerMargin(AvatarBox ab, double newValue)
 {
     if (ab.innerBG != null)
     {
         ab.innerBG.Margin = new Thickness(newValue);
     }
 }
示例#3
0
        private static void OnSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            AvatarBox ab = d as AvatarBox;

            if (e.NewValue != e.OldValue)
            {
                SetImageSource(ab, (ImageSource)e.NewValue);
            }
        }
示例#4
0
        private static void OnShapeTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            AvatarBox ab = d as AvatarBox;

            if (e.NewValue != e.OldValue)
            {
                SetClip(ab, (ShapeType)e.NewValue);
            }
        }
示例#5
0
        private static void OnInnerMarginChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            AvatarBox ab = d as AvatarBox;

            if (e.NewValue != e.OldValue)
            {
                SetInnerMargin(ab, (double)e.NewValue);
            }
        }
示例#6
0
        private static void SetClip(AvatarBox avatarBox, ShapeType newValue)
        {
            Point center = new Point();

            center.X       = avatarBox.ActualWidth > 0 ? avatarBox.ActualWidth / 2 : 0;
            center.Y       = avatarBox.ActualHeight > 0 ? avatarBox.ActualHeight / 2 : 0;
            avatarBox.Clip = new EllipseGeometry()
            {
                Center = center, RadiusX = center.X, RadiusY = center.Y
            };
            if (avatarBox.innerBG != null)
            {
                avatarBox.innerBG.CornerRadius = new CornerRadius(double.MaxValue);
            }
        }