namespace Yw.WinFrmUI
{
public partial class HydroValveListCtrl : DevExpress.XtraEditors.XtraUserControl, IViewHydroParterList
{
public HydroValveListCtrl()
{
InitializeComponent();
this.gridView1.SetNormalView(30);
this.gridView1.RegistCustomDrawRowIndicator(40);
}
///
/// 水力点击事件
///
public event Action HydroClickEvent;
///
/// 显示查询面板
///
[Browsable(true)]
[Description("显示查询面板")]
[DefaultValue(true)]
public bool ShowFindPanel
{
get { return this.gridView1.OptionsFind.AlwaysVisible; }
set { this.gridView1.OptionsFind.AlwaysVisible = value; }
}
///
/// 是否拥有水利列表
///
public bool HasHydroList
{
get { return _allBindingList != null && _allBindingList.Count > 0; }
}
//所有绑定列表
private List _allBindingList = null;
///
/// 绑定数据
///
///
public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, List allCalcuResultList)
{
_allBindingList = new List();
if (hydroInfo != null && hydroInfo.Valves != null && hydroInfo.Valves.Count > 0)
{
foreach (var valve in hydroInfo.Valves)
{
var calcuLinkResult = allCalcuResultList?.Find(x => x.Code == valve.Code) as HydroCalcuLinkResult;
var vm = new HydroValveViewModel(valve, calcuLinkResult);
_allBindingList.Add(vm);
}
}
this.hydroValveViewModelBindingSource.DataSource = _allBindingList;
this.hydroValveViewModelBindingSource.ResetBindings(false);
}
///
/// 设置简单显示模式
///
public void SetSimpleView()
{
this.colDbLocked.Visible = true;
this.colCode.Visible = true;
this.colName.Visible = true;
this.colModelType.Visible = true;
this.colFlagsString.Visible = false;
this.colStartCode.Visible = true;
this.colEndCode.Visible = true;
this.colLinkStatus.Visible = true;
this.colDiameter.Visible = true;
this.colMinorLoss.Visible = false;
this.colValveType.Visible = true;
this.colValveSetting.Visible = false;
this.colCalcuFlow.Visible = false;
this.colCalcuVelocity.Visible = false;
this.colCalcuHeadLoss.Visible = false;
this.colDescription.Visible = true;
}
///
/// 设置正常显示模式
///
public void SetNormalView()
{
this.colDbLocked.Visible = true;
this.colCode.Visible = true;
this.colName.Visible = true;
this.colModelType.Visible = true;
this.colFlagsString.Visible = true;
this.colStartCode.Visible = true;
this.colEndCode.Visible = true;
this.colLinkStatus.Visible = true;
this.colDiameter.Visible = true;
this.colMinorLoss.Visible = true;
this.colValveType.Visible = true;
this.colValveSetting.Visible = true;
this.colCalcuFlow.Visible = false;
this.colCalcuVelocity.Visible = false;
this.colCalcuHeadLoss.Visible = false;
this.colDescription.Visible = true;
}
///
/// 设置计算显示模式
///
public void SetCalcuView()
{
this.colDbLocked.Visible = true;
this.colCode.Visible = true;
this.colName.Visible = true;
this.colModelType.Visible = true;
this.colFlagsString.Visible = false;
this.colStartCode.Visible = true;
this.colEndCode.Visible = true;
this.colLinkStatus.Visible = true;
this.colDiameter.Visible = true;
this.colMinorLoss.Visible = false;
this.colValveType.Visible = true;
this.colValveSetting.Visible = false;
this.colCalcuFlow.Visible = true;
this.colCalcuVelocity.Visible = true;
this.colCalcuHeadLoss.Visible = true;
this.colDescription.Visible = true;
}
//行点击事件
private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
{
var row = this.gridView1.GetRow(e.RowHandle) as HydroValveViewModel;
if (row == null)
{
return;
}
this.HydroClickEvent?.Invoke(row.Vmo);
}
}
}