lixiaojun
2025-01-24 7b65f86343ca014b12894f09b7d62e8b5ac1f95d
WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-pump/PumpFullInfoViewDlg.cs
@@ -1,51 +1,65 @@
using DevExpress.XtraBars;
using HStation.WinFrmUI.PhartRelation;
namespace HStation.WinFrmUI
{
    public partial class DetailInfo4DsDlg : XtraForm
    public partial class PumpFullInfoViewDlg : XtraForm
    {
        private bool _isMaxWindowStatus = true;//最大化窗体覆盖任务栏
        private PumpFullInfoCtrl thePumpCtrl = null;
        #region 构造
        public DetailInfo4DsDlg()
        public PumpFullInfoViewDlg()
        {
            InitializeComponent();
            this._isMaxWindowStatus = true;//最大化窗体覆盖任务栏
            this.navBtnMin.Visible = this.navBtnSize.Visible = this.navBtnClose.Visible = false;
            this.navBtnMin.ElementClick += new DevExpress.XtraBars.Navigation.NavElementClickEventHandler(this.navBtnMin_ElementClick);
            this.navBtnSize.ElementClick += new DevExpress.XtraBars.Navigation.NavElementClickEventHandler(this.navBtnSize_ElementClick);
            this.navBtnClose.ElementClick += new DevExpress.XtraBars.Navigation.NavElementClickEventHandler(this.navBtnClose_ElementClick);
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OnFrmClosing);
            this.Load += new System.EventHandler(this.OnFrmLoad);
            this.Shown += new System.EventHandler(this.OnFrmShown);
            this.bbi下载BIM文件.Visibility = BarItemVisibility.Never;
            this.bsiPromptInfo.Caption = "";
            this.bsiPromptInfo.Caption = "";
            this.navBtn手机页面.Visible = false;
            thePumpCtrl = new PumpFullInfoCtrl();
            thePumpCtrl.Name = "PumpFullInfoCtrl";
            thePumpCtrl.Dock = DockStyle.Fill;
            this.panelMain.Controls.Add(thePumpCtrl);
        }
        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)
        {
            //手机页面
            navBtn手机页面.Visible = false;
            //bbi添加串并联.Visibility = BarItemVisibility.Never;//功能没有完成
            LocationDialog();
            SetNavTileControlMoveAble();
            this.SetMaxWindowStatus();
        }
        private PumpMatchingViewModel _pumpMatchingView;
        public event Action<PumpMatchingViewModel> ReloadDataEvent;
        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)
