Nevron Open Vision Documentation
User Interface / Widgets / Color Pickers / Palette Color Picker
In This Topic
    Palette Color Picker
    In This Topic

    The palette color picker is a table picker that lets the user pick a color from a predefined palette of colors. The palette to use may be passed as a parameter to the palette color picker constructor or may be assigned to its Palette property. The image below shows a palette color picker that displays the Microsoft Office 2007 palette:

     Properties and Events

    The palette color picker provides the following properties:

    • SelectedColor - represents the currently selected color. When the value of this property changes, the picker automatically tries to find a color in the currently used color palette that is equal to the new value and selects the cell in the color picker that corresponds to it.
    • Palette - defines the color palette used by the palette color picker. NOV provides the following predefined color palettes:
      Palette Description
      WebSafe A palette that contains the Web-safe colors.
      MicrosoftPaint A palette that contains the colors of the default Microsoft Paint palette.
      MicrosoftOffice2003 A palette that contains the colors of the default Microsoft Office 2003 palette.
      MicrosoftOffice2007 A palette that contains the colors of the default Microsoft Office 2007 palette.
      Custom Represents a palette with custom defined colors.

     

     Code Example

    The palette color picker at the beginning of this article can be generated by the following piece of code:

    Palette Color Picker Example
    Copy Code
    NColorPalette palette = new NColorPalette(ENColorPaletteType.MicrosoftOffice2007);
    NPaletteColorPicker colorPicker = new NPaletteColorPicker(palette);
    colorPicker.SelectedColor = NColor.Yellow;
    colorPicker.SelectedIndexChanged += new Function<NValueChangeEventArgs>(OnColorPickerSelectedIndexChanged);
    

    When the user selects a new color from the palette color picker the SelectedIndexChanged event is raised and the value of the picker’s SelectedColor property is updated. The example below shows how you can handle it:

    SelectedIndexedChanged event handler
    Copy Code
    private void OnColorPickerSelectedIndexChanged(NValueChangeEventArgs arg1)
    {
        // Get the palette color picker, whose selected color has changed
        NPaletteColorPicker colorPicker = (NPaletteColorPicker)arg1.CurrentTargetNode;
    
        // Get the selected color
        NColor selectedColor = colorPicker.SelectedColor;
    }
    
    See Also