User Interface for .NET / User's Guide / UI Manager

UI Manager
 Overview

Nevron User Interface exposes a top-level static class which is responsible for keeping the entire GUI synchronized. It exposes a global NPalette object and automatically updates the application GUI when this palette has changed or the user has changed a setting on its machine. It also keeps track of some global components such as NCommandBarsManager and NDockManager and updates their appearance as well.

The NUIManager gives you access to all pop-up windows (not parented by any other one) and the main active window of the application.

 Global UI Update

Updating flows in the following way:

 

The UI Manager gets all top-level (pop-up) windows and recursively loops through all their children controls. It checks whether a control implements INPaletteProvider interface and if so calls the ApplyPalette method exposed by this interface and does not dig further on in control's children. Otherwise the control's BackColor and ForeColor are updated using the current Control and ControlText values of the global palette and searches down in the children controls.

 

When the update is automatic (the palette or a user preference has changed), the current manager's palette is used.

 

The following examples demonstrate different ways to update the entire application UI:

C#
Copy Code
NUIManager.Palette.Scheme = ColorScheme.LunaBlue;
Visual Basic
Copy Code
NUIManager.Palette.Scheme = ColorScheme.LunaBlue

or

C#
Copy Code
NPalette palette = new NUIPalette();
palette.Style3D = Style3D.Light3D;
palette.Scheme = ColorScheme.WindowsDefault;
palette.UseThemes = false;

//assign the newly created palette as a global one
NUIManager.Palette = palette;
Visual Basic
Copy Code
Dim palette As NPalette = New NUIPalette()
palette.Style3D = Style3D.Light3D
palette.Scheme = ColorScheme.WindowsDefault
palette.UseThemes = False

'assign the newly created palette as a global one
NUIManager.Palette = palette

or

C#
Copy Code
//update the application with the current manager's palette
NUIManager.ApplyPalette();

//update specific control only
NUIManager.ApplyPalette(this.nTabControl1);

//update specific control with a specified palette
NPalette palette = new NUIPalette();
palette.ColorScheme = ColorScheme.Energy;
NUIManager.ApplyPalette(this.nTabControl1, palette);
Visual Basic
Copy Code
'update the application with the current manager's palette
NUIManager.ApplyPalette()

'update specific control only
NUIManager.ApplyPalette(Me.nTabControl1)

'update specific control with a specified palette
Dim palette NPalette = New NUIPalette()
palette.ColorScheme = ColorScheme.Energy
NUIManager.ApplyPalette(Me.nTabControl1, palette)
In the first case the update will occur if the current manager's palette has changed in some aspect.
 Registering Global Component

As some component that implements INPaletteProvider might not be a control, it should be registered to the global components collection of the UI Manager in order for its palette to be properly updated. When the manager updates the entire GUI it searches in the collection for such components and updates their palettes too. Currently, NCommandBarsManager and NDockManager objects are registered as global components.

 

The following example demonstrates how to use this feature:

C#
Copy Code
public class A : Component
{
    public A()
    {
  NUIManager.RegisterComponent(this);
    }

    //do not forget to unregister when disposed
    protected override Dispose(bool disposing)
    {
  if(disposing)
  {
       NUIManager.UnregisterComponent(this);
  }
  
  base.Dispose(disposing);
    }
}
Visual Basic
Copy Code
Public class A 
    Inherits Component
    Public Sub New()
        NUIManager.RegisterComponent(Me)
    End Sub

    'do not forget to unregister when disposed
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)    
        If disposing Then  
            NUIManager.UnregisterComponent(Me)
        End If  
        MyBase.Dispose(disposing)
    End Sub
End Class
 Tracking Main Window And Popup Windows

The NUIManager keeps track of the application's main window. That is the active form (or foreground window).

C#
Copy Code
Control mainWindow = NUIManager.MainWindow;
Visual Basic
Copy Code
Dim mainWindow As Control = NUIManager.MainWindow

The manager can also get all the popup windows in a thread:

C#
Copy Code
Control[] popUps = NUIManager.PopupWindows;
Visual Basic
Copy Code
Dim popUps() As Control = NUIManager.PopupWindows

Suppose you have a complicated application with some tool windows owned by the main form, and another 2 forms, the first modally dependant on the main one and the second modally dependant on the first. Calling PopupWindows will return all the currently visible forms, including the main one.

 Global Menu Options

The UI Manager controls yet another part of the entire look-and-feel of an application. It holds a NGlobalMenuOptions object, responsible for common menu properties like animation - length and type, shadow - visibility, color, alpha and offset.

 

As menu windows in Nevron Command Bars are entirely custom, you have full control over their appearance and visualization. For more information about customizing menus see Extending Commands.

 The NUIManagerController Component

The NUIManager is a singleton class which contains global user interface settings like palette, frame appearance, menu options, etc. The NUIManagerController class derives from System.ComponentModel.Component and is available in the Visual Studio Toolbox.

To use this component simply drop a NUIManagerController instance on a Form (or UserControl) and change its properties. You may have multiple instances of the controller component; each one however will operate on the NUIManager class.

See Also