duheng
2024-12-24 ef716332fef142a02843b5a99e8e3e92ab165738
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
133
134
135
136
137
138
139
140
141
142
143
144
namespace HStation.WinFrmUI.PhartRelation
{
    public partial class PumpCurveExpandDlg : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        public PumpCurveExpandDlg()
        {
            InitializeComponent();
            this.repTrackBar1.ShowValueToolTip = false;
            this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
        }
 
        /// <summary>
        /// 回调事件
        /// </summary>
        public event Func<Yw.Pump.CurveQH, Yw.Pump.CurveQE, Yw.Pump.CurveQP, Task<bool>> ReloadDataEvent;
 
        private Yw.Geometry.CubicSpline2d _qh = null;
        private Yw.Geometry.CubicSpline2d _qe = null;
        private Yw.Geometry.CubicSpline2d _qp = null;
 
        /// <summary>
        /// 初始化数据
        /// </summary> 
        public void SetBindingData(
                                    Yw.Pump.CurveQH curve_qh,
                                    Yw.Pump.CurveQE curve_qe,
                                    Yw.Pump.CurveQP curve_qp)
        {
            if (curve_qh == null)
            {
                return;
            }
            Yw.Geometry.CubicSpline2d qh = null, qe = null, qp = null;
 
            qh = new Yw.Geometry.CubicSpline2d(curve_qh.FeatCurve.GetPointList());
            if (curve_qe != null)
                qe = new Yw.Geometry.CubicSpline2d(curve_qe.FeatCurve.GetPointList());
            if (curve_qp != null)
                qp = new Yw.Geometry.CubicSpline2d(curve_qp.FeatCurve.GetPointList());
 
            _qh = qh;
            _qe = qe;
            _qp = qp;
            this.pumpPerformChart1.SetBindingData(qh, qe, qp);
        }
 
 
        /// <summary>
        /// 初始化数据
        /// </summary> 
        public void SetBindingData(Yw.Geometry.CubicSpline2d qh,
                                   Yw.Geometry.CubicSpline2d qe,
                                   Yw.Geometry.CubicSpline2d qp)
        {
 
            _qh = qh;
            _qe = qe;
            _qp = qp;
            this.pumpPerformChart1.SetBindingData(qh, qe, qp);
        }
 
 
        private void barEditTrackBar_EditValueChanged(object sender, EventArgs e)
        {
            if (this.barEditTrackBar.EditValue is not int ratio)
            {
                this.barStaticItem.Caption = $"X%";
                return;
            }
            this.barStaticItem.Caption = $"{ratio}%";
            var bol = Out(ratio, out Yw.Geometry.CubicSpline2d qh, out Yw.Geometry.CubicSpline2d qe, out Yw.Geometry.CubicSpline2d qp);
            if (!bol)
                return;
            this.pumpPerformChart1.SetBindingData(qh, qe, qp);
        }
 
        private async void barBtnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
 
            if (this.barEditTrackBar.EditValue is not int ratio)
            {
                return;
            }
            var bol = Out(ratio, out Yw.Geometry.CubicSpline2d qh, out Yw.Geometry.CubicSpline2d qe, out Yw.Geometry.CubicSpline2d qp);
            if (!bol)
                return;
 
            Yw.Pump.CurveQH pump_qh = null;
            Yw.Pump.CurveQE pump_qe = null;
            Yw.Pump.CurveQP pump_qp = null;
            var qh_pt_list = qh.GetPointList();
            pump_qh = new Yw.Pump.CurveQH(Yw.Ahart.eFeatType.Cubic, qh_pt_list);
            if (qe != null)
            {
                var qe_pt_list = qe.GetPointList();
                pump_qe = new Yw.Pump.CurveQE(Yw.Ahart.eFeatType.Cubic, qe_pt_list);
            }
            if (qp != null)
            {
                var qp_pt_list = qp.GetPointList();
                qp = new Yw.Geometry.CubicSpline2d(qp_pt_list);
                pump_qp = new Yw.Pump.CurveQP(Yw.Ahart.eFeatType.Cubic, qp_pt_list);
            }
 
            var result = await this.ReloadDataEvent?.Invoke(pump_qh, pump_qe, pump_qp);
            if (!result)
            {
                XtraMessageBox.Show("保存失败!");
                return;
            }
 
            XtraMessageBox.Show("保存成功!");
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
 
        private bool Out(double ratio, out Yw.Geometry.CubicSpline2d qh, out Yw.Geometry.CubicSpline2d qe, out Yw.Geometry.CubicSpline2d qp)
        {
            qh = null;
            qe = null;
            qp = null;
            if (_qh == null)
                return false;
            qh = new Yw.Geometry.CubicSpline2d(_qh);
            qh.MaxX = qh.MaxX * ratio / 100;
 
            if (_qe != null)
            {
                qe = new Yw.Geometry.CubicSpline2d(_qe);
                qe.MaxX = qe.MaxX * ratio / 100;
            }
 
            if (_qp != null)
            {
                qp = new Yw.Geometry.CubicSpline2d(_qp);
                qp.MaxX = qp.MaxX * ratio / 100;
            }
 
            return true;
        }
 
 
    }
}