Skybound VisualStyles

ThemeInformation Class

Provides information about whether visual styles are supported on the system and whether they are enabled in the current application.

For a list of all members of this type, see ThemeInformation Members.

System.Object
   Skybound.VisualStyles.ThemeInformation

[Visual Basic]
NotInheritable Public Class ThemeInformation
[C#]
public sealed class ThemeInformation

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

In a custom drawing routine, use this class to determine whether visual styles are enabled in the current application before drawing. When they are not, you should use your own custom drawing code.

The VisualStyles assembly requires permission to call unmanaged code in order to use the Theme API. When loaded in a partial trust security context (for example, when the application was launched from Internet Exploerer or from a network share) access to unmanaged code is not allowed. Therefore, this class will report that visual styles are not enabled. However, there are by default no such restrictions for assemblies that are installed in the Global Assembly Cache. To use VisualStyles in a partial trust security context, install it into the Global Assembly Cache first.

Example

This example draws the background of a button onto a Graphics surface. When visual styles are enabled, the button is drawn using the Theme API. Otherwise, it is drawn using the DrawButton method of the framework ControlPaint class.

private void DrawButtonBackground(Graphics g, Rectangle bounds)
{
  // check whether visual styles are enabled:
  if (ThemeInformation.VisualStylesEnabled)
  {
    // draw the button background using the Theme API:
    ThemePaint.Draw(
      g,
      this,
      ThemeClasses.Button,
      ThemeParts.ButtonPushButton,
      ThemeStates.PushButtonNormal,
      bounds, bounds
      );
  }
  else
  {
    // draw the button background without the Theme API:
    ControlPaint.DrawButton(g, bounds, ButtonState.Normal);
  }
}

Requirements

Namespace: Skybound.VisualStyles

Assembly: Skybound.VisualStyles (in Skybound.VisualStyles.dll)

See Also

ThemeInformation Members | Skybound.VisualStyles Namespace