private void Setup() { BufferedGraphicsContext bgc = BufferedGraphicsManager.Current; bgc.MaximumBuffer = new Size( _width - 10, _height - 10 ); using( BufferedGraphics bg = bgc.Allocate( CreateGraphics(), new Rectangle( _xoff + 7, _yoff + 3, _width - 10, _height - 10 ) ) ) { Graphics g = bg.Graphics; VectorGraphics.Primitives.Container container; Render( g, new Rectangle( 0, 0, _width + 20, _height + 20 ), _info, _width, _height, _balloon, _colorTable, out container ); Bitmap bitmapArgb = new Bitmap( _width + 30, _height + 30, PixelFormat.Format32bppArgb ); using( Graphics ng = Graphics.FromImage( bitmapArgb ) ) { VectorGraphics.Renderers.GdiPlusRenderer nrenderer = new VectorGraphics.Renderers.GdiPlusRenderer ( delegate { return ng; }, BinaryComponents.VectorGraphics.Renderers.GdiPlusRenderer.MarkerHandling.Ignore, 5 ); ng.TranslateTransform( _xoff, _yoff ); nrenderer.Render( ng, container, new VectorGraphics.Types.Rectangle( 0, 0, _width + 30, _height + 30 ) ); ng.TranslateTransform( _xoff + 4, _yoff + 4 ); bg.Render( ng ); } byte opacity = (byte) (_opacity * 255); SetBitmap( bitmapArgb, opacity ); } }
private static void Render( Graphics g, Rectangle clip, SuperToolTipInfo info, int width, int height, bool balloon, Drawing.ColorTable colorTable, out VectorGraphics.Primitives.Container container ) { VectorGraphics.Types.Rectangle clipRect = VectorGraphics.Renderers.GdiPlusUtility.Convert.Rectangle( clip ); VectorGraphics.Renderers.GdiPlusRenderer renderer = new VectorGraphics.Renderers.GdiPlusRenderer ( delegate { return g; }, BinaryComponents.VectorGraphics.Renderers.GdiPlusRenderer.MarkerHandling.Ignore, 5 ); container = CreateContainer( renderer, width, height, balloon, colorTable ); g.TranslateTransform( _xoff, _yoff ); renderer.Render( g, container, clipRect ); int titleHeight = WinFormsUtility.Drawing.GdiPlusEx.MeasureString( g, info.Title, SystemFonts.DialogFont, width - _bodyIndent ).Height; Rectangle rect = new Rectangle( 0, 0, width, height ); Rectangle titleRect = new Rectangle( rect.X + _border, rect.Y + _border, rect.Width - _border * 2, titleHeight ); Rectangle bodyRect = new Rectangle( rect.X + _border + _bodyIndent, rect.Y + titleHeight + _border + _titleSep, rect.Width - _border * 2 - _bodyIndent, rect.Height - titleHeight - _border * 2 - _titleSep ); using( Font font = new Font( SystemFonts.DialogFont, FontStyle.Bold ) ) { WinFormsUtility.Drawing.GdiPlusEx.DrawString ( g, info.Title, font, colorTable.TextColor, titleRect , WinFormsUtility.Drawing.GdiPlusEx.TextSplitting.MultiLine, WinFormsUtility.Drawing.GdiPlusEx.Ampersands.Display ); } WinFormsUtility.Drawing.GdiPlusEx.DrawString ( g, info.Description, SystemFonts.DialogFont, colorTable.TextColor , bodyRect, WinFormsUtility.Drawing.GdiPlusEx.TextSplitting.MultiLine, WinFormsUtility.Drawing.GdiPlusEx.Ampersands.Display ); }