更改DevExpress MVC仪表板的默认调色板

更改DevExpress MVC仪表板的默认调色板,devexpress,dashboard,devexpress-mvc,Devexpress,Dashboard,Devexpress Mvc,我正在尝试自定义DevExpress MVC仪表板的外观。我想创建一个要使用的自定义调色板。目前,我可以通过以下代码更改仪表板颜色方案,但我想自定义默认调色板 //Set color scheme of dashboard ASPxWebClientUIControl.GlobalColorScheme = "dark"; 另外,根据,可以使用以下事件自定义调色板 public event CustomPaletteWebEventHandler CustomPalette 如何实现这一点?

我正在尝试自定义DevExpress MVC仪表板的外观。我想创建一个要使用的自定义调色板。目前,我可以通过以下代码更改仪表板颜色方案,但我想自定义默认调色板

//Set color scheme of dashboard
ASPxWebClientUIControl.GlobalColorScheme = "dark";
另外,根据,可以使用以下事件自定义调色板

public event CustomPaletteWebEventHandler CustomPalette
如何实现这一点?我在Global.asax.cs中添加了以下代码,但新图表的调色板没有改变

namespace Analytics {

public class MvcApplication : System.Web.HttpApplication {


    protected void Application_Start() {
        DashboardConfig.RegisterService(RouteTable.Routes);



        ColorPaletteConfig cpc = new ColorPaletteConfig();
        cpc.CustomPalette += new CustomPaletteEventHandler(this.OnMyEvent);

    }

    private void OnMyEvent(object sender, CustomPaletteEventArgs e)
    {
        //Set value to e.Palette =
        Color[] colors = { Color.AliceBlue, Color.BlueViolet, Color.DarkBlue};
        DashboardPalette p = new DashboardPalette(colors);

        e.Palette = p;
    }

    protected void Application_Error(object sender, EventArgs e) {
        Exception exception = System.Web.HttpContext.Current.Server.GetLastError();
        //TODO: Handle Exception
    }
}
}
我的ColorPaletteConfig类

public class ColorPaletteConfig
{
    public event CustomPaletteEventHandler CustomPalette;

}

这可以通过以下方式完成

将以下代码添加到Global.asax.cs的应用程序_Start

DashboardConfigurator.Default.CustomPalette += new CustomPaletteWebEventHandler(this.OnMyEvent);
    protected void OnMyEvent(object sender, CustomPaletteWebEventArgs e)
    {

        List<Color> customColors = new List<Color>();
        customColors.Add(System.Drawing.ColorTranslator.FromHtml("#17a2b8"));
        customColors.Add(System.Drawing.ColorTranslator.FromHtml("#20c997"));
        customColors.Add(System.Drawing.ColorTranslator.FromHtml("#28a745"));
        customColors.Add(System.Drawing.ColorTranslator.FromHtml("#6610f2"));
        customColors.Add(System.Drawing.ColorTranslator.FromHtml("#6f42c1"));
        customColors.Add(System.Drawing.ColorTranslator.FromHtml("#dc3545"));
        DashboardPalette p = new DashboardPalette(customColors);
        e.Palette = p;
    }
将以下事件处理程序添加到Global.asax.cs

DashboardConfigurator.Default.CustomPalette += new CustomPaletteWebEventHandler(this.OnMyEvent);
    protected void OnMyEvent(object sender, CustomPaletteWebEventArgs e)
    {

        List<Color> customColors = new List<Color>();
        customColors.Add(System.Drawing.ColorTranslator.FromHtml("#17a2b8"));
        customColors.Add(System.Drawing.ColorTranslator.FromHtml("#20c997"));
        customColors.Add(System.Drawing.ColorTranslator.FromHtml("#28a745"));
        customColors.Add(System.Drawing.ColorTranslator.FromHtml("#6610f2"));
        customColors.Add(System.Drawing.ColorTranslator.FromHtml("#6f42c1"));
        customColors.Add(System.Drawing.ColorTranslator.FromHtml("#dc3545"));
        DashboardPalette p = new DashboardPalette(customColors);
        e.Palette = p;
    }