Exemplo n.º 1
0
        public HtmlImageRenderElement(IRenderQueue renderQueue, IHtmlValueConverter converter)
            : base(renderQueue)
        {
            this.converter = converter;

            bounds = Rect.Zero;

            Style.SetBounds(Bounds, converter);
        }
        public HtmlImageRenderElement(IRenderQueue renderQueue, IHtmlValueConverter converter) :
            base(renderQueue)
        {
            this.converter = converter;

            bounds = Rect.Zero;

            Style.SetBounds(Bounds, converter);
        }
Exemplo n.º 3
0
        public HtmlTextBoxRenderElement(IRenderQueue renderQueue, IHtmlValueConverter converter)
            : base("div", renderQueue)
        {
            this.renderQueue = renderQueue;
            this.converter = converter;

            this.bounds = System.Windows.Rect.Empty;
            this.fontFamily = FontFamily.Default;

            Element styleElement = Document.CreateElement("style");
            styleElement.TextContent = "::-ms-clear { width: 0px; height: 0px; }";

            HtmlElement.AppendChild(styleElement);

            SetContentElement();
        }
        public HtmlTextBoxRenderElement(IRenderQueue renderQueue, IHtmlValueConverter converter) :
            base("div", renderQueue)
        {
            this.renderQueue = renderQueue;
            this.converter   = converter;

            this.bounds     = System.Windows.Rect.Empty;
            this.fontFamily = FontFamily.Default;

            Bridge.Html5.HTMLElement styleElement = Bridge.Html5.Document.CreateElement("style");
            styleElement.TextContent = "::-ms-clear { width: 0px; height: 0px; }";

            HtmlElement.AppendChild(styleElement);

            SetContentElement();
        }
Exemplo n.º 5
0
        public HtmlBorderRenderElement(IRenderQueue renderQueue, IHtmlValueConverter converter) :
            base(renderQueue)
        {
            this.converter = converter;

            bounds          = Rect.Zero;
            borderThickness = Thickness.Zero;
            cornerRadius    = CornerRadius.Zero;

            Style.SetValue("background-clip", "content-box");

            SetBackground();
            SetBorderBrush();
            SetBounds();
            SetCornerRadius();
            SetIsHitTestVisible();
        }
Exemplo n.º 6
0
        public HtmlBorderRenderElement(IRenderQueue renderQueue, IHtmlValueConverter converter)
            : base(renderQueue)
        {
            this.converter = converter;

            bounds = Rect.Zero;
            borderThickness = Thickness.Zero;
            cornerRadius = CornerRadius.Zero;

            Style.SetValue("background-clip", "content-box");
            Style.SetBackground(Background, converter);
            Style.SetBorderThickness(BorderThickness, converter);
            Style.SetBounds(new Rect(Bounds.Location, (Bounds.Size - BorderThickness.Size).Max(Size.Zero)), converter);
            Style.SetBorderBrush(BorderBrush, converter);
            Style.SetCornerRadius(cornerRadius, converter);
            Style.SetIsHitTestVisible(IsHitTestVisible && Background != null);
        }
        public HtmlBorderRenderElement(IRenderQueue renderQueue, IHtmlValueConverter converter) :
            base(renderQueue)
        {
            this.converter = converter;

            bounds          = Rect.Zero;
            borderThickness = Thickness.Zero;
            cornerRadius    = CornerRadius.Zero;

            Style.SetValue("background-clip", "content-box");
            Style.SetBackground(Background, converter);
            Style.SetBorderThickness(BorderThickness, converter);
            Style.SetBounds(new Rect(Bounds.Location, (Bounds.Size - BorderThickness.Size).Max(Size.Zero)), converter);
            Style.SetBorderBrush(BorderBrush, converter);
            Style.SetCornerRadius(cornerRadius, converter);
            Style.SetIsHitTestVisible(IsHitTestVisible && Background != null);
        }
Exemplo n.º 8
0
        public static string ToImageString(this IHtmlValueConverter converter, Brush brush)
        {
            if (brush is LinearGradientBrush)
            {
                return(converter.ToImageString((LinearGradientBrush)brush));
            }

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

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

            throw new Granular.Exception("Unexpected brush type \"{0}\"", brush.GetType());
        }
Exemplo n.º 9
0
        public HtmlVisualRenderElement(object owner, IRenderQueue renderQueue, IHtmlValueConverter converter) :
            base(GetElementTagName(owner), GetElementId(owner), renderQueue)
        {
            this.converter = converter;

            this.children        = new List <object>();
            this.childrenActions = new List <Action>();

            bounds    = Rect.Zero;
            isVisible = true;
            opacity   = 1;
            transform = Matrix.Identity;

            Style.SetBounds(Bounds, converter);
            Style.SetClipToBounds(ClipToBounds);
            Style.SetIsHitTestVisible(IsHitTestVisible && Background != null);
            Style.SetIsVisible(IsVisible);
            Style.SetOpacity(Opacity, converter);
            Style.SetTransform(Transform, converter);
        }
