Class ThemedControlDrawing
Manages the theme handle given a control and exposes some basic themed Drawing methods.
Inheritance
Implements
Inherited Members
Namespace: Syncfusion.Windows.Forms
Assembly: Syncfusion.Shared.Base.dll
Syntax
public class ThemedControlDrawing : Disposable, IDisposable
Remarks
The System.Windows.Forms.Control bound to this class can either implement the IThemedControl interface or pass on the WM_THEMECHANGED message to this class with a call to the RefreshThemeHandle() method.
Constructors
ThemedControlDrawing(String)
Creates a new instance of the ThemedControlDrawing class.
Declaration
public ThemedControlDrawing(string classList)
Parameters
Type | Name | Description |
---|---|---|
System.String | classList | Pointer to a string that contains a semicolon-separated list of classes, as expected in the OpenThemeData API. |
Remarks
The System.Windows.Forms.Control bound to this class can either implement the IThemedControl interface or pass on the WM_THEMECHANGED message to this class with a call to the RefreshThemeHandle() method. This is necessary in order that this class can refresh its handles when themes settings are updated.
You can get the part and state ids required for the DrawXXX methods from the tmschema.h file (that comes with Platform SDK) or refer to the undocumented and incomplete ThemeParts and ThemeStates classes in our shared library (in the ThemeDefines.cs file).
ThemedControlDrawing(String, IComponent)
Creates a new instance of the ThemedControlDrawing class.
Declaration
public ThemedControlDrawing(string classList, IComponent owner)
Parameters
Type | Name | Description |
---|---|---|
System.String | classList | Pointer to a string that contains a semicolon-separated list of classes, as expected in the OpenThemeData API. |
System.ComponentModel.IComponent | owner | Owning component. |
Remarks
The System.Windows.Forms.Control bound to this class can either implement the IThemedControl interface or pass on the WM_THEMECHANGED message to this class with a call to the RefreshThemeHandle() method. This is necessary in order that this class can refresh its handles when themes settings are updated.
You can get the part and state ids required for the DrawXXX methods from the tmschema.h file (that comes with Platform SDK) or refer to the undocumented and incomplete ThemeParts and ThemeStates classes in our shared library (in the ThemeDefines.cs file).
If owning component is not null, ThemedControlDrawing automatically unregisters itself from XPThemes on component disposing.
Properties
DrawMirrored
Declaration
public bool DrawMirrored { get; set; }
Property Value
Type |
---|
System.Boolean |
HTheme
Returns the current theme handle used to render the parts.
Declaration
public IntPtr HTheme { get; }
Property Value
Type |
---|
System.IntPtr |
Methods
CloseThemeData()
Closes the currently open theme handle.
Declaration
protected virtual void CloseThemeData()
Dispose(Boolean)
Overridden. See System.Windows.Forms.Control.Dispose(System.Boolean).
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
Overrides
DrawThemeBackground(Graphics, Int32, Int32, Rectangle)
Overloaded. Draws the specified theme background.
Declaration
public virtual void DrawThemeBackground(Graphics g, int partID, int stateID, Rectangle rectangle)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g | A System.Drawing.Graphics object. |
System.Int32 | partID | An integer specifying the part. |
System.Int32 | stateID | An integer specifying the state. |
System.Drawing.Rectangle | rectangle | The background System.Drawing.Rectangle. |
Remarks
See ThemedControlDrawing for information on how to get the part and state IDs.
This method uses the VisibleClipRegion in the Graphics object to obtain the clip rect.
DrawThemeBackground(Graphics, Int32, Int32, Rectangle, Rectangle)
Draws the specified theme background.
Declaration
public virtual void DrawThemeBackground(Graphics g, int partID, int stateID, Rectangle rectangle, Rectangle clipRect)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g | A System.Drawing.Graphics object. |
System.Int32 | partID | An integer specifying the part. |
System.Int32 | stateID | An integer specifying the state. |
System.Drawing.Rectangle | rectangle | The background System.Drawing.Rectangle. |
System.Drawing.Rectangle | clipRect | The clip rect to be used. |
Remarks
See ThemedControlDrawing for information on how to get the part and state IDs.
Use this function to provide custom clip bounds.
DrawThemeText(Graphics, Int32, Int32, String, Rectangle, Int32, Int32)
Draws the specified theme text.
Declaration
public void DrawThemeText(Graphics g, int partID, int stateID, string text, Rectangle bounds, int formatFlags1, int formatFlags2)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g | A System.Drawing.Graphics object. |
System.Int32 | partID | An integer specifying the part. |
System.Int32 | stateID | An integer specifying the state. |
System.String | text | The text to be drawn. |
System.Drawing.Rectangle | bounds | The layout bounds within which to draw. |
System.Int32 | formatFlags1 | Refers to the DrawThemeText function in the Windows API. |
System.Int32 | formatFlags2 | Refers to the DrawThemeText function in the Windows API. |
DrawThemeText(Graphics, Int32, Int32, String, Rectangle, UInt32, UInt32)
Overloaded. Draws the specified theme text.
Declaration
[CLSCompliant(false)]
public virtual void DrawThemeText(Graphics g, int partID, int stateID, string text, Rectangle bounds, uint formatFlags1, uint formatFlags2)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g | A System.Drawing.Graphics object. |
System.Int32 | partID | An integer specifying the part. |
System.Int32 | stateID | An integer specifying the state. |
System.String | text | The text to be drawn. |
System.Drawing.Rectangle | bounds | The layout bounds within which to draw. |
System.UInt32 | formatFlags1 | Refers to the DrawThemeText function in the Windows API. |
System.UInt32 | formatFlags2 | Refers to the DrawThemeText function in the Windows API. |
GetPartSize(Graphics, Int32, Int32, Int32)
Returns the size for the specified part.
Declaration
public virtual Size GetPartSize(Graphics g, int partId, int stateId, int sizeType)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g | A System.Drawing.Graphics object. |
System.Int32 | partId | An integer specifying the part. |
System.Int32 | stateId | An integer specifying the state. |
System.Int32 | sizeType | The size type. |
Returns
Type | Description |
---|---|
System.Drawing.Size | The requested size. |
GetTextExtent(Graphics, Int32, Int32, String, Rectangle, UInt32)
Calculates the size and location of the specified text when rendered in the theme font.
Declaration
[CLSCompliant(false)]
public virtual Rectangle GetTextExtent(Graphics g, int partId, int stateId, string text, Rectangle bounds, uint format)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g | A System.Drawing.Graphics object. |
System.Int32 | partId | An integer specifying the part. |
System.Int32 | stateId | An integer specifying the state. |
System.String | text | The text to draw. |
System.Drawing.Rectangle | bounds | The layout bounds. |
System.UInt32 | format | See GetThemeTextExtent method documentation in Windows API. |
Returns
Type | Description |
---|---|
System.Drawing.Rectangle | The rectangle representing the extent. |
GetThemeSysBool(Int32)
Declaration
public bool GetThemeSysBool(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id |
Returns
Type |
---|
System.Boolean |
GetThemeSysColor(Int32)
Declaration
public Color GetThemeSysColor(int colorId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | colorId |
Returns
Type |
---|
System.Drawing.Color |
GetThemeSysInt(Int32)
Declaration
public int GetThemeSysInt(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id |
Returns
Type |
---|
System.Int32 |
GetThemeSysSize(Int32)
Declaration
public int GetThemeSysSize(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id |
Returns
Type |
---|
System.Int32 |
GetThemeSysString(Int32)
Declaration
public string GetThemeSysString(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id |
Returns
Type |
---|
System.String |
OpenThemeData()
Called to create a theme handle, given the specified control and classList.
Declaration
protected virtual void OpenThemeData()
RefreshThemeHandle()
Closes the current theme handle and tries to open a new one.
Declaration
public void RefreshThemeHandle()
ResetThemeHandle()
Closes the current theme handle.
Declaration
public void ResetThemeHandle()