duheng
2024-12-05 580201d86a324677a1d64a87c7ff79dceb27a58e
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
using Yw.WinFrmUI.Phart;
 
namespace HStation.WinFrmUI.PhartRelation
{
    public partial class PumpWorkChartDlg : XtraForm
    {
        public PumpWorkChartDlg()
        {
            InitializeComponent();
            this.Text = "曲线视图";
            this.WindowState = FormWindowState.Maximized; 
            this.pumpWorkingChart.LineVisible = true;
        }
 
 
        // <summary>
        /// 设置
        /// </summary>  
        public string SetBindingData(Yw.WinFrmUI.Phart.PumpWorkViewModel work_vm)
        {
            if (work_vm == null)
            {
                return "数据为空!";
            } 
 
            var vm = new Yw.WinFrmUI.Phart.PumpWorkInfoViewModel(work_vm);
            vm.Name = $"{vm.CurrentSpeed}({vm.CurrentHz}hz)";
            vm.Color = GetRandomColor(0);
            vm.Calc();   
            this.pumpWorkingChart.Add(vm);
            return string.Empty;
        }
 
        #region Color
 
        private List<Color> _color_array = 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>
        /// <returns></returns>
        private Color GetRandomColor(int count)
        {
            if (count < _color_array.Count)
            {
                return _color_array[count];
            }
 
            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);
        }
 
        #endregion
    }
}