Exemplo n.º 10
0
        public static void SetSize(this HtmlStyleDictionary style, Size size, IHtmlValueConverter converter)
        {
            if (size.Width.IsNaN())
            {
                style.ClearValue("width");
            }
            else
            {
                style.SetValue("width", converter.ToPixelString(size.Width));
            }

            if (size.Height.IsNaN())
            {
                style.ClearValue("height");
            }
            else
            {
                style.SetValue("height", converter.ToPixelString(size.Height));
            }
        }
        public void HtmlValueConverterLinearGradientTest()
        {
            IHtmlValueConverter converter = HtmlValueConverter.Default;

            LinearGradientBrush brush = new LinearGradientBrush(new Point(0.1, 0.8), new Point(0.8, 0.1), Colors.Red, Colors.Blue);

            Assert.AreEqual("linear-gradient(45deg, #ff0000 15%, #0000ff 85%)", converter.ToLinearGradientString(brush, new Rect(100, 100)));
            Assert.AreEqual("linear-gradient(26.57deg, #ff0000 18%, #0000ff 88%)", converter.ToLinearGradientString(brush, new Rect(100, 200)));
            Assert.AreEqual("linear-gradient(45deg, #ff0000 15%, #0000ff 85%)", converter.ToLinearGradientString(brush, new Rect(10, 10, 80, 80)));
            Assert.AreEqual("linear-gradient(23.96deg, #ff0000 18.35%, #0000ff 88.35%)", converter.ToLinearGradientString(brush, new Rect(10, 10, 80, 180)));

            LinearGradientBrush absoluteBrush = new LinearGradientBrush(new Point(10, 80), new Point(80, 10), Colors.Red, Colors.Blue)
            {
                MappingMode = BrushMappingMode.Absolute
            };

            Assert.AreEqual("linear-gradient(45deg, #ff0000 15%, #0000ff 85%)", converter.ToLinearGradientString(absoluteBrush, new Rect(100, 100)));
            Assert.AreEqual("linear-gradient(45deg, #ff0000 43.33%, #0000ff 90%)", converter.ToLinearGradientString(absoluteBrush, new Rect(100, 200)));
            Assert.AreEqual("linear-gradient(45deg, #ff0000 6.25%, #0000ff 93.75%)", converter.ToLinearGradientString(absoluteBrush, new Rect(10, 10, 80, 80)));
            Assert.AreEqual("linear-gradient(45deg, #ff0000 42.31%, #0000ff 96.15%)", converter.ToLinearGradientString(absoluteBrush, new Rect(10, 10, 80, 180)));
        }
Exemplo n.º 12
0
        public HtmlVisualRenderElement(object owner, IRenderQueue renderQueue, IHtmlValueConverter converter)
            : base(GetElementTagName(owner), GetElementId(owner), renderQueue)
        {
            this.converter = converter;

            this.children = new List<object>();
            this.childrenActions = new List<Action>();

            bounds = Rect.Zero;
            isVisible = true;
            opacity = 1;
            transform = Transform.Identity;

            Style.SetBackground(Background, converter);
            Style.SetBounds(Bounds, converter);
            Style.SetClipToBounds(ClipToBounds);
            Style.SetIsHitTestVisible(IsHitTestVisible && Background != null);
            Style.SetIsVisible(IsVisible);
            Style.SetOpacity(Opacity, converter);
            Style.SetTransform(Transform, converter);
        }
Exemplo n.º 13
0
        public HtmlTextBlockRenderElement(IRenderQueue renderQueue, IHtmlValueConverter converter)
            : base(renderQueue)
        {
            this.converter = converter;

            bounds = Rect.Zero;
            fontFamily = FontFamily.Default;
            fontSize = Double.NaN;

            Style.SetBounds(Bounds, converter);
            Style.SetForeground(Foreground, converter);
            Style.SetFontFamily(FontFamily, converter);
            Style.SetFontSize(FontSize, converter);
            Style.SetFontStyle(FontStyle, converter);
            Style.SetFontWeight(FontWeight, converter);
            Style.SetFontStretch(FontStretch, converter);
            Style.SetIsHitTestVisible(false);
            Style.SetTextAlignment(TextAlignment, converter);
            Style.SetTextTrimming(TextTrimming);
            Style.SetTextWrapping(TextWrapping, converter);
        }
