namespace HydroUI { [Serializable] public class Colour { public string Name { get; set; } public ColourType Type { get; set; } public List Items { get; set; } public bool isNode { get { if (Type == ColourType.节点自由压力 || Type == ColourType.节点需水量) { return true; } else { return false; } } } public bool isChoosed { get; set; } = false; public float minNum = 0; public float maxNum = 50; public int ColourCount = 5; public Color color0 = Color.Red; public Color color1 = Color.Blue; public Colour(ColourType type = ColourType.节点自由压力, List value = null, string name = null) { Name = name; Type = type; Items = value; if (Items == null) Items = new List(); if (Name == null) Name = type.ToString(); } public override string ToString() { return Name; } public static List GetColourItems(float minValue, float maxValue, int ColourNum, Color color0, Color color1) { var colourItems = new List(); for (int i = 0; i < ColourNum; i++) { DRange currentRange = new DRange(minValue + i * (maxValue - minValue) / ColourNum, minValue + (i + 1) * (maxValue - minValue) / ColourNum); Color c; if (i == 0) { c = color0; } else if (i == ColourNum - 1) { c = color1; } else { c = Color.FromArgb(color0.R + (color1.R - color0.R) / (ColourNum - 1) * i, color0.G + (color1.G - color0.G) / (ColourNum - 1) * i, color0.B + (color1.B - color0.B) / (ColourNum - 1) * i); } ColourItem newFloor = new ColourItem(currentRange, c); colourItems.Add(newFloor); } return colourItems; } public static int NodeTypeCount = 3; } }