Shuxia Ning
2024-11-19 6d4be4121ae5995577bb21abe88b79777c64be62
WinFrmUI/HStation.WinFrmUI.PhartRelation.Core/PumpCurveExpandDlg.cs
@@ -5,12 +5,14 @@
        public PumpCurveExpandDlg()
        {
            InitializeComponent();
            this.repTrackBar1.ShowValueToolTip = false;
            this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
        }
        /// <summary>
        /// 回调事件
        /// </summary>
        public event Func<Yw.Geometry.CubicSpline2d, Yw.Geometry.CubicSpline2d, Yw.Geometry.CubicSpline2d, Task<bool>> ReloadDataEvent;
        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;
@@ -60,11 +62,12 @@
        private void barEditTrackBar_EditValueChanged(object sender, EventArgs e)
        {
            if (this.barEditTrackBar.EditValue is not double ratio)
            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;
@@ -74,14 +77,32 @@
        private async void barBtnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (this.barEditTrackBar.EditValue is not double ratio)
            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;
            var result = await this.ReloadDataEvent?.Invoke(qh, qe, qp);
            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.Pump.eFeatType.Cubic, qh_pt_list);
            if (qe != null)
            {
                var qe_pt_list = qe.GetPointList();
                pump_qe = new Yw.Pump.CurveQE(Yw.Pump.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.Pump.eFeatType.Cubic, qp_pt_list);
            }
            var result = await this.ReloadDataEvent?.Invoke(pump_qh, pump_qe, pump_qp);
            if (!result)
            {
                XtraMessageBox.Show("保存失败!");
@@ -95,23 +116,29 @@
        private bool Out(double ratio, out Yw.Geometry.CubicSpline2d qh, out Yw.Geometry.CubicSpline2d qe, out Yw.Geometry.CubicSpline2d qp)
        {
            qh = _qh;
            qe = _qe;
            qp = _qp;
            if (qh == null)
            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)
            if (_qe != null)
            {
                qe = new Yw.Geometry.CubicSpline2d(_qe);
                qe.MaxX = qe.MaxX * ratio / 100;
            }
            if (qp != null)
            if (_qp != null)
            {
                qp = new Yw.Geometry.CubicSpline2d(_qp);
                qp.MaxX = qp.MaxX * ratio / 100;
            }
            return true;
        }
    }
}