Exemplo n.º 14
0
        public HtmlTextBlockRenderElement(IRenderQueue renderQueue, IHtmlValueConverter converter) :
            base(renderQueue)
        {
            this.converter = converter;

            bounds     = Rect.Zero;
            fontFamily = FontFamily.Default;
            fontSize   = Double.NaN;

            Style.SetBounds(Bounds, converter);
            Style.SetForeground(Foreground, converter);
            Style.SetFontFamily(FontFamily, converter);
            Style.SetFontSize(FontSize, converter);
            Style.SetFontStyle(FontStyle, converter);
            Style.SetFontWeight(FontWeight, converter);
            Style.SetFontStretch(FontStretch, converter);
            Style.SetIsHitTestVisible(false);
            Style.SetTextAlignment(TextAlignment, converter);
            Style.SetTextTrimming(TextTrimming);
            Style.SetTextWrapping(TextWrapping, converter);
        }
Exemplo n.º 15
0
        public PresentationSource(UIElement rootElement, IHtmlValueConverter converter)
        {
            this.RootElement = rootElement;
            this.converter   = converter;

            RootElement.IsRootElement = true;

            MouseDevice    = new MouseDevice(this);
            KeyboardDevice = new KeyboardDevice(this);

            window = Bridge.Html5.Window.Instance;

            MouseDevice.CursorChanged += (sender, e) => Bridge.Html5.Window.Document.Body.Style.SetProperty("cursor", converter.ToCursorString(MouseDevice.Cursor));
            Bridge.Html5.Window.Document.Body.Style.SetProperty("cursor", converter.ToCursorString(MouseDevice.Cursor));

            Bridge.Html5.Window.OnKeyDown     = OnKeyDown;
            Bridge.Html5.Window.OnKeyUp       = OnKeyUp;
            Bridge.Html5.Window.OnKeyPress    = PreventKeyboardHandled;
            Bridge.Html5.Window.OnMouseMove   = OnMouseMove;
            Bridge.Html5.Window.OnMouseDown   = OnMouseDown;
            Bridge.Html5.Window.OnMouseUp     = OnMouseUp;
            Bridge.Html5.Window.OnScroll      = OnMouseWheel;
            Bridge.Html5.Window.OnFocus       = e => MouseDevice.Activate();
            Bridge.Html5.Window.OnBlur        = e => MouseDevice.Deactivate();
            Bridge.Html5.Window.OnResize      = e => SetRootElementSize();
            Bridge.Html5.Window.OnClick       = PreventMouseHandled;
            Bridge.Html5.Window.OnContextMenu = PreventMouseHandled;
            Bridge.Html5.Window.AddEventListener("ondblclick", PreventMouseHandled);
            Bridge.Html5.Window.AddEventListener("wheel", OnMouseWheel);

            SetRootElementSize();
            ((FrameworkElement)RootElement).Arrange(new Rect(window.InnerWidth, window.InnerHeight));

            Bridge.Html5.Window.Document.Body.Style.Overflow = Overflow.Hidden;
            Bridge.Html5.Window.Document.Body.AppendChild(((HtmlRenderElement)RootElement.GetRenderElement(HtmlRenderElementFactory.Default)).HtmlElement);

            MouseDevice.Activate();
            KeyboardDevice.Activate();
        }
        public void HtmlValueConverterBasicTest()
        {
            IHtmlValueConverter converter = HtmlValueConverter.Default;

            Assert.AreEqual("1.23px", converter.ToPixelString(1.234));
            Assert.AreEqual("123.46%", converter.ToPercentString(1.23456));
            Assert.AreEqual("1.23deg", converter.ToDegreesString(1.234));
            Assert.AreEqual("1.23px 5.68px", converter.ToPixelString(new Point(1.234, 5.678)));
            Assert.AreEqual("123.46% 567.89%", converter.ToPercentString(new Point(1.23456, 5.6789)));
            Assert.AreEqual("rgba(12, 34, 56, 0.25)", converter.ToColorString(Color.FromArgb(64, 12, 34, 56)));
            Assert.AreEqual("#0c2238", converter.ToColorString(Color.FromRgb(12, 34, 56)));
            Assert.AreEqual("1.23px", converter.ToPixelString(new Thickness(1.234)));
            Assert.AreEqual("2.35px 3.46px 4.57px 1.23px", converter.ToPixelString(new Thickness(1.234, 2.345, 3.456, 4.567)));
            Assert.AreEqual("2.35 3.46 4.57 1.23", converter.ToImplicitValueString(new Thickness(1.234, 2.345, 3.456, 4.567)));
            Assert.AreEqual("url(image-source)", converter.ToUrlString("image-source"));
            Assert.AreEqual("linear-gradient(135deg, #ff0000 0%, #0000ff 100%)", converter.ToLinearGradientString(new LinearGradientBrush(45, Colors.Red, Colors.Blue), new Rect(100, 100)));
            Assert.AreEqual("repeating-linear-gradient(135deg, #ff0000 0%, #0000ff 100%)", converter.ToLinearGradientString(new LinearGradientBrush(45, Colors.Red, Colors.Blue)
            {
                SpreadMethod = GradientSpreadMethod.Repeat
            }, new Rect(100, 100)));
            Assert.AreEqual("linear-gradient(135deg, #ff0000 0%, #0000ff 50%, #0000ff 50%, #ff0000 100%)", converter.ToLinearGradientString(new LinearGradientBrush(45, Colors.Red, Colors.Blue)
            {
                SpreadMethod = GradientSpreadMethod.Reflect
            }, new Rect(100, 100)));
            Assert.AreEqual("radial-gradient(ellipse 50% 50% at 50% 50%, #ff0000 0%, #0000ff 100%)", converter.ToRadialGradientString(new RadialGradientBrush(Colors.Red, Colors.Blue)));
            Assert.AreEqual("repeating-radial-gradient(ellipse 50% 50% at 50% 50%, #ff0000 0%, #0000ff 100%)", converter.ToRadialGradientString(new RadialGradientBrush(Colors.Red, Colors.Blue)
            {
                SpreadMethod = GradientSpreadMethod.Repeat
            }));
            Assert.AreEqual("#ff0000 0%, #0000ff 100%", converter.ToColorStopsString(new GradientStop[] { new GradientStop(Colors.Red, 0), new GradientStop(Colors.Blue, 1) }));
            Assert.AreEqual("#ff0000", converter.ToColorString(new SolidColorBrush(Colors.Red)));
            Assert.AreEqual("linear-gradient(135deg, #ff0000 0%, #0000ff 100%)", converter.ToImageString(new LinearGradientBrush(45, Colors.Red, Colors.Blue), new Rect(100, 100)));
            Assert.AreEqual("radial-gradient(ellipse 50% 50% at 50% 50%, #ff0000 0%, #0000ff 100%)", converter.ToImageString(new RadialGradientBrush(Colors.Red, Colors.Blue)));
            Assert.AreEqual("url(image-source)", converter.ToImageString(new ImageBrush()
            {
                ImageSource = "image-source"
            }));
        }
