Example #1
0
 public override void DrawBackground(Graphics graphics, Rectangle bounds)
 {
     using (var mh = ManagedHdc.FromGraphics(graphics))
     {
         var rect = Win32.RECT.FromRectangle(bounds);
         UxTheme.DrawThemeBackground(_theme, mh.Hdc, _partId, _stateId, ref rect, IntPtr.Zero);
     }
 }
Example #2
0
 public override void DrawParentBackground(Graphics graphics, Rectangle bounds, Control childControl)
 {
     using (var mh = ManagedHdc.FromGraphics(graphics))
     {
         var rect = Win32.RECT.FromRectangle(bounds);
         UxTheme.DrawThemeParentBackground(_theme, mh.Hdc, ref rect);
     }
 }
Example #3
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);
     }
 }
Example #4
0
 public static Font GetThemeFont(IntPtr theme, Graphics graphics)
 {
     if (!_themeFontMap.ContainsKey(theme))
     {
         using (var m = ManagedHdc.FromGraphics(graphics))
         {
             LOGFONT font = new LOGFONT();
             int     ret  = GetThemeFont(theme, m.Hdc, 1, 1, PropertyIdentifier.Font, out font);
             if (ret != 0)
             {
                 return(SystemFonts.CaptionFont);
             }
             Font themeFont = Font.FromLogFont(font);
             _themeFontMap.Add(theme, themeFont);
             return(themeFont);
         }
     }
     return(_themeFontMap[theme]);
 }