Since version 4.2 MindFusion.Scheduling enables the creation of user-defined themes. The Theme class is now abstract and can be inherited. In order to create a custom theme, you have to define a new class derived from Theme and implement all abstract properties.
In order to work properly, all properties of the theme must be explicitly initialized. The theme properties cannot have undefined values. For example a property of type State cannot have Unspecified value. This ensues from the fact that the theme is the last layer in the appearance hierarchy and the mechanism to propagate a request further in the hierarchy when a theme property is undefined will fail. This requirement makes custom theme creation really tedious to be done manually. In order to automate this process, you can use the MindFusion Theme Editor, a small application installed with MindFusion.Scheduling. To learn more about the editor, please refer to Theme Editor.
The following sample code illustrates what is the usual structure of a custom theme class:
C#
Copy Code
|
---|
public class MyTheme : MindFusion.Scheduling.WinForms.Theme { public MyTheme() { this._controlAppearance = ControlAppearance.System; this._listViewSettings = base.CreateListViewSettings(); this._itemSettings = base.CreateItemSettings(); // Instantiate the rest of the fields
// Initialize all objects }
public override ControlAppearance ControlAppearance { get { return this._controlAppearance; } }
public override ListViewSettings ListViewSettings { get { return this._listViewSettings; } }
public override ItemSettings ItemSettings { get { return this._itemSettings; } }
// Override all other theme properties and return // the corresponding objects
private ControlAppearance _controlAppearance; private ListViewSettings _listViewSettings; private ItemSettings _itemSettings; // Declare all other necessary fields } |
Visual Basic
Copy Code
|
---|
Public Class MyTheme Inherits MindFusion.Scheduling.WinForms.Theme
Public Sub New()
Me._controlAppearance = ControlAppearance.System Me._listViewSettings = MyBase.CreateListViewSettings() Me._itemSettings = MyBase.CreateItemSettings() ' Instantiate the rest of the fields
' Initialize all objects
End Sub
Public Overrides ReadOnly Property ControlAppearance() As ControlAppearance
Get Return Me._controlAppearance End Get
End Property
Public Overrides ReadOnly Property ListViewSettings() As ListViewSettings
Get Return Me._listViewSettings End Get
End Property
Public Overrides ReadOnly Property ItemSettings() As ItemSettings
Get Return Me._itemSettings End Get
End Property
' Override all other theme properties and return ' the corresponding objects
Private _controlAppearance As ControlAppearance Private _listViewSettings As ListViewSettings Private _itemSettings As ItemSettings ' Declare all other necessary fields
End Class |
All objects that cannot be instantiated directly, such as MonthSettings and ControlStyle can be created by calling various protected methods of the base Theme class. For example, in order to create a MonthSettings object, you need to invoke Theme.CreateMonthSettings.