Esempio n. 1
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)
            {
                using (var ig = new WinGraphics(g, _useGdiPlusTextRendering))
                {
                    _root.Paint(ig);
                }
            }

            if (prevClip != null)
            {
                g.SetClip(prevClip, CombineMode.Replace);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Measures the bounds of box and children, recursively.
        /// </summary>
        /// <param name="g">Device context to draw</param>
        public void PerformLayout(Graphics g)
        {
            ArgChecker.AssertArgNotNull(g, "g");

            if (_root != null)
            {
                using (var ig = new WinGraphics(g, _useGdiPlusTextRendering))
                {
                    _actualSize = SizeF.Empty;

                    // if width is not restricted we set it to large value to get the actual later
                    _root.Size     = new SizeF(_maxSize.Width > 0 ? _maxSize.Width : 99999, 0);
                    _root.Location = _location;
                    _root.PerformLayout(ig);

                    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 SizeF((int)Math.Ceiling(_actualSize.Width), 0);
                        _actualSize = SizeF.Empty;
                        _root.PerformLayout(ig);
                    }
                }
            }
        }
Esempio n. 3
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)
            {
                using (var ig = new WinGraphics(g))
                {
                    _root.Paint(ig);
                }
            }

            if (prevClip != null)
            {
                g.SetClip(prevClip, CombineMode.Replace);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Measures the bounds of box and children, recursively.
        /// </summary>
        /// <param name="g">Device context to draw</param>
        public void PerformLayout(Graphics g)
        {
            ArgChecker.AssertArgNotNull(g, "g");

            if (_root != null)
            {
                using (var ig = new WinGraphics(g))
                {
                    _actualSize = SizeF.Empty;

                    // if width is not restricted we set it to large value to get the actual later
                    _root.Size = new SizeF(_maxSize.Width > 0 ? _maxSize.Width : 99999, 0);
                    _root.Location = _location;
                    _root.PerformLayout(ig);

                    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 SizeF((int)Math.Ceiling(_actualSize.Width), 0);
                        _actualSize = SizeF.Empty;
                        _root.PerformLayout(ig);
                    }
                }
            }
        }