Exemplo n.º 17
0
        public PresentationSource(UIElement rootElement, IHtmlValueConverter converter)
        {
            this.RootElement = rootElement;
            this.converter = converter;

            RootElement.IsRootElement = true;

            MouseDevice = new MouseDevice(this);
            KeyboardDevice = new KeyboardDevice(this);

            window = System.Html.Window.Instance;

            MouseDevice.CursorChanged += (sender, e) => System.Html.Window.Document.Body.Style.Cursor = converter.ToCursorString(MouseDevice.Cursor);
            System.Html.Window.Document.Body.Style.Cursor = converter.ToCursorString(MouseDevice.Cursor);

            System.Html.Window.OnKeydown = OnKeyDown;
            System.Html.Window.OnKeyup = OnKeyUp;
            System.Html.Window.OnKeypress = PreventKeyboardHandled;
            System.Html.Window.OnMousemove = OnMouseMove;
            System.Html.Window.OnMousedown = OnMouseDown;
            System.Html.Window.OnMouseup = OnMouseUp;
            System.Html.Window.OnScroll = OnMouseWheel;
            System.Html.Window.OnFocus = e => MouseDevice.Activate();
            System.Html.Window.OnBlur = e => MouseDevice.Deactivate();
            System.Html.Window.OnResize = e => SetRootElementSize();
            System.Html.Window.OnClick = PreventMouseHandled;
            System.Html.Window.OnDblclick = PreventMouseHandled;
            System.Html.Window.OnContextmenu = PreventMouseHandled;
            System.Html.Window.AddEventListener("wheel", OnMouseWheel);

            SetRootElementSize();
            System.Html.Window.Document.Body.Style.Overflow = "hidden";
            System.Html.Window.Document.Body.AppendChild(((HtmlRenderElement)RootElement.GetRenderElement(HtmlRenderElementFactory.Default)).HtmlElement);

            MouseDevice.Activate();
            KeyboardDevice.Activate();
        }
