我正在尝试自定义DevExpress MVC仪表板的外观。我想创建一个要使用的自定义调色板。目前,我可以通过以下代码更改仪表板的配色方案,但我想自定义默认调色板。
//Set color scheme of dashboard
ASPxWebClientUIControl.GlobalColorScheme = "dark";
还根据DevExpress Documentation,可以使用以下事件自定义调色板。
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;
}
答案 0 :(得分:0)
这可以通过以下方式完成。
将以下代码添加到Global.asax.cs的Application_Start()
DashboardConfigurator.Default.CustomPalette += new CustomPaletteWebEventHandler(this.OnMyEvent);
将以下事件处理程序添加到Global.asax.cs
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;
}