lixiaojun
2024-12-02 f460fd2c628ab56db7450d70f3b7ad4b3524e6c8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
namespace Yw.WinFrmUI
{
    /// <summary>
    /// 
    /// </summary>
    public class HydroPumpCurveColorHelper
    {
        //缓存
        private static List<Color> _cache = new List<Color>()
        {
            Color.Red, Color.Blue, Color.Green,Color.DodgerBlue,
            Color.Fuchsia, Color.MidnightBlue,  Color.Maroon, Color.Aquamarine,
            Color.Bisque,Color.BurlyWood
        };
 
        /// <summary>
        /// 获取随机颜色
        /// </summary>
        public static Color GetRandomColor(int index)
        {
            if (index <= _cache.Count - 1)
            {
                return _cache[index];
            }
            var random = new Random();
            int r = random.Next(1, 256);
            int g = random.Next(1, 256);
            int b = random.Next(1, 256);
            return Color.FromArgb(r, g, b);
        }
 
 
 
    }
}