Example #1
0
 /// <summary>
 /// Perform the layout of the html in the control.
 /// </summary>
 protected override void OnLayout(LayoutEventArgs levent)
 {
     if (_htmlContainer != null)
     {
         using (Graphics g = CreateGraphics())
         using (var ig = new GraphicsAdapter(g, _htmlContainer.UseGdiPlusTextRendering))
         {
             var newSize = HtmlRendererUtils.Layout(ig,
                 _htmlContainer.HtmlContainerInt,
                 new RSize(ClientSize.Width - Padding.Horizontal, ClientSize.Height - Padding.Vertical),
                 new RSize(MinimumSize.Width - Padding.Horizontal, MinimumSize.Height - Padding.Vertical),
                 new RSize(MaximumSize.Width - Padding.Horizontal, MaximumSize.Height - Padding.Vertical),
                 AutoSize,
                 AutoSizeHeightOnly);
             ClientSize = Utils.ConvertRound(new RSize(newSize.Width + Padding.Horizontal, newSize.Height + Padding.Vertical));
         }
     }
     base.OnLayout(levent);
 }
Example #2
0
 /// <summary>
 /// Measure the size of the html by performing layout under the given restrictions.
 /// </summary>
 /// <param name="htmlContainer">the html to calculate the layout for</param>
 /// <param name="minSize">the minimal size of the rendered html (zero - not limit the width/height)</param>
 /// <param name="maxSize">the maximum size of the rendered html, if not zero and html cannot be layout within the limit it will be clipped (zero - not limit the width/height)</param>
 /// <returns>return: the size of the html to be rendered within the min/max limits</returns>
 private static Size MeasureHtmlByRestrictions(HtmlContainer htmlContainer, Size minSize, Size maxSize)
 {
     // use desktop created graphics to measure the HTML
     using (var g = Graphics.FromHwnd(IntPtr.Zero))
     using (var mg = new GraphicsAdapter(g, htmlContainer.UseGdiPlusTextRendering))
     {
         var sizeInt = HtmlRendererUtils.MeasureHtmlByRestrictions(mg, htmlContainer.HtmlContainerInt, Utils.Convert(minSize), Utils.Convert(maxSize));
         return Utils.ConvertRound(sizeInt);
     }
 }
Example #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");

            using (var ig = new GraphicsAdapter(g, _useGdiPlusTextRendering))
            {
                _htmlContainerInt.PerformPaint(ig);
            }
        }
 public override void MeasureString(string str, RFont font, double maxWidth, out int charFit, out double charFitWidth)
 {
     using (var g = new GraphicsAdapter(_control.CreateGraphics(), _useGdiPlusTextRendering, true))
     {
         g.MeasureString(str, font, maxWidth, out charFit, out charFitWidth);
     }
 }
Example #5
0
 public override void MeasureString(string str, RFont font, double maxWidth, out int charFit, out double charFitWidth)
 {
     using (var g = new GraphicsAdapter(_control.CreateGraphics(), _useGdiPlusTextRendering, true)) {
         g.MeasureString(str, font, maxWidth, out charFit, out charFitWidth);
     }
 }