User Interface for .NET / User's Guide / Palettes / Using Palettes

In This Topic
    Using Palettes
    In This Topic
     Overview
    Nevron palettes provide the main render information about how an object is visualized. A NPalette object supports a great level of customization, has intuitive behaviour and can easily be persisted.
     Customizing Palette

    A NPalette object exposes lots of different color values used by various controls to render parts of them. For example, a NProgressBar uses ControlLight color to draw its background and PressedDark to render its progress area. A NToolbar uses ControlLight and ControlDark to create a gradient for its background.

     

    The following example demonstrates customizing features of a palette:

     

    • ColorScheme - Nevron User Interface ships with 27 predefined color schemes:
      C#
      Copy Code
      this.nButton1.Palette.Scheme = ColorScheme.LunaBlue;
      
      Visual Basic
      Copy Code
      Me.nButton1.Palette.Scheme = ColorScheme.LunaBlue
      
      Using ColorScheme.Custom works in the following way: If there is a custom color specified for the respective property, it is used. Otherwise, the last used color is applied. So, specifying custom color scheme will have no effect if custom colors are not specified.
    • Changing a specific color value - You can change a single color in the current scheme:
      C#
      Copy Code
      this.nCheckBox1.HighlightLight = Color.Yellow;
      
      Visual Basic
      Copy Code
      Me.nCheckBox1.HighlightLight = Color.Yellow
      
      Changing a color value will automatically set the color scheme to ColorScheme.Custom
    • Changing the entire color table:
      C#
      Copy Code
      this.nPanelBar1.Palette.SetColorTable(myColorTable);
      
      Visual Basic
      Copy Code
      Me.nPanelBar1.Palette.SetColorTable(myColorTable)
      
      The specified color table must be fully assigned (default colors are initially set to Color.Empty).
    • Changing the 3D-style - this value is used when drawing borders:
      C#
      Copy Code
      this.nProgressBar1.Palette.Style3D = Style3D.Light3D;
      
      Visual Basic
      Copy Code
      Me.nProgressBar1.Palette.Style3D = Style3D.Light3D
      
    • Specifying whether a renderer should use system themes if the current color scheme is ColorScheme.WindowsDefault:
      C#
      Copy Code
      this.nTabControl1.Palette.UseThemes = false;
      
      Visual Basic
      Copy Code
      Me.nTabControl1.Palette.UseThemes = False
      
     Palette Inheritance

    The NPalette object provides an extensible way for preserving some settings discarding the current global ones. For example, if you want to have a certain button that will always have 3D-style Style3D.Flat - you can achieve this via the PaletteInheritance property.

     

    Following is a list of the flags in this enumeration:

     

    • All (default) - when the palette is forced to update itself from any other one it will copy the entire state from the new palette.
    • None - all changes are discarded.
    • ColorTable - only color values are copied.
    • Style3D - only Style3D value is copied, other settings are preserved.
    • UseThemes - only UseThemes value is copied, other settings are preserved.

     

    The Suite provides a convenient visual editor to be used both at design and run-time to edit the inheritance of a palette:

     

    These flags work when a palette object is forced to update itself from another one (for example when the NUIManager is updating the entire GUI). If you change a property directly, the change will be accepted regardless of the PaletteInheritance value.

    The following example demonstrates how to preserve the 3D-style of a INPaletteProvider:

    C#
    Copy Code
    this.nRadioButton1.Palette.Inheritance = PaletteInheritance.ColorTable | PaletteInheritance.UseThemes;
    
    Visual Basic
    Copy Code
    Me.nRadioButton1.Palette.Inheritance = PaletteInheritance.ColorTable Or PaletteInheritance.UseThemes
    
     Using The Visual Editor

    The NPalette object provides an advanced visual editor available at both design and run time, which provides rich support in editing and customizing its properties.

     

    The NPalette object provides powerful and intuitive visual editor to edit its properties.

     

    The editor can also be triggered from code via the ShowEditor method of the NPalette object. Use the combo box at the top-left corner of the editor to choose a predefined ColorScheme. Or select a color property, edit it using the color picker on the right and press the "Apply Color" button to confirm editing. Confirm palette change by pressing the "OK" button or cancel it using the "Cancel" button. Restore default palette settings using the "Default" button. Use the "Save" button to save a current state of the palette to a file or use the "Load" button to load previously saved palette.

    See Also