protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
 {
     if (_image != null)
     {
         ImageDecoration profileImage = Visual as ImageDecoration;
         drawingContext.DrawRoundedRectangle(_imageBrush, _borderPen, _imageRect, profileImage.CornerRadius, profileImage.CornerRadius);
     }
 }
 protected override void OnRender(DrawingContext drawingContext, double scaleX, double scaleY)
 {
     if (_image != null)
     {
         ImageDecoration profileImage = Visual as ImageDecoration;
         Rect            scaledRect   = new Rect(_imageRect.X, _imageRect.Y, _imageRect.Width * scaleX, _imageRect.Height * scaleY);
         drawingContext.DrawRoundedRectangle(_imageBrush, _borderPen, scaledRect, profileImage.CornerRadius, profileImage.CornerRadius);
     }
 }
        protected override void OnRefresh()
        {
            ImageDecoration profileImage = Visual as ImageDecoration;

            if (profileImage != null)
            {
                _image            = ConfigManager.ImageManager.LoadImage(profileImage.Image);
                _imageRect.Width  = profileImage.Width;
                _imageRect.Height = profileImage.Height;

                if (profileImage.BorderThickness > 0d)
                {
                    _borderPen = new Pen(new SolidColorBrush(profileImage.BorderColor), profileImage.BorderThickness);
                }
                else
                {
                    _borderPen = null;
                }

                if (_image == null)
                {
                    _image                    = ConfigManager.ImageManager.LoadImage("{Helios}/Controls/missing_image.png");
                    _imageBrush               = new ImageBrush(_image);
                    _imageBrush.Stretch       = Stretch.Fill;
                    _imageBrush.TileMode      = TileMode.None;
                    _imageBrush.Viewport      = new Rect(0d, 0d, 1d, 1d);
                    _imageBrush.ViewportUnits = BrushMappingMode.RelativeToBoundingBox;
                }
                else
                {
                    _imageBrush = new ImageBrush(_image);
                    switch (profileImage.Alignment)
                    {
                    case ImageAlignment.Centered:
                        _imageBrush.Stretch       = Stretch.None;
                        _imageBrush.TileMode      = TileMode.None;
                        _imageBrush.Viewport      = new Rect(0d, 0d, 1d, 1d);
                        _imageBrush.ViewportUnits = BrushMappingMode.RelativeToBoundingBox;
                        break;

                    case ImageAlignment.Stretched:
                        _imageBrush.Stretch       = Stretch.Fill;
                        _imageBrush.TileMode      = TileMode.None;
                        _imageBrush.Viewport      = new Rect(0d, 0d, 1d, 1d);
                        _imageBrush.ViewportUnits = BrushMappingMode.RelativeToBoundingBox;
                        break;

                    case ImageAlignment.Tiled:
                        _imageBrush.Stretch       = Stretch.None;
                        _imageBrush.TileMode      = TileMode.Tile;
                        _imageBrush.Viewport      = new Rect(0d, 0d, _image.Width, _image.Height);
                        _imageBrush.ViewportUnits = BrushMappingMode.Absolute;
                        break;
                    }
                }
            }
            else
            {
                _image = null;
            }
        }