Ejemplo n.º 1
0
 public override void DrawText(Graphics graphics, Rectangle bounds, string text)
 {
     using (var mh = ManagedHdc.FromGraphics(graphics))
     {
         var  rect  = Win32.RECT.FromRectangle(bounds);
         uint flags = (int)(TextFormatFlags.EndEllipsis);
         UxTheme.DrawThemeText(_theme, mh.Hdc, _partId, _stateId, text, text.Length, flags, 0, ref rect);
     }
 }
Ejemplo n.º 2
0
        public void DrawText(IDeviceContext dc, Rectangle bounds, string textToDraw, bool drawDisabled, TextFormatFlags flags)
        {
            if (dc == null)
            {
                throw new ArgumentNullException(nameof(dc));
            }

            if (bounds.Width < 0 || bounds.Height < 0)
            {
                return;
            }

            if (!string.IsNullOrEmpty(textToDraw))
            {
                using var wgr = new WindowsGraphicsWrapper(dc, AllGraphicsProperties);
                var  hdc         = new HandleRef(wgr, wgr.WindowsGraphics.DeviceContext.Hdc);
                uint disableFlag = drawDisabled ? 0x1u : 0u;
                RECT rect        = bounds;
                lastHResult = UxTheme.DrawThemeText(this, hdc, part, state, textToDraw, textToDraw.Length, (User32.DT)flags, disableFlag, ref rect);
            }
        }