The theme defines style and appearance of controls in Dapfor library

Namespace: Dapfor.Net.Theming
Assembly: Dapfor.Net (in Dapfor.Net.dll) Version: 2.10.3.24917 (2.10.3.24917)

Syntax

C#
public class Theme
Visual Basic
Public Class Theme
Visual C++
public ref class Theme
F#
type Theme =  class end

Remarks

Themes are sets of properties and colors for each control. They define style and appearance of controls in Dapfor library. In addition to properties and cooler themes contain code for specific painting of various control elements (including .Net Grid).

The grid supports attachment of themes via Grid.Theme property. Dapfor's library contains several predefined themes such as Theme.XPStyle, Theme.Silver, etc. The list of predefined themes is stored in Dapfor.Net.Theming.KnownTheme enumeration. Accordingly, theme object can be obtained with the following code.

 Copy imageCopy
grid1.Theme = Theme.XPStyle;
grid2.Theme = Theme.FromKnownTheme(KnownTheme.XPStyle);

A programmer may also create his own themes, including those based on already existing themes. The example below demonstrates creation of an arbitrary theme on the basis of an existing theme. Therefore, all grids using the same theme shall look in the same way.

 Copy imageCopy
Theme myTheme = new Theme("MyTheme", Theme.Silver);
myTheme.Renderers.GridRenderer.Appearance.ColumnNormal.BackColor = Color.LightPink;
myTheme.Renderers.GridRenderer.Appearance.ColumnNormal.GradientEndBackColor = ControlPaint.Dark(Color.LightPink);
grid.Theme = myTheme;

Dapfor’s library provides a convenient API for theme changing. For this purpose it uses a special default theme that is returned by Theme.Default property. If a grid uses this theme, it subscribes to Theme.DefaultThemeChanged events. Therefore, when a new theme is set in Theme.Default property, all controls subscribed to this theme shall receive notifications and automatically change their appearance.

 Copy imageCopy
grid1.Theme = Theme.Default;
grid2.Theme = Theme.Default;

Theme myTheme = new Theme("MyTheme", Theme.Silver);
Theme.Default = myTheme;

Grid themes have been developed to enable the programmer to change appearance of any grid elements. When a theme is set for the grid, this grid uses colors and renderer defined for each theme. In addition to that a programmer may modify colors for headers, columns, rows etc using properties like Grid.Appearance, Header.Appearance, etc.

Inheritance Hierarchy

System..::..Object
  Dapfor.Net.Theming..::..Theme

See Also