Exemplo n.º 18
0
        public PresentationSource(UIElement rootElement, IHtmlValueConverter converter)
        {
            this.RootElement = rootElement;
            this.converter   = converter;

            RootElement.IsRootElement = true;

            MouseDevice    = new MouseDevice(this);
            KeyboardDevice = new KeyboardDevice(this);

            window = System.Html.Window.Instance;

            MouseDevice.CursorChanged += (sender, e) => System.Html.Window.Document.Body.Style.Cursor = converter.ToCursorString(MouseDevice.Cursor);
            System.Html.Window.Document.Body.Style.Cursor = converter.ToCursorString(MouseDevice.Cursor);

            System.Html.Window.OnKeydown     = OnKeyDown;
            System.Html.Window.OnKeyup       = OnKeyUp;
            System.Html.Window.OnKeypress    = PreventKeyboardHandled;
            System.Html.Window.OnMousemove   = OnMouseMove;
            System.Html.Window.OnMousedown   = OnMouseDown;
            System.Html.Window.OnMouseup     = OnMouseUp;
            System.Html.Window.OnScroll      = OnMouseWheel;
            System.Html.Window.OnFocus       = e => MouseDevice.Activate();
            System.Html.Window.OnBlur        = e => MouseDevice.Deactivate();
            System.Html.Window.OnResize      = e => SetRootElementSize();
            System.Html.Window.OnClick       = PreventMouseHandled;
            System.Html.Window.OnDblclick    = PreventMouseHandled;
            System.Html.Window.OnContextmenu = PreventMouseHandled;
            System.Html.Window.AddEventListener("wheel", OnMouseWheel);

            SetRootElementSize();
            System.Html.Window.Document.Body.Style.Overflow = "hidden";
            System.Html.Window.Document.Body.AppendChild(((HtmlRenderElement)RootElement.GetRenderElement(HtmlRenderElementFactory.Default)).HtmlElement);

            MouseDevice.Activate();
            KeyboardDevice.Activate();
        }
Exemplo n.º 19
0
 public static void SetFontSize(this HtmlStyleDictionary style, double fontSize, IHtmlValueConverter converter)
 {
     if (fontSize.IsNaN())
     {
         style.ClearValue("font-size");
     }
     else
     {
         style.SetValue("font-size", converter.ToPixelString(fontSize));
     }
 }
Exemplo n.º 20
0
 public static void SetForeground(this HtmlStyleDictionary style, Brush foreground, IHtmlValueConverter converter)
 {
     if (foreground == null)
     {
         style.ClearValue("color");
     }
     else if (foreground is SolidColorBrush)
     {
         style.SetValue("color", converter.ToColorString((SolidColorBrush)foreground));
     }
     else
     {
         throw new Granular.Exception("A \"{0}\" foreground brush is not supported", foreground.GetType());
     }
 }
Exemplo n.º 21
0
 public static void SetTransform(this HtmlStyleDictionary style, Matrix transform, IHtmlValueConverter converter)
 {
     if (transform == Matrix.Identity)
     {
         style.ClearValue("transform");
         style.ClearValue("transform-origin");
     }
     else
     {
         style.SetValue("transform", converter.ToTransformString(transform));
         style.SetValue("transform-origin", "0 0");
     }
 }
Exemplo n.º 22
0
 public static void SetBounds(this HtmlStyleDictionary style, Rect bounds, IHtmlValueConverter converter)
 {
     SetLocation(style, bounds.Location, converter);
     SetSize(style, bounds.Size, converter);
 }
Exemplo n.º 23
0
        public static void SetBackground(this HtmlStyleDictionary style, Brush background, IHtmlValueConverter converter)
        {
            style.ClearValue("background-color");
            style.ClearValue("background-image");

            if (background is SolidColorBrush)
            {
                style.SetValue("background-color", converter.ToColorString((SolidColorBrush)background));
            }
            else if (background != null)
            {
                style.SetValue("background-image", converter.ToImageString(background));
            }
        }
Exemplo n.º 24
0
 public static void SetVerticalScrollBarVisibility(this HtmlStyleDictionary style, ScrollBarVisibility scrollBarVisibility, IHtmlValueConverter converter)
 {
     style.SetValue("overflow-y", converter.ToOverflowString(scrollBarVisibility));
 }
Exemplo n.º 25
0
 public static void SetFontStyle(this HtmlStyleDictionary style, FontStyle fontStyle, IHtmlValueConverter converter)
 {
     if (fontStyle == FontStyle.Normal)
     {
         style.ClearValue("font-style");
     }
     else
     {
         style.SetValue("font-style", converter.ToFontStyleString(fontStyle));
     }
 }
Exemplo n.º 26
0
 public static void SetTextAlignment(this HtmlStyleDictionary style, TextAlignment textAlignment, IHtmlValueConverter converter)
 {
     style.SetValue("text-align", converter.ToTextAlignmentString(textAlignment));
 }
