cloudflight
2024-06-10 4db7d08bb295be33e80f1353f58fcea4a8da6127
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
using Hydro.CommonBase;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Hydro.MapView
{
    [Serializable]
    public class MapOption
    {
        public float Link_multiply { get; set; } = 0.6667f;
        public float junction_multiply { get; set; } = 1f;
        public bool _ShowValve { get; set; } = true;
        public bool _ShowJunction { get; set; } = true;
 
        public bool _ShowStatus { get; set; } = false;
 
        public bool _ShowFlowDirection { get; set; } = false;
 
        
    }
    [Serializable]
    public class Colour
    {
        public string Name { get; set; }
        public ColourType Type { get; set; }
        public List<ColourItem> 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<ColourItem> value=null, string name =null)
        {
            Name =name;
            Type = type;
            Items = value;
            if (Items == null) Items = new List<ColourItem>();
            if (Name==null) Name= type.ToString();
        }
        public override string ToString()
        {
            return Name;
        }
 
        public static List<ColourItem> GetColourItems(float minValue, float maxValue, int ColourNum, Color color0, Color color1)
        {
            var colourItems = new List<ColourItem>();
            for (int i = 0; i < ColourNum; i++)
            {
                DRange currentRange = new DRange(minValue + i * (maxValue - minValue) / ColourNum, minValue + (i + 1) * (maxValue - minValue) / ColourNum);
                Color c;
                //获取color0和color1,Colour个等分颜色,第一个为color0,最后一个为color1,中间的为等分颜色
                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;
    }
    [Serializable]
    public class ColourItem
    {
        public DRange DRange { get; set; }=new DRange();
        public Color value;
        public ColourItem(DRange dRange, Color value)
        {
            DRange = dRange;
            this.value = value;
        }
        public ColourItem()
        {
        }
        public ColourItem(ColourItem item)
        {
            this.DRange = item.DRange;
            this.value = item.value;    
        }
        public override string ToString()
        {
            return DRange.ToString();
        }
    }
    public enum ColourType
    {
        无=0,
        节点自由压力=1,
        节点绝对压力=2,
        节点需水量=3,
        管线流量=4,
        管线流速=5
    }
}