duheng
2024-10-22 36c4ee4f56763ba96d37ff9f89bbf9440fb8be9f
WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-pump/PumpFullInfoViewDlg.cs
@@ -1,12 +1,11 @@
using DevExpress.XtraBars;
using HStation.WinFrmUI.PhartRelation;
using Yw.WinFrmUI.Phart;
namespace HStation.WinFrmUI
{
    public partial class PumpFullInfoViewDlg : XtraForm
    {
        private bool _isMaxWindowStatus = true;//最大化窗体覆盖任务栏
        private PumpFullInfoCtrl thePumpCtrl = null;
        #region 构造
        public PumpFullInfoViewDlg()
@@ -21,6 +20,12 @@
            this.bsiPromptInfo.Caption = "";
        }
        private Vmo.XhsPumpMainPhartMappingExtensions _xhs_phart_diagram_ex_std_dto = null;
        private readonly BLL.XhsPumpMainPhartMappingExtensions _bll_ex = new();
        private bool _isMaxWindowStatus = true;//最大化窗体覆盖任务栏
        private PumpFullInfoCtrl thePumpCtrl = null;
        private void OnFrmLoad(object sender, EventArgs e)
        {
            //手机页面
@@ -34,11 +39,28 @@
        private event Action<PumpMatchingViewModel> ReloadDataEvent;
        public void SetBindindData(PumpMatchingViewModel pumpMatchingViewModel)
        private long _PumpId;
        public async void SetBindindData(PumpMatchingViewModel pumpMatchingViewModel)
        {
            _pumpMatchingView = pumpMatchingViewModel;
            this.navBtnTitle.Caption = $"泵型号:{pumpMatchingViewModel.ModelType}";
            pumpFullInfoCtrl1.SetBindingData(pumpMatchingViewModel);
            if (long.TryParse(pumpMatchingViewModel.DbId, out long pumpId))
            {
                _PumpId = pumpId;
            }
            var list = await _bll_ex.GetByPumpMainID(_PumpId);
            if (list != null && list.Any())
            {
                //list= list.OrderBy(x => x.Importance).ToList();
                /*      foreach (var item in list)
                      {
                          var vm = new CurrentViewModel(item);
                          _allBindingList.Add(vm);
                      }*/
                _xhs_phart_diagram_ex_std_dto = list.First();
            }
        }
        private void OnFrmShown(object sender, EventArgs e)
@@ -341,5 +363,82 @@
            };
            dlg.ShowDialog();
        }
        private void navBtnEdit_ElementClick(object sender, DevExpress.XtraBars.Navigation.NavElementEventArgs e)
        {
            this.popupMenuEdit.ShowPopup(MousePosition);
        }
        //表格编辑
        private void BarButtonItem1_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (_xhs_phart_diagram_ex_std_dto == null)
            {
                return;
            }
            var diagram = _xhs_phart_diagram_ex_std_dto.Diagram;
            if (diagram == null)
            {
                return;
            }
            var graph_list = diagram.GraphList;
            if (graph_list == null || !graph_list.Any())
            {
                return;
            }
            var graph_qh = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQH);
            var graph_qe = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQE);
            var graph_qp = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQP);
            if (graph_qh == null)
            {
                return;
            }
            Yw.Pump.CurveQH qh = null;
            Yw.Pump.CurveQE qe = null;
            Yw.Pump.CurveQP qp = null;
            List<Yw.Geometry.Point2d> points_qh = null, points_qe = null, points_qp = null;
            points_qh = PhartPerformCurveHelper.GetFeatPointList(graph_qh.GraphType, graph_qh.GeometryInfo, 12, null);
            qh = new Yw.Pump.CurveQH(Yw.Pump.eFeatType.Cubic, points_qh);
            if (graph_qe != null)
            {
                points_qe = PhartPerformCurveHelper.GetFeatPointList(graph_qe.GraphType, graph_qe.GeometryInfo, 12, null);
                qe = new Yw.Pump.CurveQE(Yw.Pump.eFeatType.Cubic, points_qe);
            }
            if (graph_qp != null)
            {
                points_qp = PhartPerformCurveHelper.GetFeatPointList(graph_qp.GraphType, graph_qp.GeometryInfo, 12, null);
                qp = new Yw.Pump.CurveQP(Yw.Pump.eFeatType.Cubic, points_qp);
            }
            var dlg = new Yw.WinFrmUI.Phart.PumpPerform2dEditDlg();
            dlg.SetBindingData(qh, qe, qp);
            dlg.ReloadDataEvent += async (new_qh, new_qe, new_qp) =>
            {
                var new_points_qh = new_qh.GetPointList();
                var new_points_qe = new_qe.GetPointList();
                var new_points_qp = new_qp.GetPointList();
                graph_qh.GeometryInfo = new Yw.Pump.CurveQH(Yw.Pump.eFeatType.Cubic, new_points_qh).ToDbString();
                graph_qe.GeometryInfo = new Yw.Pump.CurveQE(Yw.Pump.eFeatType.Cubic, new_points_qe).ToDbString();
                graph_qp.GeometryInfo = new Yw.Pump.CurveQP(Yw.Pump.eFeatType.Cubic, new_points_qp).ToDbString();
                _xhs_phart_diagram_ex_std_dto.Diagram.GraphList = new List<Vmo.PhartGraph>()
                {
                    graph_qh,
                    graph_qe,
                    graph_qp,
                };
                var bol = await _bll_ex.Update(_xhs_phart_diagram_ex_std_dto);
                if (bol)
                {
                   // var pump_main = await new BLL.AssetsPumpMain().GetByID(_PumpId);
                    //    this.pumpFullInfoCtrl1.InitChart(_pump_main, _xhs_phart_diagram_ex_std_dto);
                }
                return bol;
            };
            dlg.ShowDialog();
        }
    }
}