Пример #1
0
        /// <summary>
        /// Handle mouse double click to select word under the mouse.
        /// </summary>
        /// <param name="parent">the control hosting the html to set cursor and invalidate</param>
        /// <param name="e">mouse event args</param>
        public void HandleMouseDoubleClick(Control parent, PointerEventArgs e)
        {
            ArgChecker.AssertArgNotNull(parent, "parent");
            ArgChecker.AssertArgNotNull(e, "e");

            _htmlContainerInt.HandleMouseDoubleClick(new ControlAdapter(parent), HtmlUtil.Convert(e.GetPosition(parent)));
        }
Пример #2
0
        public override void DrawString(string str, RFont font, RColor color, RPoint point, RSize size, bool rtl)
        {
            var text = GetText(str, font);

            text.Constraint = HtmlUtil.Convert(size);
            _g.DrawText(new SolidColorBrush(HtmlUtil.Convert(color)), HtmlUtil.Convert(point), text);
        }
Пример #3
0
        /// <summary>
        /// Render the html using the given device.
        /// </summary>
        /// <param name="g">the device to use to render</param>
        /// <param name="clip">the clip rectangle of the html container</param>
        public void PerformPaint(DrawingContext g, Rect clip)
        {
            ArgChecker.AssertArgNotNull(g, "g");

            using (var ig = new GraphicsAdapter(g, HtmlUtil.Convert(clip)))
            {
                _htmlContainerInt.PerformPaint(ig);
            }
        }
Пример #4
0
        /// <summary>
        /// Handle mouse up to handle selection and link click.
        /// </summary>
        /// <param name="parent">the control hosting the html to invalidate</param>
        /// <param name="e">the mouse event args</param>
        public void HandleLeftMouseUp(Control parent, PointerEventArgs e)
        {
            ArgChecker.AssertArgNotNull(parent, "parent");
            ArgChecker.AssertArgNotNull(e, "e");

            var mouseEvent = new RMouseEvent(true);

            _htmlContainerInt.HandleMouseUp(new ControlAdapter(parent), HtmlUtil.Convert(e.GetPosition(parent)), mouseEvent);
        }
Пример #5
0
        public override RBrush GetTextureBrush(RImage image, RRect dstRect, RPoint translateTransformLocation)
        {
            var brush = new ImageBrush(((ImageAdapter)image).Image);

            brush.Stretch         = Stretch.None;
            brush.TileMode        = TileMode.Tile;
            brush.DestinationRect = new RelativeRect(HtmlUtil.Convert(dstRect).Translate(HtmlUtil.Convert(translateTransformLocation) - new Point()), RelativeUnit.Absolute);

            return(new BrushAdapter(brush));
        }
Пример #6
0
        protected override RColor GetColorInt(string colorName)
        {
            Color c;

            if (!ColorNameDic.TryGetValue(colorName.ToLower(), out c))
            {
                return(RColor.Empty);
            }
            return(HtmlUtil.Convert(c));
        }
Пример #7
0
        /// <summary>
        /// Get all the links in the HTML with the element Rect and href data.
        /// </summary>
        /// <returns>collection of all the links in the HTML</returns>
        public List <LinkElementData <Rect> > GetLinks()
        {
            var linkElements = new List <LinkElementData <Rect> >();

            foreach (var link in HtmlContainerInt.GetLinks())
            {
                linkElements.Add(new LinkElementData <Rect>(link.Id, link.Href, HtmlUtil.Convert(link.Rectangle)));
            }
            return(linkElements);
        }
Пример #8
0
        public override void DrawPolygon(RBrush brush, RPoint[] points)
        {
            if (points != null && points.Length > 0)
            {
                var g = new StreamGeometry();
                using (var context = g.Open())
                {
                    context.BeginFigure(HtmlUtil.Convert(points[0]), true);
                    for (int i = 1; i < points.Length; i++)
                    {
                        context.LineTo(HtmlUtil.Convert(points[i]));
                    }
                    context.EndFigure(false);
                }

                _g.DrawGeometry(((BrushAdapter)brush).Brush, null, g);
            }
        }
