【问题标题】:Change the DevExpress MVC Dashboard Default color palette更改 DevExpress MVC 仪表板默认调色板
【发布时间】:2019-07-02 05:34:00
【问题描述】:

我正在尝试自定义 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;

}

【问题讨论】:

    标签: devexpress dashboard devexpress-mvc


    【解决方案1】:

    这可以通过以下方式完成。

    将以下代码添加到 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;
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多