Exemplo n.º 27
0
 public static void SetTextWrapping(this HtmlStyleDictionary style, TextWrapping textWrapping, IHtmlValueConverter converter)
 {
     style.SetValue("white-space", converter.ToWhiteSpaceString(textWrapping));
 }
Exemplo n.º 28
0
 public static void SetOpacity(this HtmlStyleDictionary style, double opacity, IHtmlValueConverter converter)
 {
     if (opacity == 1.0)
     {
         style.ClearValue("opacity");
     }
     else
     {
         style.SetValue("opacity", converter.ToImplicitValueString(opacity));
     }
 }
Exemplo n.º 29
0
        public static void SetSize(this HtmlStyleDictionary style, Size size, IHtmlValueConverter converter)
        {
            if (size.Width.IsNaN())
            {
                style.ClearValue("width");
            }
            else
            {
                style.SetValue("width", converter.ToPixelString(size.Width));
            }

            if (size.Height.IsNaN())
            {
                style.ClearValue("height");
            }
            else
            {
                style.SetValue("height", converter.ToPixelString(size.Height));
            }
        }
Exemplo n.º 30
0
 public static void SetLocation(this HtmlStyleDictionary style, Point location, IHtmlValueConverter converter)
 {
     style.SetValue("position", "absolute");
     style.SetValue("left", converter.ToPixelString(location.X));
     style.SetValue("top", converter.ToPixelString(location.Y));
 }
Exemplo n.º 31
0
 public static void SetForeground(this HtmlStyleDictionary style, Brush foreground, IHtmlValueConverter converter)
 {
     if (foreground == null)
     {
         style.ClearValue("color");
     }
     else if (foreground is SolidColorBrush)
     {
         style.SetValue("color", converter.ToColorString((SolidColorBrush)foreground));
     }
     else
     {
         throw new Granular.Exception("A \"{0}\" foreground brush is not supported", foreground.GetType());
     }
 }
Exemplo n.º 32
0
 public static void SetFontWeight(this HtmlStyleDictionary style, FontWeight fontWeight, IHtmlValueConverter converter)
 {
     if (fontWeight == FontWeight.Normal)
     {
         style.ClearValue("font-weight");
     }
     else
     {
         style.SetValue("font-weight", converter.ToFontWeightString(fontWeight));
     }
 }
Exemplo n.º 33
0
 public static void SetFontWeight(this HtmlStyleDictionary style, FontWeight fontWeight, IHtmlValueConverter converter)
 {
     if (fontWeight == FontWeight.Normal)
     {
         style.ClearValue("font-weight");
     }
     else
     {
         style.SetValue("font-weight", converter.ToFontWeightString(fontWeight));
     }
 }
Exemplo n.º 34
0
 public static void SetFontSize(this HtmlStyleDictionary style, double fontSize, IHtmlValueConverter converter)
 {
     if (fontSize.IsNaN())
     {
         style.ClearValue("font-size");
     }
     else
     {
         style.SetValue("font-size", converter.ToPixelString(fontSize));
     }
 }
Exemplo n.º 35
0
 public static void SetTextAlignment(this HtmlStyleDictionary style, TextAlignment textAlignment, IHtmlValueConverter converter)
 {
     style.SetValue("text-align", converter.ToTextAlignmentString(textAlignment));
 }
Exemplo n.º 36
0
 public static void SetBorderThickness(this HtmlStyleDictionary style, Thickness borderThickness, IHtmlValueConverter converter)
 {
     if (borderThickness == Thickness.Zero)
     {
         style.ClearValue("border-style");
         style.ClearValue("border-width");
         style.ClearValue("border-image-slice");
     }
     else
     {
         style.SetValue("border-style", "solid");
         style.SetValue("border-width", converter.ToPixelString(borderThickness));
         style.SetValue("border-image-slice", converter.ToImplicitValueString(borderThickness));
     }
 }
Exemplo n.º 37
0
 public static void SetTransform(this HtmlStyleDictionary style, Transform transform, IHtmlValueConverter converter)
 {
     if (transform == Transform.Identity)
     {
         style.ClearValue("transform");
     }
     else
     {
         style.SetValue("transform", transform.Value.ToString());
     }
 }
Exemplo n.º 38
0
 public static void SetFontStretch(this HtmlStyleDictionary style, FontStretch fontStretch, IHtmlValueConverter converter)
 {
     if (fontStretch == FontStretch.Normal)
     {
         style.ClearValue("font-stretch");
     }
     else
     {
         style.SetValue("font-stretch", converter.ToFontStretchString(fontStretch));
     }
 }
