public override void DrawItemOn(Gdi g, Rectangle rItem) { int y = (rItem.Height - _imageSize.Height) / 2; g.Font = Font; if (_selectButton != null) { g.DrawImageAlphaChannel(_selectButton, rItem.Right - _imageSize.Width - UISettings.CalcPix(15), rItem.Top + y); } g.TextColor = Color.FromArgb(51, 153, 255); var textSize = g.GetTextExtent((string)DataSource.OptionValue); y = (rItem.Height - textSize.Height) / 2; int x = rItem.Width - UISettings.CalcPix(20) - _imageSize.Width; if (textSize.Width < x) { x = textSize.Width; } g.DrawText((string)DataSource.OptionValue, new Win32.RECT(rItem.Right - UISettings.CalcPix(20) - _imageSize.Width - x, rItem.Top + y, x, textSize.Height), Win32.DT.LEFT | Win32.DT.TOP | Win32.DT.WORDBREAK | Win32.DT.SINGLELINE); }
protected override void OnRender(Gdi graphics, Rectangle clipRect) { IntPtr ptrSrc = OffscreenBuffer.OffScreenGraphics.GetHdc(); using (Gdi gr = Gdi.FromHdc(ptrSrc, Rectangle.Empty)) { DrawBackground(gr, clipRect); // fill background with double gradient var y = (int)(_backgroundRectangle.Height * _gradientCenter); gr.GradientFill(new Rectangle(_backgroundRectangle.Left, _backgroundRectangle.Top, _backgroundRectangle.Width, y), _gradientColor1, _gradientColor2, FillDirection.TopToBottom); gr.GradientFill(new Rectangle(_backgroundRectangle.Left, _backgroundRectangle.Top + y, _backgroundRectangle.Width, _backgroundRectangle.Height - y), _gradientColor2, _gradientColor3, FillDirection.TopToBottom); // Pass the graphics to the canvas to render if (Canvas != null) { Canvas.Render(gr, clipRect); } //Draw Text SetFont(gr); gr.DrawText(_message, new Win32.RECT(_textRectangle.X, _textRectangle.Y, _textRectangle.Width, _textRectangle.Height), Win32.DT.LEFT | Win32.DT.TOP | Win32.DT.WORDBREAK | Win32.DT.NOCLIP); } graphics.BitBlt(clipRect.Left, clipRect.Top, Width, Height, ptrSrc, clipRect.Left, clipRect.Top, TernaryRasterOperations.SRCCOPY); OffscreenBuffer.OffScreenGraphics.ReleaseHdc(ptrSrc); }