更改 DevExpress MVC 仪表板默认调色板
Change the DevExpress MVC Dashboard Default color palette
我正在尝试自定义 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
}
}
}
我的调色板配置class
public class ColorPaletteConfig
{
public event CustomPaletteEventHandler CustomPalette;
}
这可以通过以下方式完成。
将以下代码添加到 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;
}
我正在尝试自定义 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
}
}
}
我的调色板配置class
public class ColorPaletteConfig
{
public event CustomPaletteEventHandler CustomPalette;
}
这可以通过以下方式完成。
将以下代码添加到 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;
}