@@ -67,8 +81,7 @@
        //窗体尺寸:注意默认是不显示的
        public void IsDispBtn窗体尺寸(bool isDisp)
        {
            navBtnMin.Visible = navBtnSize.Visible = navBtnClose.Visible = isDisp;
            navBtnMin.Visible = navBtnbutton9.Visible = navBtnbutton10.Visible = isDisp;
            //设置tileNav可移动
            if (isDisp == true)
                SetNavTileControlMoveAble();
@@ -78,7 +91,6 @@
        protected void SetNavTileControlMoveAble()
        {
            this.tileNavPaneTop.OptionsPrimaryDropDown.CloseOnOuterClick = DevExpress.Utils.DefaultBoolean.False;
            this.tileNavPaneTop.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tileNavPane_MouseDown);
            this.tileNavPaneTop.MouseMove += new System.Windows.Forms.MouseEventHandler(this.tileNavPane_MouseMove);
            this.tileNavPaneTop.MouseUp += new System.Windows.Forms.MouseEventHandler(this.tileNavPane_MouseUp);
@@ -90,34 +102,6 @@
        private void navBtn导出_ElementClick(object sender, DevExpress.XtraBars.Navigation.NavElementEventArgs e)
        {
            this.popupMenu1.ShowPopup(MousePosition);
        }
        private void bbi导出安装图_ItemClick(object sender, ItemClickEventArgs e)
        {
        }
        private void bbi导出性能曲线_ItemClick(object sender, ItemClickEventArgs e)
        {
        }
        private void bbi下载BIM文件_ItemClick(object sender, ItemClickEventArgs e)
        {
        }
        private void bbi导出属性表_ItemClick(object sender, ItemClickEventArgs e)
        {
        }
        private void navBtn选型报告_ElementClick(object sender, DevExpress.XtraBars.Navigation.NavElementEventArgs e)
        {
        }
        private void navBtn手机页面_ElementClick(object sender, DevExpress.XtraBars.Navigation.NavElementEventArgs e)
        {
        }
        private void navBtn寿命成本计算_ElementClick(object sender, DevExpress.XtraBars.Navigation.NavElementEventArgs e)
        {
        }
        #region 最大最小按钮操作
@@ -154,10 +138,9 @@
        //设置窗体最大化,全屏
        private void SetMaxWindowStatus()
        {
            this.WindowState = FormWindowState.Normal;
            // this.navBtnSize.Glyph = HStation.WinFrmUI.Xhs.Core.Properties.Resources.SizeNormal32;
            (this.navBtnSize.SuperTip.Items[0] as DevExpress.Utils.ToolTipItem).Text = "向下还原";
            this.WindowState = FormWindowState.Maximized;
            this.navBtnbutton9.Glyph = HStation.WinFrmUI.Xhs.Core.Properties.Resources.SizeNormal32;
            (this.navBtnbutton9.SuperTip.Items[0] as DevExpress.Utils.ToolTipItem).Text = "向下还原";
            this._isMaxWindowStatus = true;//最大化窗体状态
            this.Location = new Point(0, 0);
            //Rectangle rect = System.Windows.Forms.SystemInformation.VirtualScreen;
@@ -165,20 +148,18 @@
            this.Size = new System.Drawing.Size(System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width, System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height);
        }
        //设置窗体(小窗)
        private void SetNormalWindowStatus()
        {
            this.WindowState = FormWindowState.Normal;
            //  this.navBtnSize.Glyph = HStation.WinFrmUI.Xhs.Core.Properties.Resources.SizeMax32;
            (this.navBtnSize.SuperTip.Items[0] as DevExpress.Utils.ToolTipItem).Text = "最大化";
            this.navBtnbutton9.Glyph = HStation.WinFrmUI.Xhs.Core.Properties.Resources.Square32;
            (this.navBtnbutton9.SuperTip.Items[0] as DevExpress.Utils.ToolTipItem).Text = "最大化";
            this._isMaxWindowStatus = false;
            var sq_width = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width / 8;
            var sq_height = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height / 8;
            this.Location = new Point(sq_width, sq_height);
            this.Size = new System.Drawing.Size(sq_width * 6, sq_height * 6);
            //this.Location = new Point(0, 0);
            //this.Size = new System.Drawing.Size(900,600);//rect.Width/2, rect.Height/2);
        }
@@ -301,6 +282,8 @@
        #endregion 可拖动缩放
        #region 功能点击事件
        private void navButton询价_ElementClick(object sender, DevExpress.XtraBars.Navigation.NavElementEventArgs e)
        {
        }
@@ -326,5 +309,196 @@
            alertControl1.AllowHtmlText = true;
            alertControl1.Show(this, "tip", info);
        }
        #endregion 功能点击事件
        public static event Action<PumpFullInfoCtrl> JumpPumpFullInfoCtrl;
        //停靠
        private void navBtnDock_ElementClick(object sender, DevExpress.XtraBars.Navigation.NavElementEventArgs e)
        {
            this.Close();
            JumpPumpFullInfoCtrl.Invoke(this.pumpFullInfoCtrl1);
        }
        private void navBtnEdit_ElementClick(object sender, DevExpress.XtraBars.Navigation.NavElementEventArgs e)
        {
            this.popupMenuEdit.ShowPopup(MousePosition);
        }
        //表格编辑
        private void BarButtonItem1_ItemClick(object sender, ItemClickEventArgs e)
        {
            var dlg = new Yw.WinFrmUI.Phart.ImportPumpPerform2dByExcelDlg();
            dlg.ReloadDataEvent += async (other_name, qh, qe, qp) =>
            {
                var bol = await Import(other_name, qh, qe, qp);
                return bol;
            };
            dlg.ShowDialog();
        }
        //泵型号属性编辑
        private void BarBtnEditProp_ItemClick(object sender, ItemClickEventArgs e)
        {
            var dlg = new EditPumpPartPropDlg();
            dlg.SetBindingData(PumpPropViewCtrl.GetPumpMainVmo());
            dlg.ShowDialog();
            this.pumpFullInfoCtrl1.RefreshPropData();
        }
        //泵型号重新匹配
        private void BarBtnRefreshMatching_ItemClick(object sender, ItemClickEventArgs e)
        {
            var dlg = new PumpSingleMatchingDlg();
            dlg.SetBindingData(_pumpMatchingView);
            dlg.ReloadDataEvent += (matching) =>
            {
                _pumpMatchingView = matching;
                ReloadDataEvent.Invoke(_pumpMatchingView);
                this.SetBindindData(_pumpMatchingView);
            };
            dlg.ShowDialog();
        }
        //单点编辑
        private void BarButtonItemOnePoint_ItemClick(object sender, ItemClickEventArgs e)
        {
            var dlg = new Yw.WinFrmUI.Phart.ImportPumpPerform2dByOnePointDlg();
            dlg.ReloadDataEvent += async (other_name, qh, qe, qp) =>
            {
                var bol = await Import(other_name, qh, qe, qp);
                return bol;
            };
            dlg.ShowDialog();
        }
        //曲线编辑
        private void BarButtonItemEdit_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.PumpEditChartDlg();
            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,
                };
                Yw.Geometry.Point2d point2D = new Yw.Geometry.Point2d();
                var bol = await _bll_ex.Update(_xhs_phart_diagram_ex_std_dto);
                if (bol)
                {
                }
                return bol;
            };
            dlg.ShowDialog();
        }
        //图片编辑
        private void BarButtonItemPicture_ItemClick(object sender, ItemClickEventArgs e)
        {
        }
        // 导入
        private async Task<bool> Import(string other_name, Yw.Pump.CurveQH qh, Yw.Pump.CurveQE qe, Yw.Pump.CurveQP qp)
        {
            if (_PumpId < 1)
            {
                XtraMessageBox.Show("PumpMain is null!");
                return false;
            }
            var input = new Vmo.XhsPumpMainPhartMappingExtensions();
            input.PumpMainID = _PumpId;
            input.Importance = 0;
            input.OtherName = other_name;
            input.Diagram = new Vmo.PhartDiagramExGraphList()
            {
                DiagramType = HStation.PhartRelation.eDiagramType.Feat,
                Name = other_name,
                GraphList = new List<Vmo.PhartGraph>()
                {
                    new ()
                    {
                        Name = other_name+"-QH",
                        GeometryStyle=  HStation.PhartRelation.eGeometryStyle.FeatCurve,
                        GraphType= HStation.PhartRelation.eGraphType.PumpQH,
                        GeometryInfo=qh.ToDbString()
                    },
                    new ()
                    {
                        Name = other_name+"-QE",
                        GeometryStyle= HStation.PhartRelation.eGeometryStyle.FeatCurve,
                        GraphType= HStation.PhartRelation.eGraphType.PumpQE,
                        GeometryInfo=qe.ToDbString()
                    },
                    new ()
                    {
                        Name = other_name+"-QP",
                        GeometryStyle=  HStation.PhartRelation.eGeometryStyle.FeatCurve,
                        GraphType= HStation.PhartRelation.eGraphType.PumpQP,
                        GeometryInfo=qp.ToDbString()
                    },
                }
            };
            var mapping_id = await _bll_ex.Insert(input);
            if (mapping_id < 1)
            {
                return false;
            }
            var xhs_phart_diagram_ex_std_dto = await _bll_ex.GetByID(mapping_id);
            return true;
        }
    }
}