Back to Devexpress

IColorSchemeStorage Interface

xtrareports-devexpress-dot-xtrareports-dot-wizards-dot-colorschemes-ff6bd75c.md

latest5.6 KB
Original Source

IColorSchemeStorage Interface

If implemented, enables you to create a custom color scheme storage in WinForms and WPF applications.

Namespace : DevExpress.XtraReports.Wizards.ColorSchemes

Assembly : DevExpress.XtraReports.v25.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
public interface IColorSchemeStorage
vb
Public Interface IColorSchemeStorage

Remarks

Tip

Online Example :

This code sample demonstrates how to create a custom color scheme storage and add new color schemes to it.

csharp
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using DevExpress.XtraReports.Wizards;
using DevExpress.XtraReports.Wizards.ColorSchemes;
//...
class CustomColorSchemeStorage : IColorSchemeStorage {

    readonly List<ColorScheme> colorSchemes = new List<ColorScheme>();

    public CustomColorSchemeStorage() {
        //Add custom color schemes to the storage.
        AddColorScheme(new ColorScheme("Independence", System.Drawing.Color.FromArgb(80, 75, 102)));
        AddColorScheme(new ColorScheme("Cerulean",
            System.Drawing.Color.FromArgb(0, 109, 167),
            System.Drawing.Color.FromArgb(0, 48, 65),
            System.Drawing.Color.FromArgb(0, 151, 167),
            System.Drawing.Color.FromArgb(205, 232, 242),
            System.Drawing.Color.FromArgb(255, 243, 245, 248),
            System.Drawing.Color.FromArgb(255, 109, 117, 129),
            System.Drawing.Color.FromArgb(255, 182, 186, 192)));
    }

    public bool AddColorScheme(ColorScheme colorScheme) {
        if(colorSchemes.Where(x => x.Name == colorScheme.Name).Any())
            return false;
        colorSchemes.Add(colorScheme);
        return true;
    }

    public bool RemoveColorScheme(string colorSchemeName) {
        ColorScheme colorScheme = colorSchemes.Where(x => x.Name == colorSchemeName).First();
        if(colorScheme != null) {
            colorSchemes.Remove(colorScheme);
            return true;
        }
        return false;
    }

    IEnumerable<ColorScheme> IColorSchemeStorage.GetColorSchemes() {
        return colorSchemes;
    }
}
//...
vb
Imports System.Collections.Generic
Imports System.ComponentModel.Design
Imports System.Linq
Imports DevExpress.XtraReports.Wizards
Imports DevExpress.XtraReports.Wizards.ColorSchemes
'...
Friend Class CustomColorSchemeStorage
    Implements IColorSchemeStorage

    Private ReadOnly colorSchemes As New List(Of ColorScheme)()

  Public Sub New()
        'Add custom color schemes to the storage.
        AddColorScheme(New ColorScheme("Independence", System.Drawing.Color.FromArgb(80, 75, 102)))
        AddColorScheme(New ColorScheme("Cerulean", 
      System.Drawing.Color.FromArgb(0, 109, 167), 
      System.Drawing.Color.FromArgb(0, 48, 65), 
      System.Drawing.Color.FromArgb(0, 151, 167), 
      System.Drawing.Color.FromArgb(205, 232, 242), System.Drawing.Color.FromArgb(255, 243, 245, 248), System.Drawing.Color.FromArgb(255, 109, 117, 129), System.Drawing.Color.FromArgb(255, 182, 186, 192)))
    End Sub

  Public Function AddColorScheme(ByVal colorScheme As ColorScheme) As Boolean
        If colorSchemes.Where(Function(x) x.Name = colorScheme.Name).Any() Then
            Return False
        End If
        colorSchemes.Add(colorScheme)
        Return True
    End Function

  Public Function RemoveColorScheme(ByVal colorSchemeName As String) As Boolean
        Dim colorScheme As ColorScheme = colorSchemes.Where(Function(x) x.Name = colorSchemeName).First()
        If colorScheme IsNot Nothing Then
            colorSchemes.Remove(colorScheme)
            Return True
        End If
        Return False
    End Function

  Private Function IColorSchemeStorage_GetColorSchemes() As IEnumerable(Of ColorScheme) Implements IColorSchemeStorage.GetColorSchemes
        Return colorSchemes
    End Function
End Class
'...

Implement the IWizardCustomizationService interface to register the created custom color scheme storage. Use one of the following code samples depending on the target platform:

  • WinForms

  • WPF

Apply the wizard customization logic to the End-User Report Designer.

  • WinForms

  • WPF

See Also

IColorSchemeStorage Members

Wizard Customization Overview (WinForms)

Wizard Customization Overview (WPF)

DevExpress.XtraReports.Wizards.ColorSchemes Namespace