Пример #9
0
        protected override RBrush CreateLinearGradientBrush(RRect rect, RColor color1, RColor color2, double angle)
        {
            var startColor = angle <= 180 ? HtmlUtil.Convert(color1) : HtmlUtil.Convert(color2);
            var endColor   = angle <= 180 ? HtmlUtil.Convert(color2) : HtmlUtil.Convert(color1);

            angle = angle <= 180 ? angle : angle - 180;
            double x = angle < 135 ? Math.Max((angle - 45) / 90, 0) : 1;
            double y = angle <= 45 ? Math.Max(0.5 - angle / 90, 0) : angle > 135 ? Math.Abs(1.5 - angle / 90) : 0;

            return(new BrushAdapter(new LinearGradientBrush
            {
                StartPoint = new RelativePoint(x, y, RelativeUnit.Relative),
                EndPoint = new RelativePoint(1 - x, 1 - y, RelativeUnit.Relative),
                GradientStops = new GradientStops
                {
                    new GradientStop(startColor, 0),
                    new GradientStop(endColor, 1)
                }
            }));
        }
Пример #10
0
        /// <summary>
        /// Get solid color brush for the given color.
        /// </summary>
        private static IBrush GetSolidColorBrush(RColor color)
        {
            IBrush solidBrush;

            if (color == RColor.White)
            {
                solidBrush = Brushes.White;
            }
            else if (color == RColor.Black)
            {
                solidBrush = Brushes.Black;
            }
            else if (color.A < 1)
            {
                solidBrush = Brushes.Transparent;
            }
            else
            {
                solidBrush = new SolidColorBrush(HtmlUtil.Convert(color));
            }
            return(solidBrush);
        }
Пример #11
0
 public override void DrawImage(RImage image, RRect destRect, RRect srcRect)
 {
     _g.DrawImage(((ImageAdapter)image).Image, 1, HtmlUtil.Convert(srcRect), HtmlUtil.Convert(destRect));
 }
Пример #12
0
        /// <summary>
        /// Handle mouse move to handle hover cursor and text selection.
        /// </summary>
        /// <param name="parent">the control hosting the html to set cursor and invalidate</param>
        /// <param name="mousePos">the mouse event args</param>
        public void HandleMouseMove(Control parent, Point mousePos)
        {
            ArgChecker.AssertArgNotNull(parent, "parent");

            _htmlContainerInt.HandleMouseMove(new ControlAdapter(parent), HtmlUtil.Convert(mousePos));
        }
Пример #13
0
 public override void DrawImage(RImage image, RRect destRect)
 {
     _g.DrawImage(((ImageAdapter)image).Image, 1, new Rect(0, 0, image.Width, image.Height), HtmlUtil.Convert(destRect));
 }
Пример #14
0
 public override void PushClip(RRect rect)
 {
     _clipStack.Push(_g.PushClip(HtmlUtil.Convert(rect)));
     //_clipStack.Push(rect);
     //_g.PushClip(new RectangleGeometry(Utils.Convert(rect)));
 }
Пример #15
0
        /// <summary>
        /// Get the Rect of html element as calculated by html layout.<br/>
        /// Element if found by id (id attribute on the html element).<br/>
        /// Note: to get the screen Rect you need to adjust by the hosting control.<br/>
        /// </summary>
        /// <param name="elementId">the id of the element to get its Rect</param>
        /// <returns>the Rect of the element or null if not found</returns>
        public Rect?GetElementRectangle(string elementId)
        {
            var r = _htmlContainerInt.GetElementRectangle(elementId);

            return(r.HasValue ? HtmlUtil.Convert(r.Value) : (Rect?)null);
        }
Пример #16
0
 /// <summary>
 /// Get css link href at the given x,y location.
 /// </summary>
 /// <param name="location">the location to find the link at</param>
 /// <returns>css link href if exists or null</returns>
 public string GetLinkAt(Point location)
 {
     return(_htmlContainerInt.GetLinkAt(HtmlUtil.Convert(location)));
 }
Пример #17
0
 /// <summary>
 /// Get attribute value of element at the given x,y location by given key.<br/>
 /// If more than one element exist with the attribute at the location the inner most is returned.
 /// </summary>
 /// <param name="location">the location to find the attribute at</param>
 /// <param name="attribute">the attribute key to get value by</param>
 /// <returns>found attribute value or null if not found</returns>
 public string GetAttributeAt(Point location, string attribute)
 {
     return(_htmlContainerInt.GetAttributeAt(HtmlUtil.Convert(location), attribute));
 }