C# DevExpress.XtraCharts获取调色板系统默认颜色
C# DevExpress.XtraCharts获取调色板系统默认颜色
C# 全选
using DevExpress.XtraCharts;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CSFrameworkV5.Library.CommonClass
{
public class ChartColorHelper
{
public static List<Color> GetPaleteColors(Palette palete, int maxColorCount = 0)
{
//获取调色板默认颜色
List<Color> colors = new List<Color>();
for (int i = 0; i <= palete.Count - 1; i++)
colors.Add(palete[i].Color);
if (maxColorCount > 0)
{
//C# 获取颜色集合(系统所有的颜色)
List<String> sysColors = GetSystemAllColors();
//随机组合添加更多的颜色
while (colors.Count < maxColorCount)
{
int idx = new Random().Next(0, sysColors.Count - 1);
System.Threading.Thread.Sleep(50);
colors.Add(Color.FromName(sysColors[idx]));
}
}
return colors;
}
/// <summary>
/// C# 获取颜色集合(系统所有的颜色)
/// </summary>
/// <returns></returns>
public static List<String> GetSystemAllColors()
{
List<String> sysColors = new List<string>();
Type ColorCollection = typeof(System.Drawing.KnownColor);
foreach (string colorName in Enum.GetNames(ColorCollection))
{
sysColors.Add(colorName);
}
return sysColors;
}
}
}
默认几个色盘
C# 全选
var colors = new string[] { "Default", "Office 2013", "Marquee", "Pastel Kit", "Red Violet", "Solstice", "Concourse" };
cmbColors.Properties.Items.Clear();
foreach (var c in colors)
cmbColors.Properties.Items.Add(c);
cmbColors.Text = "Marquee";
C# 全选
//调色板
var paleteName = cmbColors.Text;
chartControl1.PaletteName = paleteName;
Palette palete = chartControl1.PaletteRepository[paleteName];
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网