Document Themes
Document themes enable you to specify colors, fonts and a variety of graphic effects in a document and affect the look and feel of the whole document. Each theme contains a color scheme and a font scheme and is represented by the DocumentTheme class and can be modified by the Theme property of RadFlowDocument. Document theme contains two parts – color scheme – responsible for the colors, and font scheme – responsible for the fonts.
Color Schemes
A color scheme has a unique name and contains a number of predefined colors. Its representation in RadFlowDocument's model is the ThemeColorScheme class. A scheme defines twelve colors and each of these is assigned a sole ThemeColorType. The following list contains all ThemeColorType values:
- background1
- text1
- background2
- text2
- accent1
- accent2
- accent3
- accent4
- accent5
- accent6
- hyperlink
- followed hyperlink
The twelve color types above are used for creating ThemableColor objects. They determine the color of the scheme that appears as the actual color of the ThemableColor instance. As you change the theme or the color scheme, the actual color of the ThemeableColor object changes as well. For example, if you set the fill of a cell to be a ThemableColor, applying a new theme or another scheme also affects the solid fill.
Example 1 demonstrates how to create a ThemeColorScheme object. Note that the example passes a name and twelve colors to the constructor. Every color has a comment next to it, so you can see its corresponding ThemeColorType.
Example 1: Create a ThemeColorScheme object
ThemeColorScheme colorScheme = new ThemeColorScheme(
"Mine",
Colors.Black, // background 1
Colors.Blue, // text 1
Colors.Brown, // background 2
Colors.Cyan, // text 2
Colors.DarkGray, // accent 1
Colors.Gray, // accent 2
Colors.Green, // accent 3
Colors.LightGray, // accent 4
Colors.Magenta, // accent 5
Colors.Orange, // accent 6
Colors.Purple, // hyperlink
Colors.Red); // followedHyperlink
There are several ways to create a ThemableColor object:
-
Passing two parameters to the constructor – ThemeColorType and double.
ThemeColorType is an enum which has twelve possible values (the aforementioned color types).
The second parameter is of type double and should be between -1 and 1. It represents the tint and shade to be applied to the selected color.
-
Passing ThemeColorType and ColorShadeType.
- ThemeColorType is the same as in the previously mentioned constructor.
In order to create colors that depend on the current document theme, you need to use ThemableColor objects.
Example 2: Create a ThemableColor object
ThemableColor themableColor = new ThemableColor(ThemeColorType.Accent1);
Font Schemes
A font scheme is represented by the ThemeFontScheme class. Every font scheme consists of a name and a number of predefined font families. Each font family corresponds to one of two font types:
Major
Minor
The code in Example 3 illustrates how to create a ThemeFontScheme object. A name and two font family names are passed to the font scheme constructor. The former font family name corresponds to the Major ThemeFontType and the latter - to the Minor.
Example 3: Create a ThemeFontScheme
ThemeFontScheme fontScheme = new ThemeFontScheme(
"Mine",
"Times New Roman", // Major
"Arial"); // Minor
In order to use the document theme's fonts you need to use ThemableFontFamily objects. Again, there are several ways you can create one:
Passing a ThemeFontType object as a constructor parameter – this way you will bind the object being created to the currently selected document theme.
Passing a FontFamily object or a string representing a FontFamily name – the result would be a static FontFamily, meaning it will not be changed when the document theme is changed.
When you need to create a font that depends on the current document theme, you need to use ThemableFontFamily objects.
Example 4: Create a ThemableFontFamily object
ThemableFontFamily themableFont = new ThemableFontFamily(ThemeFontType.Major);
Document Themes
Now that you have a color and a font schemes, you can create a new DocumentTheme. You need to specify a name and pass the already created color and font schemes.
Example 5: Create a DocumentTheme object
DocumentTheme theme = new DocumentTheme("Mine", colorScheme, fontScheme);
Example 6: Using a predefined scheme
DocumentTheme theme1 = new DocumentTheme("From Predefined schemes", PredefinedThemeSchemes.ColorSchemes[0], PredefinedThemeSchemes.FontSchemes[5]);
Example 7: Change the document theme
RadFlowDocument document = new RadFlowDocument();
document.Theme = theme;
Predefined ThemeColorSchemes
The table includes all 42 predefined theme color schemes with their corresponding color values for each color category (Background 1, Text 1, Background 2, Text 2, Accent 1-6, Hyperlink, and Followed Hyperlink).
| Theme Name | Background 1 | Text 1 | Background 2 | Text 2 | Accent 1 | Accent 2 | Accent 3 | Accent 4 | Accent 5 | Accent 6 | Hyperlink | Followed Hyperlink |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Office | ||||||||||||
| Office 2007 - 2010 | ||||||||||||
| Grayscale | ||||||||||||
| Adjacency | ||||||||||||
| Angels | ||||||||||||
| Apex | ||||||||||||
| Apothecary | ||||||||||||
| Aspect | ||||||||||||
| Austin | ||||||||||||
| Black Tie | ||||||||||||
| Civic | ||||||||||||
| Clarity | ||||||||||||
| Composite | ||||||||||||
| Concourse | ||||||||||||
| Couture | ||||||||||||
| Elemental | ||||||||||||
| Equity | ||||||||||||
| Essential | ||||||||||||
| Executive | ||||||||||||
| Flow | ||||||||||||
| Foundry | ||||||||||||
| Grid | ||||||||||||
| Hardcover | ||||||||||||
| Horizon | ||||||||||||
| Median | ||||||||||||
| Metro | ||||||||||||
| Module | ||||||||||||
| Newsprint | ||||||||||||
| Opulent | ||||||||||||
| Oriel | ||||||||||||
| Origin | ||||||||||||
| Paper | ||||||||||||
| Perspective | ||||||||||||
| Pushpin | ||||||||||||
| Slipstream | ||||||||||||
| Solstice | ||||||||||||
| Technic | ||||||||||||
| Thatch | ||||||||||||
| Trek | ||||||||||||
| Urban | ||||||||||||
| Verve | ||||||||||||
| Waveform |
Predefined ThemeFontSchemes
RadWordsProcessing offers a set of predefined ThemeFontSchemes listed in the table below:
| Theme Name | Major Font | Minor Font |
|---|---|---|
| Office | Calibri Light | Calibri |
| Office 2007 - 2010 | Cambria | Calibri |
| Office 2 | Calibri | Cambria |
| Office Classic | Arial | Times New Roman |
| Office Classic 2 | Arial | Arial |
| Adjacency | Cambria | Calibri |
| Angels | Franklin Gothic Medium | Franklin Gothic Book |
| Apex | Lucida Sans | Book Antiqua |
| Apothecary | Book Antiqua | Century Gothic |
| Aspect | Verdana | Verdana |
| Austin | Century Gothic | Century Gothic |
| Black Tie | Garamond | Garamond |
| Civic | Georgia | Georgia |
| Clarity | Arial | Arial |
| Composite | Calibri | Calibri |
| Concourse | Lucida Sans Unicode | Lucida Sans Unicode |
| Couture | Garamond | Garamond |
| Elemental | Palatino Linotype | Palatino Linotype |
| Equity | Franklin Gothic Book | Perpetua |
| Essential | Arial Black | Arial |
| Executive | Century Gothic | Palatino Linotype |
| Flow | Calibri | Constantia |
| Foundry | Rockwell | Rockwell |
| Grid | Franklin Gothic Medium | Franklin Gothic Medium |
| Hardcover | Book Antiqua | Book Antiqua |
| Horizon | Arial Narrow | Arial Narrow |
| Median | Tw Cen MT | Tw Cen MT |
| Metro | Consolas | Corbel |
| Module | Corbel | Corbel |
| Newsprint | Impact | Times New Roman |
| Opulent | Trebuchet MS | Trebuchet MS |
| Oriel | Century Schoolbook | Century Schoolbook |
| Origin | Bookman Old Style | Gill Sans MT |
| Paper | Constantia | Constantia |
| Perspective | Arial | Arial |
| Pushpin | Constantia | Franklin Gothic Book |
| Slipstream | Trebuchet MS | Trebuchet MS |
| Solstice | Gill Sans MT | Gill Sans MT |
| Technic | Franklin Gothic Book | Arial |
| Thatch | Tw Cen MT | Tw Cen MT |
| Trek | Franklin Gothic Medium | Franklin Gothic Book |
| Urban | Trebuchet MS | Georgia |
| Verve | Century Gothic | Century Gothic |
| Waveform | Candara | Candara |
Getting Actual Values
In order to get the actual value from ThemableColor or ThemableFontFamily, you need to call the GetActualValue() method on the corresponding object.
Example 8: Get actual value from ThemableColor
Color actualColor = themableColor.GetActualValue(theme);
// The actual color is the same as Accent1 color of the colorScheme.
Example 9: Get actual value from ThemableFont
var actualFont = themableFont.GetActualValue(theme);
// The actualFont is the same as the Major font of the fontScheme.