| | |
| | | |
| | | namespace HStation.WinFrmUI |
| | | { |
| | | public partial class CreateXhsSchemePumpChangePage : DevExpress.XtraEditors.XtraUserControl, Yw.WinFrmUI.IWizardPage<CreateXhsSchemeViewModel> |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public partial class CreateXhsSchemePumpChangePage : DevExpress.XtraEditors.XtraUserControl, Yw.WinFrmUI.IWizardPageAsync<CreateXhsSchemeViewModel> |
| | | { |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public CreateXhsSchemePumpChangePage() |
| | | { |
| | | InitializeComponent(); |
| | | InitialLinkStatus(); |
| | | this.layoutView1.SetDefuaulView(); |
| | | this.layoutView1.SetFindPanel(); |
| | | this.xhsSchemePumpChangeListCtrl1.HydroViewEvent += XhsSchemePumpChangeListCtrl1_HydroViewEvent; |
| | | this.xhsSchemePumpChangeListCtrl1.HydroChangeEvent += XhsSchemePumpChangeListCtrl1_HydroChangeEvent; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | public event Action PageStateChangedEvent; |
| | | |
| | | private CreateXhsSchemeViewModel _vm = null;//操作对象 |
| | | private bool _isInitialize = false;//是否初始化 |
| | | |
| | | private HStation.Vmo.XhsProjectVmo _project = null;//项目 |
| | | private HStation.Vmo.XhsProjectSiteVmo _project_site = null;//项目站 |
| | | private List<CreateXhsSchemePumpChangeViewMdoel> _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(); |
| | | } |
| | | private List<HydroPumpViewModel> _allViewModelList = null;//所有视图列表 |
| | | |
| | | /// <summary> |
| | | /// 初始化 |
| | | /// </summary> |
| | | public void InitialPage(CreateXhsSchemeViewModel t) |
| | | public void InitialPage(CreateXhsSchemeViewModel vm) |
| | | { |
| | | if (_isInitialize) |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | _vm = t; |
| | | _isInitialize = true; |
| | | _project = t.Project; |
| | | _project_site = t.ProjectSite; |
| | | if (t.HydroInfo.Pumps != null && t.HydroInfo.Pumps.Any()) |
| | | _vm = vm; |
| | | _allViewModelList = new List<HydroPumpViewModel>(); |
| | | if (vm.HydroInfo.Pumps != null && vm.HydroInfo.Pumps.Count > 0) |
| | | { |
| | | var svg = SvgImage.FromStream(new MemoryStream(HStation.WinFrmUI.Xhs.Core.Properties.Resources.pump)); |
| | | _vm_list = new List<CreateXhsSchemePumpChangeViewMdoel>(); |
| | | foreach (var pump in t.HydroInfo.Pumps) |
| | | foreach (var visualViewModel in vm.AllVisualViewModelList) |
| | | { |
| | | var vm = new Yw.WinFrmUI.HydroPumpViewModel(pump, t.HydroInfo); |
| | | _vm_list.Add(new CreateXhsSchemePumpChangeViewMdoel(vm, svg)); |
| | | if (visualViewModel.Vmo.Catalog == Yw.Hydro.ParterCatalog.Pump) |
| | | { |
| | | var vmPump = visualViewModel as HydroPumpViewModel; |
| | | if (vmPump != null) |
| | | { |
| | | _allViewModelList.Add(vmPump); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | this.createXhsSchemePumpChangeViewMdoelBindingSource.DataSource = _vm_list; |
| | | this.createXhsSchemePumpChangeViewMdoelBindingSource.ResetBindings(false); |
| | | |
| | | ShowBimfaceCtrl(); |
| | | this.xhsSchemePumpChangeListCtrl1.SetBindingData(_allViewModelList); |
| | | this.PageStateChangedEvent?.Invoke(); |
| | | } |
| | | |
| | | #region Bimface |
| | | |
| | | //bimface控件 |
| | | private SimulationBimfaceCtrl _bimfaceCtrl = null; |
| | | private CreateXhsSchemeBimfaceCtrl _bimfaceCtrl = null; |
| | | |
| | | //获取 bimface 控件 |
| | | private async Task<SimulationBimfaceCtrl> GetBimfaceCtrl() |
| | | private async Task<CreateXhsSchemeBimfaceCtrl> GetBimfaceCtrl() |
| | | { |
| | | if (_vm == null) |
| | | return null; |
| | | { |
| | | return default; |
| | | } |
| | | if (_bimfaceCtrl == null) |
| | | { |
| | | _bimfaceCtrl = new SimulationBimfaceCtrl(); |
| | | _bimfaceCtrl = new CreateXhsSchemeBimfaceCtrl(); |
| | | _bimfaceCtrl.Dock = DockStyle.Fill; |
| | | await _bimfaceCtrl.InitialData(_project, _project_site); |
| | | await _bimfaceCtrl.InitialData(_vm.Project, _vm.ProjectSite, _vm.HydroInfo, _vm.AllVisualViewModelList); |
| | | _bimfaceCtrl.HydroMouseLeftClickEvent += (code) => |
| | | { |
| | | if (_vm_list == null || !_vm_list.Any()) |
| | | if (_allViewModelList == null || _allViewModelList.Count < 1) |
| | | { |
| | | return; |
| | | var index = _vm_list.FindIndex(x => x.ViewModel.Code == code); |
| | | this.layoutView1.FocusedRowHandle = index; |
| | | } |
| | | var index = _allViewModelList.FindIndex(x => x.Vmo.Code == code); |
| | | this.xhsSchemePumpChangeListCtrl1.SetFocusedRow(index); |
| | | }; |
| | | _bimfaceCtrl.SelectVisualEvent += (code) => |
| | | { |
| | | if (_allViewModelList == null || _allViewModelList.Count < 1) |
| | | { |
| | | return; |
| | | } |
| | | var index = _allViewModelList.FindIndex(x => x.Vmo.Code == code); |
| | | this.xhsSchemePumpChangeListCtrl1.SetFocusedRow(index); |
| | | }; |
| | | } |
| | | return _bimfaceCtrl; |
| | |
| | | private async void ShowBimfaceCtrl() |
| | | { |
| | | var bimfaceCtrl = await GetBimfaceCtrl(); |
| | | this.sidePanel3dModel.Controls.Clear(); |
| | | this.sidePanel3dModel.Controls.Add(bimfaceCtrl); |
| | | this.panelControl1.Controls.Clear(); |
| | | this.panelControl1.Controls.Add(bimfaceCtrl); |
| | | } |
| | | |
| | | |
| | | |
| | | #endregion |
| | | |
| | | //保存 |
| | | private bool Save() |
| | | { |
| | | if (!_isInitialize) |
| | | { |
| | | return false; |
| | | } |
| | | if (_vm_list == null || !_vm_list.Any()) |
| | | { |
| | | return false; |
| | | } |
| | | _vm_list.ForEach(x => x.ViewModel.UpdateVmoProperty()); |
| | | _vm.HydroInfo.Pumps = _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 CreateXhsSchemePumpChangeViewMdoel; |
| | | if (row == null) |
| | | return; |
| | | await _bimfaceCtrl?.ZoomAndSelectComponent(row.ViewModel.Code); |
| | | } |
| | | |
| | | //选中列变换 |
| | | private void layoutView1_FocusedColumnChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedColumnChangedEventArgs e) |
| | | { |
| | | if (e.FocusedColumn == this.colModelType) |
| | | { |
| | | this.layoutView1.FocusedColumn = null; |
| | | if (this.layoutView1.GetFocusedRow() is not CreateXhsSchemePumpChangeViewMdoel row) |
| | | return; |
| | | |
| | | var link_status = row.LinkStatus; |
| | | var current_hz = row.CurrentHz; |
| | | var input = Yw.WinFrmUI.HydroMatchingHelper.Create(row.ViewModel.Vmo, _vm.HydroInfo); |
| | | var dlg = new SimulationPumpSingleMatchingDlg(); |
| | | dlg.SetBindingData(input); |
| | | dlg.ReloadDataEvent += (output) => |
| | | { |
| | | Yw.WinFrmUI.HydroMatchingHelper.Apply(row.ViewModel, output); |
| | | row.LinkStatus = link_status; |
| | | row.CurrentHz = current_hz; |
| | | if (!_vm.ChangeRecordList.Exists(x => x.Code == row.ViewModel.Code)) |
| | | { |
| | | _vm.ChangeRecordList.Add(new(Yw.Hydro.ParterCatalog.Pump, 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 CreateXhsSchemePumpChangeViewMdoel row) |
| | | return; |
| | | if (!_vm.ChangeRecordList.Exists(x => x.Code == row.ViewModel.Code)) |
| | | { |
| | | _vm.ChangeRecordList.Add(new(Yw.Hydro.ParterCatalog.Pump, row.ViewModel.Code, row.Name,row.SvgImage)); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 允许上一步 |
| | | /// </summary> |
| | | public bool AllowPrev |
| | | { |
| | | get |
| | | { |
| | | return true; |
| | | } |
| | | get { return true; } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public bool AllowNext |
| | | { |
| | | get |
| | | { |
| | | return _isInitialize; |
| | | } |
| | | get { return true; } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public bool AllowCancel |
| | | { |
| | | get { return false; } |
| | | get { return true; } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <summary> |
| | | /// 能否上一步 |
| | | /// </summary> |
| | | public bool CanPrev() |
| | | public Task<bool> CanPrev() |
| | | { |
| | | return true; |
| | | return Task.Run(() => true); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 能否下一步 |
| | | /// </summary> |
| | | public bool CanNext() |
| | | public Task<bool> CanNext() |
| | | { |
| | | if (!_isInitialize) |
| | | { |
| | | return false; |
| | | } |
| | | return Save(); |
| | | return Task.Run(() => true); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 能否关闭 |
| | | /// </summary> |
| | | public bool CanCancel() |
| | | public Task<bool> CanCancel() |
| | | { |
| | | return true; |
| | | return Task.Run(() => true); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 能否完成 |
| | | /// </summary> |
| | | public bool CanComplete() |
| | | public Task<bool> CanComplete() |
| | | { |
| | | return false; |
| | | return Task.Run(() => false); |
| | | } |
| | | |
| | | //改变 |
| | | private void XhsSchemePumpChangeListCtrl1_HydroChangeEvent(HydroPumpViewModel obj) |
| | | { |
| | | if (_vm == null) |
| | | { |
| | | return; |
| | | } |
| | | if (_vm.allChangeRecordList == null) |
| | | { |
| | | _vm.allChangeRecordList = new List<XhsSchemeChangeRecordViewModel>(); |
| | | } |
| | | _vm.allChangeRecordList.Update(obj); |
| | | } |
| | | |
| | | //定位 |
| | | private void XhsSchemePumpChangeListCtrl1_HydroViewEvent(string obj) |
| | | { |
| | | if (string.IsNullOrEmpty(obj)) |
| | | { |
| | | return; |
| | | } |
| | | if (_vm == null) |
| | | { |
| | | return; |
| | | } |
| | | _bimfaceCtrl?.ZoomAndSelectComponent(obj); |
| | | } |
| | | |
| | | |