Applies to: Nevron User Interface for .NET
How to synchronize the look-and-feel of the entire GUI?
The Nevron User Interface appearance has two levels of priority:
1. Skinning – if the NSkinManager is enabled (a valid NSkin instance is loaded) it will have the highest priority when the appearance of a GUI element is determined. If the current skin does not contain an entry which describes the required element’s state the default palette-based logic will be used. In order to explicitly specify that a control should not use the current skin use the following code:
this.<INSkinnableControl instance>.EnableSkinning = false;
Remarks:
When skinning is enabled you do not need to manually perform additional synchronization code – each control will update its appearance dynamically. The NFrameAppearance template for each NForm is provided by the current skin. The global palette is also retrieved from the skin.
For more information about loading a valid NSkin see the following KB topic: How to load and apply a predefined Nevron skin
2. Palette-based appearance – this is the default appearance logic used by Nevron User Interface components when the NSkinManager is not enabled. In this case the GUI managing class is the NUIManager static one which provides global NPalette, NFrameAppearance and NGlobalMenuOptions properties. Whenever a change in one of these occurs the manager will notify all available GUI components about the change and force them reflect the changes.
By default each INPaletteProvider control (when created) will synchronize its local palette with the global one provided by the static NUIManager class. Sometimes you will need to dynamically apply palette from one control to another – in this case use the ApplyPalette method of the NUIManager. It will recursively update either the entire GUI with the global palette or a specific control (and optionally its children) with a specific palette. The following code demonstrates how to dynamically apply custom palette to a NForm instance:
[C#]
using
System;
using
System.Drawing;
using
Nevron.UI.WinForm.Controls;
...
//create a NForm instance
NForm myForm =
new
NForm();
//hook to the "Load" event of the form
myForm.Load +=
new
EventHandler(OnMyFormLoad);
myForm.ShowDialog();
private
void
OnMyFormLoad(
object
sender, EventArgs e)
{
//create a custom palette
NPalette palette =
new
NUIPalette();
palette.Control = Color.Gray;
palette.ControlText = Color.White;
//apply the palette
NUIManager.ApplyPalette((NForm)sender, palette);
}
[VB.NET]
Imports
System
Imports
System.Drawing
Imports
Nevron.UI.WinForm.Controls
...
'create a NForm instance
Dim
myForm
As
New
NForm()
'hook to the "Load" event of the form
myForm.Load +=
New
EventHandler(OnMyFormLoad)
myForm.ShowDialog()
Private
Sub
OnMyFormLoad(sender
As
Object
, e
As
EventArgs)
'create a custom palette
Dim
palette
As
NPalette =
New
NUIPalette()
palette.Control = Color.Gray
palette.ControlText = Color.White
'apply the palette
NUIManager.ApplyPalette(
DirectCast
(sender, NForm), palette)
End
Sub
Remarks:
You may use this technique to dynamically load custom palette on each form and/or control. The palette is applied in the "Load" event which ensures that all children of the form are created. By default the form will listen for any changes in its local Palette and will perform the same logic if you specify this:
NForm form = new NForm();
form.Palette.Scheme = ColorScheme.LunaBlue;
The NFrameAppearance template which defines the look-and-feel of a NForm border is retrieved by default from the NUIManager. In order to override the global one you may either assign a local NFrameAppearance to an NForm instance or modify the "UseGlobalTemplate" property accordingly.
Article ID: 91, Created On: 10/13/2010, Modified: 12/1/2010