Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="g"></param>
        /// <param name="tableBox"> </param>
        public static void PerformLayout(RGraphics g, CssBox tableBox)
        {
            ArgChecker.AssertArgNotNull(g, "g");
            ArgChecker.AssertArgNotNull(tableBox, "tableBox");

            try
            {
                var table = new CssLayoutEngineTable(tableBox);
                table.Layout(g);
            }
            catch (Exception ex)
            {
                tableBox.HtmlContainer.ReportError(HtmlRenderErrorType.Layout, "Failed table layout", ex);
            }
        }
Exemplo n.º 2
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="location">the location of the mouse</param>
        public void HandleMouseDoubleClick(RControl parent, RPoint location)
        {
            ArgChecker.AssertArgNotNull(parent, "parent");

            try {
                HandleBoxClicked(2, location);

                if (_selectionHandler != null && IsMouseInContainer(location))
                {
                    _selectionHandler.SelectWord(parent, OffsetByScroll(location));
                }
            } catch (Exception ex) {
                ReportError(HtmlRenderErrorType.KeyboardMouse, "Failed mouse double click handle", ex);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Renders the specified HTML source on the specified location and max size restriction.<br/>
        /// If <paramref name="maxSize"/>.Width is zero the html will use all the required width, otherwise it will perform line
        /// wrap as specified in the html<br/>
        /// If <paramref name="maxSize"/>.Height is zero the html will use all the required height, otherwise it will clip at the
        /// given max height not rendering the html below it.<br/>
        /// Returned is the actual widht and height of the rendered html.<br/>
        /// </summary>
        /// <param name="g">Device to render with</param>
        /// <param name="html">HTML source to render</param>
        /// <param name="location">the top-left most location to start render the html at</param>
        /// <param name="maxSize">the max size of the rendered html (if height above zero it will be clipped)</param>
        /// <param name="cssData">optiona: the style to use for html rendering (default - use W3 default style)</param>
        /// <param name="stylesheetLoad">optional: can be used to overwrite stylesheet resolution logic</param>
        /// <param name="imageLoad">optional: can be used to overwrite image resolution logic</param>
        /// <returns>the actual size of the rendered html</returns>
        public static SizeF Render(Graphics g, string html, PointF location, SizeF maxSize, CssData cssData, EventHandler <HtmlStylesheetLoadEventArgs> stylesheetLoad, EventHandler <HtmlImageLoadEventArgs> imageLoad)
        {
            ArgChecker.AssertArgNotNull(g, "g");

            SizeF actualSize = SizeF.Empty;

            if (!string.IsNullOrEmpty(html))
            {
                Region prevClip = null;
                if (maxSize.Height > 0)
                {
                    prevClip = g.Clip;
                    g.SetClip(new RectangleF(location, maxSize));
                }

                var container = new HtmlContainer();
                if (stylesheetLoad != null)
                {
                    container.StylesheetLoad += stylesheetLoad;
                }
                if (imageLoad != null)
                {
                    container.ImageLoad += imageLoad;
                }
                container.SetHtml(html, cssData);
                container.Location = location;
                container.MaxSize  = maxSize;
                container.PerformLayout(g);
                container.PerformPaint(g);
                if (stylesheetLoad != null)
                {
                    container.StylesheetLoad -= stylesheetLoad;
                }
                if (imageLoad != null)
                {
                    container.ImageLoad -= imageLoad;
                }

                if (prevClip != null)
                {
                    g.SetClip(prevClip, CombineMode.Replace);
                }

                actualSize = container.ActualSize;
            }

            return(actualSize);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates line boxes for the specified blockbox
        /// </summary>
        /// <param name="g"></param>
        /// <param name="blockBox"></param>
        public static void CreateLineBoxes(IGraphics g, CssBox blockBox)
        {
            ArgChecker.AssertArgNotNull(g, "g");
            ArgChecker.AssertArgNotNull(blockBox, "blockBox");

            blockBox.LineBoxes.Clear();

            float limitRight = blockBox.ActualRight - blockBox.ActualPaddingRight - blockBox.ActualBorderRightWidth;

            //Get the start x and y of the blockBox
            float startx = blockBox.Location.X + blockBox.ActualPaddingLeft - 0 + blockBox.ActualBorderLeftWidth;
            float starty = blockBox.Location.Y + blockBox.ActualPaddingTop - 0 + blockBox.ActualBorderTopWidth;
            float curx   = startx + blockBox.ActualTextIndent;
            float cury   = starty;

            //Reminds the maximum bottom reached
            float maxRight  = startx;
            float maxBottom = starty;

            //First line box
            CssLineBox line = new CssLineBox(blockBox);

            //Flow words and boxes
            FlowBox(g, blockBox, blockBox, limitRight, 0, startx, ref line, ref curx, ref cury, ref maxRight, ref maxBottom);

            // if width is not restricted we need to lower it to the actual width
            if (blockBox.ActualRight >= 90999)
            {
                blockBox.ActualRight = maxRight + blockBox.ActualPaddingRight + blockBox.ActualBorderRightWidth;
            }

            //Gets the rectangles for each line-box
            foreach (var linebox in blockBox.LineBoxes)
            {
                ApplyAlignment(g, linebox);
                ApplyRightToLeft(blockBox, linebox);
                BubbleRectangles(blockBox, linebox);
                linebox.AssignRectanglesToBoxes();
            }

            blockBox.ActualBottom = maxBottom + blockBox.ActualPaddingBottom + blockBox.ActualBorderBottomWidth;

            // handle limiting block height when overflow is hidden
            if (blockBox.Height != null && blockBox.Height != CssConstants.Auto && blockBox.Overflow == CssConstants.Hidden && blockBox.ActualBottom - blockBox.Location.Y > blockBox.ActualHeight)
            {
                blockBox.ActualBottom = blockBox.Location.Y + blockBox.ActualHeight;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Handle mouse leave to handle hover cursor.
        /// </summary>
        /// <param name="parent">the control hosting the html to set cursor and invalidate</param>
        public void HandleMouseLeave(RControl parent)
        {
            ArgChecker.AssertArgNotNull(parent, "parent");

            try
            {
                if (this._selectionHandler != null)
                {
                    this._selectionHandler.HandleMouseLeave(parent);
                }
            }
            catch (Exception ex)
            {
                this.ReportError(HtmlRenderErrorType.KeyboardMouse, "Failed mouse leave handle", ex);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Init.
        /// </summary>
        /// <param name="fullString">the full string that this sub-string is part of</param>
        /// <param name="startIdx">the start index of the sub-string</param>
        /// <param name="length">the length of the sub-string starting at <paramref name="startIdx"/></param>
        /// <exception cref="ArgumentNullException"><paramref name="fullString"/> is null</exception>
        public SubString(string fullString, int startIdx, int length)
        {
            ArgChecker.AssertArgNotNull(fullString, "fullString");
            if (startIdx < 0 || startIdx >= fullString.Length)
            {
                throw new ArgumentOutOfRangeException("startIdx", "Must within fullString boundries");
            }
            if (length < 0 || startIdx + length > fullString.Length)
            {
                throw new ArgumentOutOfRangeException("length", "Must within fullString boundries");
            }

            _fullString = fullString;
            _startIdx   = startIdx;
            _length     = length;
        }
Exemplo n.º 7
0
            public SubstringReader(string s, int index, int count)
            {
                ArgChecker.AssertArgNotNull(s, nameof(s));
                if (index < 0 || index > s.Length)
                {
                    throw new ArgumentOutOfRangeException(nameof(index));
                }
                if (count < 0 || index + count > s.Length)
                {
                    throw new ArgumentOutOfRangeException(nameof(count));
                }

                _s        = s;
                _index    = index;
                _maxIndex = index + count;
            }
        /// <summary>
        /// Render the html using the given printer device.
        /// </summary>
        /// <param name="g">the printer device to use to render</param>
        public void PerformPrint(Graphics g, int iPage)
        {
            RPoint rpoint = this._htmlContainerInt.ScrollOffset;

            rpoint.Y = this._htmlContainerInt._pagelist.Page(iPage).YOffset;
            Point pt = new Point(Convert.ToInt32(rpoint.X), Convert.ToInt32(rpoint.Y));

            //this._htmlContainerInt.ScrollOffset = rpoint;
            //this.ScrollOffset = pt;

            ArgChecker.AssertArgNotNull(g, "g");
            using (var ig = new GraphicsAdapter(g, _useGdiPlusTextRendering))
            {
                _htmlContainerInt.PerformPrint(ig, iPage);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Handle mouse down to handle selection.
        /// </summary>
        /// <param name="parent">the control hosting the html to invalidate</param>
        /// <param name="location">the location of the mouse</param>
        public void HandleMouseDown(RControl parent, RPoint location)
        {
            ArgChecker.AssertArgNotNull(parent, "parent");

            try
            {
                if (this._selectionHandler != null)
                {
                    this._selectionHandler.HandleMouseDown(parent, this.OffsetByScroll(location), this.IsMouseInContainer(location));
                }
            }
            catch (Exception ex)
            {
                this.ReportError(HtmlRenderErrorType.KeyboardMouse, "Failed mouse down handle", ex);
            }
        }
Exemplo n.º 10
0
        public int Read(StringBuilder buffer, int count)
        {
            ArgChecker.AssertArgNotNull(buffer, nameof(buffer));

            if (!EnsureBufferLength(count))
            {
                count = _cyclicBufferLen;
            }

            for (var i = 0; i < count; i++)
            {
                buffer.Append(_cyclicBuffer[_cyclicBufferPos]);
                _cyclicBufferPos = (_cyclicBufferPos + 1) % _cyclicBuffer.Length;
                _cyclicBufferLen--;
            }
            return(count);
        }
Exemplo n.º 11
0
            public override int Read(char[] buffer, int index, int count)
            {
                ArgChecker.AssertArgNotNull(buffer, nameof(buffer));
                if (index < 0 || index > buffer.Length)
                {
                    throw new ArgumentOutOfRangeException(nameof(index));
                }
                if (count < 0 || index + count > buffer.Length)
                {
                    throw new ArgumentOutOfRangeException(nameof(count));
                }

                count = Math.Min(count, _maxIndex - _index);
                _s.CopyTo(_index, buffer, index, count);
                _index += count;
                return(count);
            }
Exemplo n.º 12
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, MouseEventArgs e)
        {
            ArgChecker.AssertArgNotNull(parent, "parent");
            ArgChecker.AssertArgNotNull(e, "e");

            try
            {
                if (_selectionHandler != null && IsMouseInContainer(e.Location))
                {
                    _selectionHandler.SelectWord(parent, OffsetByScroll(e.Location));
                }
            }
            catch (Exception ex)
            {
                ReportError(HtmlRenderErrorType.KeyboardMouse, "Failed mouse double click handle", ex);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Combine this CSS data blocks with <paramref name="other"/> CSS blocks for each media.<br/>
        /// Merge blocks if exists in both.
        /// </summary>
        /// <param name="other">the CSS data to combine with</param>
        public void Combine(CssData other)
        {
            ArgChecker.AssertArgNotNull(other, "other");

            // for each media block
            foreach (var mediaBlock in other.MediaBlocks)
            {
                // for each css class in the media block
                foreach (var bla in mediaBlock.Value)
                {
                    // for each css block of the css class
                    foreach (var cssBlock in bla.Value)
                    {
                        // combine with this
                        AddCssBlock(mediaBlock.Key, cssBlock);
                    }
                }
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Render the html using the given device.
        /// </summary>
        /// <param name="g">the device to use to render</param>
        public void PerformPaint(RGraphics g)
        {
            ArgChecker.AssertArgNotNull(g, "g");

            if (this.MaxSize.Height > 0)
            {
                g.PushClip(new RRect(this._location.X, this._location.Y, Math.Min(this._maxSize.Width, this.PageSize.Width), Math.Min(this._maxSize.Height, this.PageSize.Height)));
            }
            else
            {
                g.PushClip(new RRect(this.MarginLeft, this.MarginTop, this.PageSize.Width, this.PageSize.Height));
            }

            if (this._root != null)
            {
                this._root.Paint(g);
            }

            g.PopClip();
        }
Exemplo n.º 15
0
        /// <summary>
        /// Handle key down event for selection and copy.
        /// </summary>
        /// <param name="parent">the control hosting the html to invalidate</param>
        /// <param name="e">the pressed key</param>
        public void HandleKeyDown(Control parent, KeyEventArgs e)
        {
            ArgChecker.AssertArgNotNull(parent, "parent");
            ArgChecker.AssertArgNotNull(e, "e");

            if (e.Control && _selectionHandler != null)
            {
                // select all
                if (e.KeyCode == Keys.A)
                {
                    _selectionHandler.SelectAll(parent);
                }

                // copy currently selected text
                if (e.KeyCode == Keys.C)
                {
                    _selectionHandler.CopySelectedHtml();
                }
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Measures the bounds of box and children, recursively.
        /// </summary>
        /// <param name="g">Device context to draw</param>
        public void PerformLayout(RGraphics g)
        {
            ArgChecker.AssertArgNotNull(g, "g");

            _actualSize = RSize.Empty;
            if (_root != null)
            {
                // if width is not restricted we set it to large value to get the actual later
                _root.Size     = new RSize(_maxSize.Width > 0 ? _maxSize.Width : 99999, 0);
                _root.Location = _location;
                _root.PerformLayout(g);

                if (_maxSize.Width <= 0.1)
                {
                    // in case the width is not restricted we need to double layout, first will find the width so second can layout by it (center alignment)
                    _root.Size  = new RSize((int)Math.Ceiling(_actualSize.Width), 0);
                    _actualSize = RSize.Empty;
                    _root.PerformLayout(g);
                }
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Render the html using the given device.
        /// </summary>
        /// <param name="g">the device to use to render</param>
        public void PerformPaint(RGraphics g)
        {
            ArgChecker.AssertArgNotNull(g, "g");

            bool pushedClip = false;

            if (MaxSize.Height > 0)
            {
                pushedClip = true;
                g.PushClip(new RRect(_location, _maxSize));
            }

            if (_root != null)
            {
                _root.Paint(g);
            }

            if (pushedClip)
            {
                g.PopClip();
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Render the html using the given device.
        /// </summary>
        /// <param name="g">the device to use to render</param>
        public void PerformPaint(Graphics g)
        {
            ArgChecker.AssertArgNotNull(g, "g");

            Region prevClip = null;

            if (MaxSize.Height > 0)
            {
                prevClip = g.Clip;
                g.SetClip(new RectangleF(_location, _maxSize));
            }

            if (_root != null)
            {
                _root.Paint(g);
            }

            if (prevClip != null)
            {
                g.SetClip(prevClip, CombineMode.Replace);
            }
        }
Exemplo n.º 19
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="e">the mouse event args</param>
        public void HandleMouseMove(Control parent, MouseEventArgs e)
        {
            ArgChecker.AssertArgNotNull(parent, "parent");
            ArgChecker.AssertArgNotNull(e, "e");

            try
            {
                Point loc = OffsetByScroll(e.Location);
                if (_selectionHandler != null && IsMouseInContainer(e.Location))
                {
                    _selectionHandler.HandleMouseMove(parent, loc);
                }

                /*
                 * if( _hoverBoxes != null )
                 * {
                 *  bool refresh = false;
                 *  foreach(var hoverBox in _hoverBoxes)
                 *  {
                 *      foreach(var rect in hoverBox.Item1.Rectangles.Values)
                 *      {
                 *          if( rect.Contains(loc) )
                 *          {
                 *              //hoverBox.Item1.Color = "gold";
                 *              refresh = true;
                 *          }
                 *      }
                 *  }
                 *
                 *  if(refresh)
                 *      RequestRefresh(true);
                 * }
                 */
            }
            catch (Exception ex)
            {
                ReportError(HtmlRenderErrorType.KeyboardMouse, "Failed mouse move handle", ex);
            }
        }
Exemplo n.º 20
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="location">the location of the mouse</param>
        public void HandleMouseMove(RControl parent, RPoint location)
        {
            ArgChecker.AssertArgNotNull(parent, "parent");

            try
            {
                var loc = OffsetByScroll(location);
                if (_selectionHandler != null && IsMouseInContainer(location))
                {
                    _selectionHandler.HandleMouseMove(parent, loc);
                }

                if (_hoverBoxes != null)
                {
                    bool refresh = false;
                    foreach (var hoverBox in _hoverBoxes)
                    {
                        foreach (var rect in hoverBox.CssBox.Rectangles.Values)
                        {
                            if (rect.Contains(loc))
                            {
                                //Console.WriteLine("" + hoverBox.CssBlock.Class);
                                hoverBox.CssBox.Color = "red";
                                refresh = true;
                            }
                        }
                    }

                    if (refresh)
                    {
                        RequestRefresh(true);
                    }
                }
            }
            catch (Exception ex)
            {
                ReportError(HtmlRenderErrorType.KeyboardMouse, "Failed mouse move handle", ex);
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Makes a request to download the image from the server and raises the <see cref="cachedFileCallback"/> when it's down.<br/>
        /// </summary>
        /// <param name="imageUri">The online image uri</param>
        /// <param name="filePath">the path on disk to download the file to</param>
        /// <param name="async">is to download the file sync or async (true-async)</param>
        /// <param name="cachedFileCallback">This callback will be called with local file path. If something went wrong in the download it will return null.</param>
        public void DownloadImage(Uri imageUri, string filePath, bool async,
                                  DownloadFileAsyncCallback cachedFileCallback)
        {
            ArgChecker.AssertArgNotNull(imageUri, "imageUri");
            ArgChecker.AssertArgNotNull(cachedFileCallback, "cachedFileCallback");

            // to handle if the file is already been downloaded
            bool download = true;

            lock (_imageDownloadCallbacks)
            {
                if (_imageDownloadCallbacks.ContainsKey(filePath))
                {
                    download = false;
                    _imageDownloadCallbacks[filePath].Add(cachedFileCallback);
                }
                else
                {
                    _imageDownloadCallbacks[filePath] = new List <DownloadFileAsyncCallback> {
                        cachedFileCallback
                    };
                }
            }

            if (download)
            {
                var tempPath = Path.GetTempFileName();
                if (async)
                {
                    ThreadPool.QueueUserWorkItem(DownloadImageFromUrlAsync,
                                                 new DownloadData(imageUri, tempPath, filePath));
                }
                else
                {
                    DownloadImageFromUrl(imageUri, tempPath, filePath);
                }
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// LoadFromRaw stylesheet data from the given source.<br/>
        /// The source can be local file or web URI.<br/>
        /// First raise <see cref="HtmlStylesheetLoadEventArgs"/> event to allow the client to overwrite the stylesheet loading.<br/>
        /// If the stylesheet is downloaded from URI we will try to correct local URIs to absolute.<br/>
        /// </summary>
        /// <param name="htmlContainer">the container of the html to handle load stylesheet for</param>
        /// <param name="src">the source of the element to load the stylesheet by</param>
        /// <param name="attributes">the attributes of the link element</param>
        /// <param name="stylesheet">return the stylesheet string that has been loaded (null if failed or <paramref name="stylesheetData"/> is given)</param>
        /// <param name="stylesheetData">return stylesheet data object that was provided by overwrite (null if failed or <paramref name="stylesheet"/> is given)</param>
        public static void LoadStylesheet(HtmlContainerInt htmlContainer, string src, Dictionary<string, string> attributes, out string stylesheet, out CssData stylesheetData)
        {
            ArgChecker.AssertArgNotNull(htmlContainer, "htmlContainer");

            stylesheet = null;
            stylesheetData = null;
            try {
                var args = new HtmlStylesheetLoadEventArgs(src, attributes);
                htmlContainer.RaiseHtmlStylesheetLoadEvent(args);

                if (!string.IsNullOrEmpty(args.SetStyleSheet)) {
                    stylesheet = args.SetStyleSheet;
                } else if (args.SetStyleSheetData != null) {
                    stylesheetData = args.SetStyleSheetData;
                } else if (args.SetSrc != null) {
                    stylesheet = LoadStylesheet(htmlContainer, args.SetSrc);
                } else {
                    stylesheet = LoadStylesheet(htmlContainer, src);
                }
            } catch (Exception ex) {
                htmlContainer.ReportError(HtmlRenderErrorType.CssParsing, "Exception in handling stylesheet source", ex);
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Handle key down event for selection and copy.
        /// </summary>
        /// <param name="parent">the control hosting the html to invalidate</param>
        /// <param name="e">the pressed key</param>
        public void HandleKeyDown(RControl parent, RKeyEvent e)
        {
            ArgChecker.AssertArgNotNull(parent, "parent");
            ArgChecker.AssertArgNotNull(e, "e");

            try {
                if (e.Control && _selectionHandler != null)
                {
                    // select all
                    if (e.AKeyCode)
                    {
                        _selectionHandler.SelectAll(parent);
                    }

                    // copy currently selected text
                    if (e.CKeyCode)
                    {
                        _selectionHandler.CopySelectedHtml();
                    }
                }
            } catch (Exception ex) {
                ReportError(HtmlRenderErrorType.KeyboardMouse, "Failed key down handle", ex);
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// Adds a font family to be used in html rendering.<br/>
        /// The added font will be used by all rendering function including <see cref="HtmlContainer"/> and all WinForms controls.
        /// </summary>
        /// <remarks>
        /// The given font family instance must be remain alive while the renderer is in use.<br/>
        /// If loaded to <see cref="PrivateFontCollection"/> then the collection must be alive.<br/>
        /// If loaded from file then the file must not be deleted.
        /// </remarks>
        /// <param name="fontFamily">The font family to add.</param>
        public static void AddFontFamily(FontFamily fontFamily)
        {
            ArgChecker.AssertArgNotNull(fontFamily, "fontFamily");

            FontsUtils.AddFontFamily(fontFamily);
        }
Exemplo n.º 25
0
 /// <summary>
 /// Renders the specified HTML source on the specified location and max size restriction.<br/>
 /// Use GDI+ text rending, use <see cref="Graphics.TextRenderingHint"/> to control text rendering.<br/>
 /// If <paramref name="maxSize"/>.Width is zero the html will use all the required width, otherwise it will perform line
 /// wrap as specified in the html<br/>
 /// If <paramref name="maxSize"/>.Height is zero the html will use all the required height, otherwise it will clip at the
 /// given max height not rendering the html below it.<br/>
 /// Returned is the actual width and height of the rendered html.<br/>
 /// </summary>
 /// <param name="g">Device to render with</param>
 /// <param name="html">HTML source to render</param>
 /// <param name="location">the top-left most location to start render the html at</param>
 /// <param name="maxSize">the max size of the rendered html (if height above zero it will be clipped)</param>
 /// <param name="cssData">optional: the style to use for html rendering (default - use W3 default style)</param>
 /// <param name="stylesheetLoad">optional: can be used to overwrite stylesheet resolution logic</param>
 /// <param name="imageLoad">optional: can be used to overwrite image resolution logic</param>
 /// <returns>the actual size of the rendered html</returns>
 public static SizeF RenderGdiPlus(Graphics g, string html, PointF location, SizeF maxSize, CssData cssData = null,
                                   EventHandler <HtmlStylesheetLoadEventArgs> stylesheetLoad = null, EventHandler <HtmlImageLoadEventArgs> imageLoad = null)
 {
     ArgChecker.AssertArgNotNull(g, "g");
     return(RenderClip(g, html, location, maxSize, cssData, true, stylesheetLoad, imageLoad));
 }
Exemplo n.º 26
0
 /// <summary>
 /// Renders the specified HTML source on the specified location and max size restriction.<br/>
 /// Use GDI+ text rending, use <see cref="Graphics.TextRenderingHint"/> to control text rendering.<br/>
 /// If <paramref name="maxWidth"/> is zero the html will use all the required width, otherwise it will perform line
 /// wrap as specified in the html<br/>
 /// Returned is the actual width and height of the rendered html.<br/>
 /// </summary>
 /// <param name="g">Device to render with</param>
 /// <param name="html">HTML source to render</param>
 /// <param name="left">optional: the left most location to start render the html at (default - 0)</param>
 /// <param name="top">optional: the top most location to start render the html at (default - 0)</param>
 /// <param name="maxWidth">optional: bound the width of the html to render in (default - 0, unlimited)</param>
 /// <param name="cssData">optional: the style to use for html rendering (default - use W3 default style)</param>
 /// <param name="stylesheetLoad">optional: can be used to overwrite stylesheet resolution logic</param>
 /// <param name="imageLoad">optional: can be used to overwrite image resolution logic</param>
 /// <returns>the actual size of the rendered html</returns>
 public static SizeF RenderGdiPlus(Graphics g, string html, float left = 0, float top = 0, float maxWidth = 0, CssData cssData = null,
                                   EventHandler <HtmlStylesheetLoadEventArgs> stylesheetLoad = null, EventHandler <HtmlImageLoadEventArgs> imageLoad = null)
 {
     ArgChecker.AssertArgNotNull(g, "g");
     return(RenderClip(g, html, new PointF(left, top), new SizeF(maxWidth, 0), cssData, true, stylesheetLoad, imageLoad));
 }
Exemplo n.º 27
0
 /// <summary>
 /// Measure the size (width and height) required to draw the given html under given max width restriction.<br/>
 /// If no max width restriction is given the layout will use the maximum possible width required by the content,
 /// it can be the longest text line or full image width.<br/>
 /// Use GDI+ text rending, use <see cref="Graphics.TextRenderingHint"/> to control text rendering.
 /// </summary>
 /// <param name="g">Device to use for measure</param>
 /// <param name="html">HTML source to render</param>
 /// <param name="maxWidth">optional: bound the width of the html to render in (default - 0, unlimited)</param>
 /// <param name="cssData">optional: the style to use for html rendering (default - use W3 default style)</param>
 /// <param name="stylesheetLoad">optional: can be used to overwrite stylesheet resolution logic</param>
 /// <param name="imageLoad">optional: can be used to overwrite image resolution logic</param>
 /// <returns>the size required for the html</returns>
 public static SizeF MeasureGdiPlus(Graphics g, string html, float maxWidth = 0, CssData cssData = null,
                                    EventHandler <HtmlStylesheetLoadEventArgs> stylesheetLoad = null, EventHandler <HtmlImageLoadEventArgs> imageLoad = null)
 {
     ArgChecker.AssertArgNotNull(g, "g");
     return(Measure(g, html, maxWidth, cssData, true, stylesheetLoad, imageLoad));
 }
Exemplo n.º 28
0
        /// <summary>
        /// Init.
        /// </summary>
        public DomParser(CssParser cssParser)
        {
            ArgChecker.AssertArgNotNull(cssParser, "cssParser");

            _cssParser = cssParser;
        }
Exemplo n.º 29
0
        /// <summary>
        /// Handle mouse leave to handle hover cursor.
        /// </summary>
        /// <param name="parent">the control hosting the html to set cursor and invalidate</param>
        public void HandleMouseLeave(Control parent)
        {
            ArgChecker.AssertArgNotNull(parent, "parent");

            _htmlContainerInt.HandleMouseLeave(new ControlAdapter(parent, _useGdiPlusTextRendering));
        }
Exemplo n.º 30
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), Utils.Convert(mousePos));
        }