lixiaojun
2024-10-29 7c4fde84af5d666236c85b784bf13c9295bcb605
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
using System.Data;
 
namespace Yw.WinFrmUI
{
    public partial class SetHydroCurveCtrl : DevExpress.XtraEditors.XtraUserControl
    {
        public SetHydroCurveCtrl()
        {
            InitializeComponent();
            this.gridView1.SetBindingLimitEditView(25);
            this.gridView1.ShowViewCaption(25);
        }
 
        /// <summary>
        /// 保存曲线信息事件
        /// </summary>
        public event Action<Yw.Model.HydroCurveInfo> SaveCurveInfoEvent;
 
        private Yw.Model.HydroModelInfo _hydroInfo = null;//水力信息
        private Yw.Model.HydroCurveInfo _curveInfo = null;//曲线信息
        private BindingList<HydroCurvePointViewModel> _allBindingList = null;
 
        /// <summary>
        /// 
        /// </summary>
        public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroCurveInfo curveInfo, string curveType)
        {
            if (hydroInfo == null)
            {
                return;
            }
            _hydroInfo = hydroInfo;
            _curveInfo = curveInfo;
            if (_curveInfo == null)
            {
                _curveInfo = new Model.HydroCurveInfo();
                _curveInfo.Catalog = Yw.Hydro.ParterCatalog.Curve;
                _curveInfo.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", _hydroInfo.GetAllParters().Select(x => x.Code).ToList());
                _curveInfo.CurveType = curveType;
            }
            this.txtCode.EditValue = _curveInfo.Code;
            this.txtName.EditValue = _curveInfo.Name;
            this.txtDescription.EditValue = _curveInfo.Description;
            switch (curveType)
            {
                case HydroCurve.TankVol:
                    {
 
                    }
                    break;
                case HydroCurve.PumpQH:
                    {
                        this.txtCurveType.EditValue = "水泵流量扬程曲线";
                        this.colX.Caption = "Q(m³/h)";
                        this.colY.Caption = "H(m)";
                        this.hydroCurveViewCtrl1.TitleTextX = "流量(m³/h)";
                        this.hydroCurveViewCtrl1.TitleTextY = "扬程(m)";
                    }
                    break;
                case HydroCurve.PumpQP:
                    {
                        this.txtCurveType.EditValue = "水泵流量功率曲线";
                        this.colX.Caption = "Q(m³/h)";
                        this.colY.Caption = "P(kW)";
                        this.hydroCurveViewCtrl1.TitleTextX = "流量(m³/h)";
                        this.hydroCurveViewCtrl1.TitleTextY = "功率(kW)";
                    }
                    break;
                case HydroCurve.PumpQE:
                    {
                        this.txtCurveType.EditValue = "水泵流量效率曲线";
                        this.colX.Caption = "Q(m³/h)";
                        this.colY.Caption = "E(%)";
                        this.hydroCurveViewCtrl1.TitleTextX = "流量(m³/h)";
                        this.hydroCurveViewCtrl1.TitleTextY = "效率(%)";
                    }
                    break;
                case HydroCurve.ValveQL:
                    {
                        this.txtCurveType.EditValue = "阀门水头损失曲线";
                        this.colX.Caption = "Q(m³/h)";
                        this.colY.Caption = "H(m)";
                        this.hydroCurveViewCtrl1.TitleTextX = "流量(m³/h)";
                        this.hydroCurveViewCtrl1.TitleTextY = "压力(m)";
                    }
                    break;
                default: break;
            }
            _allBindingList = new BindingList<HydroCurvePointViewModel>();
            _curveInfo.CurveData?.ForEach(x =>
            {
                var pt = new HydroCurvePointViewModel(x.X, x.Y);
                _allBindingList.Add(pt);
            });
            this.hydroCurvePointViewModelBindingSource.DataSource = _allBindingList;
            this.hydroCurvePointViewModelBindingSource.ResetBindings(false);
 
            this.hydroCurveViewCtrl1.SetBindingData(_allBindingList.ToList());
        }
 
        //保存
        private void btnSave_Click(object sender, EventArgs e)
        {
            _curveInfo.Name = this.txtName.Text.Trim();
            _curveInfo.Description = this.txtDescription.Text.Trim();
            _curveInfo.CurveData = _allBindingList?.Select(x => new Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
            this.hydroCurveViewCtrl1.SetBindingData(_allBindingList.ToList());
            this.SaveCurveInfoEvent?.Invoke(_curveInfo);
        }
 
        //删除
        private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
            if (e.RowHandle < 0)
            {
                return;
            }
            if (e.Column == this.colDelete)
            {
                _allBindingList.RemoveAt(e.RowHandle);
            }
        }
 
 
    }
}