Exemplo n.º 39
0
 public static void SetBackgroundBounds(this HtmlStyleDictionary style, Rect bounds, IHtmlValueConverter converter)
 {
     style.SetBackgroundLocation(bounds.Location, converter);
     style.SetBackgroundSize(bounds.Size, converter);
 }
Exemplo n.º 40
0
 public static void SetVerticalScrollBarVisibility(this HtmlStyleDictionary style, ScrollBarVisibility scrollBarVisibility, IHtmlValueConverter converter)
 {
     style.SetValue("overflow-y", converter.ToOverflowString(scrollBarVisibility));
 }
Exemplo n.º 41
0
        public static void SetBorderBrush(this HtmlStyleDictionary style, Brush borderBrush, Size targetSize, IHtmlValueConverter converter)
        {
            style.ClearValue("border-color");
            style.ClearValue("border-image-source");

            if (borderBrush is SolidColorBrush)
            {
                style.SetValue("border-color", converter.ToColorString((SolidColorBrush)borderBrush));
            }
            else if (borderBrush != null)
            {
                style.SetValue("border-image-source", converter.ToImageString(borderBrush, new Rect(targetSize)));
            }
        }
Exemplo n.º 42
0
        public static void SetCornerRadius(this HtmlStyleDictionary style, CornerRadius cornerRadius, IHtmlValueConverter converter)
        {
            style.ClearValue("border-radius");
            style.ClearValue("border-top-left-radius");
            style.ClearValue("border-top-right-radius");
            style.ClearValue("border-bottom-left-radius");
            style.ClearValue("border-bottom-right-radius");

            if (cornerRadius != CornerRadius.Zero)
            {
                if (cornerRadius.IsUniform)
                {
                    style.SetValue("border-radius", converter.ToPixelString(cornerRadius.TopLeft));
                }
                else
                {
                    style.SetValue("border-top-left-radius", converter.ToPixelString(cornerRadius.TopLeft));
                    style.SetValue("border-top-right-radius", converter.ToPixelString(cornerRadius.TopRight));
                    style.SetValue("border-bottom-left-radius", converter.ToPixelString(cornerRadius.BottomLeft));
                    style.SetValue("border-bottom-right-radius", converter.ToPixelString(cornerRadius.BottomRight));
                }
            }
        }
Exemplo n.º 43
0
 public static void SetLocation(this HtmlStyleDictionary style, Point location, IHtmlValueConverter converter)
 {
     style.SetValue("position", "absolute");
     style.SetValue("left", converter.ToPixelString(location.X));
     style.SetValue("top", converter.ToPixelString(location.Y));
 }
Exemplo n.º 44
0
 public static void SetBounds(this HtmlStyleDictionary style, Rect bounds, IHtmlValueConverter converter)
 {
     SetLocation(style, bounds.Location, converter);
     SetSize(style, bounds.Size, converter);
 }
Exemplo n.º 45
0
        public static void SetCornerRadius(this HtmlStyleDictionary style, CornerRadius cornerRadius, IHtmlValueConverter converter)
        {
            style.ClearValue("border-radius");
            style.ClearValue("border-top-left-radius");
            style.ClearValue("border-top-right-radius");
            style.ClearValue("border-bottom-left-radius");
            style.ClearValue("border-bottom-right-radius");

            if (cornerRadius != CornerRadius.Zero)
            {
                if (cornerRadius.IsUniform)
                {
                    style.SetValue("border-radius", converter.ToPixelString(cornerRadius.TopLeft));
                }
                else
                {
                    style.SetValue("border-top-left-radius", converter.ToPixelString(cornerRadius.TopLeft));
                    style.SetValue("border-top-right-radius", converter.ToPixelString(cornerRadius.TopRight));
                    style.SetValue("border-bottom-left-radius", converter.ToPixelString(cornerRadius.BottomLeft));
                    style.SetValue("border-bottom-right-radius", converter.ToPixelString(cornerRadius.BottomRight));
                }
            }
        }
Exemplo n.º 46
0
 public static void SetBorderThickness(this HtmlStyleDictionary style, Thickness borderThickness, IHtmlValueConverter converter)
 {
     if (borderThickness == Thickness.Zero)
     {
         style.ClearValue("border-style");
         style.ClearValue("border-width");
         style.ClearValue("border-image-slice");
     }
     else
     {
         style.SetValue("border-style", "solid");
         style.SetValue("border-width", converter.ToPixelString(borderThickness));
         style.SetValue("border-image-slice", converter.ToImplicitValueString(borderThickness));
     }
 }
Exemplo n.º 47
0
 public static void SetOpacity(this HtmlStyleDictionary style, double opacity, IHtmlValueConverter converter)
 {
     if (opacity == 1.0)
     {
         style.ClearValue("opacity");
     }
     else
     {
         style.SetValue("opacity", converter.ToImplicitValueString(opacity));
     }
 }
