Ejemplo n.º 1
0
        public static string ToImageString(this HtmlValueConverter converter, Brush brush, Rect targetRect, IRenderElementFactory factory)
        {
            if (brush is LinearGradientBrush)
            {
                return(converter.ToImageString((LinearGradientBrush)brush, targetRect));
            }

            if (brush is RadialGradientBrush)
            {
                return(converter.ToImageString((RadialGradientBrush)brush));
            }

            if (brush is ImageBrush)
            {
                return(converter.ToImageString((ImageBrush)brush, factory));
            }

            throw new Granular.Exception("Unexpected brush type \"{0}\"", brush.GetType());
        }
Ejemplo n.º 2
0
        public static void SetHtmlBorderBrush(this HtmlElement element, Brush borderBrush, Size targetSize, IRenderElementFactory factory, HtmlValueConverter converter)
        {
            element.ClearHtmlStyleProperty("border-color");
            element.ClearHtmlStyleProperty("border-image-source");

            if (borderBrush is SolidColorBrush)
            {
                element.SetHtmlStyleProperty("border-color", converter.ToColorString((SolidColorBrush)borderBrush));
            }
            else if (borderBrush != null)
            {
                element.SetHtmlStyleProperty("border-image-source", converter.ToImageString(borderBrush, new Rect(targetSize), factory));
            }
        }
Ejemplo n.º 3
0
        public static void SetHtmlBackground(this HtmlElement element, Brush background, Rect targetRect, IRenderElementFactory factory, HtmlValueConverter converter)
        {
            element.ClearHtmlStyleProperty("background-color");
            element.ClearHtmlStyleProperty("background-image");

            if (background is SolidColorBrush)
            {
                element.SetHtmlStyleProperty("background-color", converter.ToColorString((SolidColorBrush)background));
            }
            else if (background != null)
            {
                element.SetHtmlStyleProperty("background-image", converter.ToImageString(background, targetRect, factory));
            }
        }