duheng
2024-12-27 1c3e5bc50d3045d51cb9a9f747d53442b82d9e2c
WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/04-scheme/02-change/03-pipe/CreateXhsSchemePipeChangePage.cs
@@ -1,6 +1,4 @@
using DevExpress.Utils.Svg;
using Mapster;
using Yw;
namespace HStation.WinFrmUI
{
@@ -9,8 +7,8 @@
        public CreateXhsSchemePipeChangePage()
        {
            InitializeComponent();
            InitialLinkStatus();
            this.layoutView1.SetDefuaulView();
            this.layoutView1.SetDefuaulView();
            this.layoutView1.SetFindPanel();
        }
        /// <summary>
@@ -22,19 +20,8 @@
        private bool _isInitialize = false;//是否初始化
        private HStation.Vmo.XhsProjectVmo _project = null;//项目
        private HStation.Vmo.XhsProjectSiteVmo _project_site = null;//项目站
        private HStation.Vmo.XhsProjectSiteVmo _project_site = null;//项目站
        private List<CreateXhsSchemePipeChangeViewMdoel> _vm_list = null;
        //初始化状态
        private void InitialLinkStatus()
        {
            this.repImgCmbStatus.BeginUpdate();
            this.repImgCmbStatus.Items.Clear();
            this.repImgCmbStatus.Items.Add("开启", "开启", -1);
            this.repImgCmbStatus.Items.Add("关闭", "关闭", -1);
            this.repImgCmbStatus.EndUpdate();
        }
        /// <summary>
        /// 初始化
@@ -51,21 +38,20 @@
            _project_site = t.ProjectSite;
            if (t.HydroInfo.Pipes != null && t.HydroInfo.Pipes.Any())
            {
                var svg_img = SvgImage.FromStream(new MemoryStream(HStation.WinFrmUI.Xhs.Core.Properties.Resources.pipe));
                var svg = SvgImage.FromStream(new MemoryStream(HStation.WinFrmUI.Xhs.Core.Properties.Resources.pipe));
                _vm_list = new List<CreateXhsSchemePipeChangeViewMdoel>();
                foreach (var pipe in t.HydroInfo.Pipes)
                {
                    var vm = new Yw.WinFrmUI.HydroPipeViewModel(pipe, t.HydroInfo).Adapt<CreateXhsSchemePipeChangeViewMdoel>();
                    vm.SvgImage = svg_img;
                    _vm_list.Add(vm);
                    var vm = new Yw.WinFrmUI.HydroPipeViewModel(pipe, t.HydroInfo);
                    _vm_list.Add(new CreateXhsSchemePipeChangeViewMdoel(vm, svg));
                }
            }
            //this.CreateXhsSchemePipeChangeViewMdoelBindingSource.DataSource = _vm_list;
            //this.CreateXhsSchemePipeChangeViewMdoelBindingSource.ResetBindings(false);
            }
            this.createXhsSchemePipeChangeViewMdoelBindingSource.DataSource = _vm_list;
            this.createXhsSchemePipeChangeViewMdoelBindingSource.ResetBindings(false);
            ShowBimfaceCtrl();
            this.PageStateChangedEvent?.Invoke();
        }
        #region Bimface
@@ -82,7 +68,14 @@
            {
                _bimfaceCtrl = new SimulationBimfaceCtrl();
                _bimfaceCtrl.Dock = DockStyle.Fill;
                await _bimfaceCtrl.InitialData(_project, _project_site);
                await _bimfaceCtrl.InitialData(_project, _project_site);
                _bimfaceCtrl.HydroMouseLeftClickEvent += (code) =>
                {
                    if (_vm_list == null || !_vm_list.Any())
                        return;
                    var index = _vm_list.FindIndex(x => x.ViewModel.Code == code);
                    this.layoutView1.FocusedRowHandle = index;
                };
            }
            return _bimfaceCtrl;
        }
@@ -95,8 +88,7 @@
            this.sidePanel3dModel.Controls.Add(bimfaceCtrl);
        }
        #endregion
        #endregion Bimface
        //保存
        private bool Save()
@@ -109,19 +101,20 @@
            {
                return false;
            }
            _vm.HydroInfo.Pipes = _vm_list.Adapt<List<Yw.Model.HydroPipeInfo>>();
            _vm_list.ForEach(x => x.ViewModel.UpdateVmoProperty());
            _vm.HydroInfo.Pipes = _vm_list.Select(x => x.ViewModel.Vmo).ToList();
            return true;
        }
        //
        //点击
        private async void layoutView1_CardClick(object sender, DevExpress.XtraGrid.Views.Layout.Events.CardClickEventArgs e)
        {
            var row = this.layoutView1.GetRow(e.RowHandle) as CreateXhsSchemePipeChangeViewMdoel;
            if (row == null)
            if (this.layoutView1.GetRow(e.RowHandle) is not CreateXhsSchemePipeChangeViewMdoel row)
                return;
            await _bimfaceCtrl?.ZoomAndSelectComponent(row.Code);
            await _bimfaceCtrl?.ZoomAndSelectComponent(row.ViewModel.Code);
        }
        //选中列变换
        private void layoutView1_FocusedColumnChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedColumnChangedEventArgs e)
        {
            if (e.FocusedColumn == this.colModelType)
@@ -131,16 +124,31 @@
                    return;
                var link_status = row.LinkStatus;
                var input = Yw.WinFrmUI.HydroMatchingHelper.Create(row.Vmo, _vm.HydroInfo);
                var dlg = new SimulationPipeSingleMatchingDlg();
                var input = Yw.WinFrmUI.HydroMatchingHelper.Create(row.ViewModel.Vmo, _vm.HydroInfo);
                var dlg = new AssetsPipeSingleMatchingDlg();
                dlg.SetBindingData(input);
                dlg.ReloadDataEvent += (output) =>
                {
                    Yw.WinFrmUI.HydroMatchingHelper.Apply(row, output);
                    row.LinkStatus = link_status;
                    Yw.WinFrmUI.HydroMatchingHelper.Apply(row.ViewModel, output);
                    row.LinkStatus = link_status;
                    if (!_vm.ChangeRecordList.Exists(x => x.Code == row.ViewModel.Code))
                    {
                        _vm.ChangeRecordList.Add(new(Yw.Hydro.ParterCatalog.Pipe, row.ViewModel.Code, row.Name, row.SvgImage));
                    }
                };
                dlg.ShowDialog();
            }
        }
        //单元格值变换
        private void layoutView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            if (this.layoutView1.GetRow(e.RowHandle) is not CreateXhsSchemePipeChangeViewMdoel row)
                return;
            if (!_vm.ChangeRecordList.Exists(x => x.Code == row.ViewModel.Code))
            {
                _vm.ChangeRecordList.Add(new(Yw.Hydro.ParterCatalog.Pipe, row.ViewModel.Code, row.Name, row.SvgImage));
            }
        }
@@ -217,7 +225,5 @@
        {
            return false;
        }
    }
}