Exemplo n.º 48
0
        public static void SetBorderBrush(this HtmlStyleDictionary style, Brush borderBrush, IHtmlValueConverter converter)
        {
            style.ClearValue("border-color");
            style.ClearValue("border-image-source");

            if (borderBrush is SolidColorBrush)
            {
                style.SetValue("border-color", converter.ToColorString((SolidColorBrush)borderBrush));
            }
            else if (borderBrush != null)
            {
                style.SetValue("border-image-source", converter.ToImageString(borderBrush));
            }
        }
Exemplo n.º 49
0
 public static void SetFontFamily(this HtmlStyleDictionary style, FontFamily fontFamily, IHtmlValueConverter converter)
 {
     if (!fontFamily.FamilyNames.Any())
     {
         style.ClearValue("font-family");
     }
     else
     {
         style.SetValue("font-family", converter.ToFontFamilyNamesString(fontFamily));
     }
 }
Exemplo n.º 50
0
 public static void SetBackgroundSize(this HtmlStyleDictionary style, Size size, IHtmlValueConverter converter)
 {
     if (Size.IsNullOrEmpty(size))
     {
         style.ClearValue("background-size");
     }
     else
     {
         style.SetValue("background-size", converter.ToPixelString(size));
     }
 }
Exemplo n.º 51
0
 public static void SetFontStyle(this HtmlStyleDictionary style, FontStyle fontStyle, IHtmlValueConverter converter)
 {
     if (fontStyle == FontStyle.Normal)
     {
         style.ClearValue("font-style");
     }
     else
     {
         style.SetValue("font-style", converter.ToFontStyleString(fontStyle));
     }
 }
Exemplo n.º 52
0
 public static void SetBackgroundLocation(this HtmlStyleDictionary style, Point location, IHtmlValueConverter converter)
 {
     if (Point.IsNullOrEmpty(location))
     {
         style.ClearValue("background-position");
     }
     else
     {
         style.SetValue("background-position", converter.ToPixelString(location));
     }
 }
Exemplo n.º 53
0
 public static void SetFontStretch(this HtmlStyleDictionary style, FontStretch fontStretch, IHtmlValueConverter converter)
 {
     if (fontStretch == FontStretch.Normal)
     {
         style.ClearValue("font-stretch");
     }
     else
     {
         style.SetValue("font-stretch", converter.ToFontStretchString(fontStretch));
     }
 }
Exemplo n.º 54
0
 public static void SetBackgroundImage(this HtmlStyleDictionary style, ImageSource imageSource, IHtmlValueConverter converter)
 {
     if (imageSource == null)
     {
         style.ClearValue("background-image");
     }
     else
     {
         style.SetValue("background-image", converter.ToUrlString(((RenderImageSource)imageSource.RenderImageSource).Url));
     }
 }
Exemplo n.º 55
0
 public static void SetTextWrapping(this HtmlStyleDictionary style, TextWrapping textWrapping, IHtmlValueConverter converter)
 {
     style.SetValue("white-space", converter.ToWhiteSpaceString(textWrapping));
 }
Exemplo n.º 56
0
 public static void SetBackgroundBounds(this HtmlStyleDictionary style, Rect bounds, IHtmlValueConverter converter)
 {
     style.SetBackgroundLocation(bounds.Location, converter);
     style.SetBackgroundSize(bounds.Size, converter);
 }
Exemplo n.º 57
0
 public static void SetBackgroundImage(this HtmlStyleDictionary style, ImageSource imageSource, IHtmlValueConverter converter)
 {
     if (imageSource == null)
     {
         style.ClearValue("background-image");
     }
     else
     {
         style.SetValue("background-image", converter.ToUrlString(((RenderImageSource)imageSource.RenderImageSource).Url));
     }
 }
Exemplo n.º 58
0
 private RenderImageSourceFactory(IHtmlValueConverter converter)
 {
     this.converter = converter;
     objectUrlCache = new CacheDictionary<string, string>(ResolveObjectUrl);
 }
Exemplo n.º 59
0
 private TextMeasurementService(IHtmlValueConverter converter)
 {
     this.converter = converter;
 }
Exemplo n.º 60
0
 public static void SetFontFamily(this HtmlStyleDictionary style, FontFamily fontFamily, IHtmlValueConverter converter)
 {
     if (!fontFamily.FamilyNames.Any())
     {
         style.ClearValue("font-family");
     }
     else
     {
         style.SetValue("font-family", converter.ToFontFamilyNamesString(fontFamily));
     }
 }