namespace Yw.WinFrmUI { public partial class SetHydroWorkingPumpCtrl : DevExpress.XtraEditors.XtraUserControl, ISetHydroWorkingVisualCtrl { public SetHydroWorkingPumpCtrl() { InitializeComponent(); this.layoutControl1.SetupLayoutControl(); InitialLinkStatus(); } /// /// 查看组件事件 /// public event Action HydroViewEvent; //组件 private Yw.Model.HydroPumpInfo _visual = null; //工况 private HydroWorkingPumpViewModel _working = null; /// /// 绑定数据 /// public void SetBindingData(Yw.Model.HydroVisualInfo visual, HydroWorkingVisualViewModel working = null) { _visual = visual as Yw.Model.HydroPumpInfo; if (_visual == null) { return; } this.layoutGroupCaption.Text = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Pump); if (!string.IsNullOrEmpty(_visual.Name)) { this.layoutGroupCaption.Text = _visual.Name; } _working = working as HydroWorkingPumpViewModel; if (_working == null) { _working = new HydroWorkingPumpViewModel(_visual); } this.imgCmbLinkStatus.EditValue = _working.LinkStatus; this.txtCurrentHz.EditValue = Math.Round(_working.CurrentHz, 1); } /// /// 获取工况 /// public HydroWorkingVisualViewModel GetWorking() { if (_visual == null) { return default; } if (_working == null) { return default; } _working.LinkStatus = this.imgCmbLinkStatus.EditValue?.ToString(); _working.CurrentHz = double.Parse(this.txtCurrentHz.EditValue.ToString()); return _working; } //初始化管段状态 private void InitialLinkStatus() { this.imgCmbLinkStatus.Properties.BeginUpdate(); this.imgCmbLinkStatus.Properties.Items.Clear(); this.imgCmbLinkStatus.Properties.Items.Add(HydroLinkStatusHelper.GetStatusName(Yw.Hydro.PumpStatus.Open), Yw.Hydro.PumpStatus.Open, -1); this.imgCmbLinkStatus.Properties.Items.Add(HydroLinkStatusHelper.GetStatusName(Yw.Hydro.PumpStatus.Closed), Yw.Hydro.PumpStatus.Closed, -1); this.imgCmbLinkStatus.Properties.EndUpdate(); } //查看部件 private void layoutGroupCaption_CustomButtonClick(object sender, DevExpress.XtraBars.Docking2010.BaseButtonEventArgs e) { if (_visual == null) { return; } this.HydroViewEvent?.Invoke(_visual); } //开关状态决定设定频率的可用性 private void imgCmbLinkStatus_EditValueChanged(object sender, EventArgs e) { var linkStatus = this.imgCmbLinkStatus.EditValue?.ToString(); if (linkStatus == Yw.Hydro.PumpStatus.Open) { this.txtCurrentHz.Properties.ReadOnly = false; } else { this.txtCurrentHz.Properties.ReadOnly = true; } } } }