/// <summary>Calculates the size of the rich text.</summary>
        /// <param name="graphics">The graphics.</param>
        /// <param name="text">The text.</param>
        /// <param name="maxSize">The maximum size.</param>
        /// <param name="itemViewInfo">The item view information.</param>
        /// <returns>A <see cref="Size" />.</returns>
        public Size CalcRichTextSize(Graphics graphics, string text, Size maxSize, RichToolTipItemViewInfo itemViewInfo)
        {
            const int delta = 20;

            var vi = new RichTextEditViewInfo(richTextRepoItem);

            vi.LoadText(text);

            var viewer = vi.GetViewer();

            var height = viewer.GetEditorHeight(graphics, maxSize.Width, maxSize.Height, 1.0f);
            var width  = maxSize.Width;

            while (height < maxSize.Height && width > delta && viewer.GetEditorHeight(graphics, width - delta, maxSize.Height, 1.0f) == height)
            {
                width -= delta;
            }

            return(new Size(width + delta, height));
        }
Exemplo n.º 2
0
 public RichToolTipItemInfoArgs(GraphicsCache cache, RichToolTipItemViewInfo viewInfo)
     : base(cache, viewInfo, viewInfo.Bounds)
 {
 }