namespace Yw.WinFrmUI
|
{
|
public partial class HydroHydrantListCtrl : DevExpress.XtraEditors.XtraUserControl, IViewHydroParterList
|
{
|
public HydroHydrantListCtrl()
|
{
|
InitializeComponent();
|
this.gridView1.SetNormalView(30);
|
this.gridView1.RegistCustomDrawRowIndicator(40);
|
}
|
|
/// <summary>
|
/// 水力点击事件
|
/// </summary>
|
public event Action<Yw.Model.HydroParterInfo> HydroClickEvent;
|
|
/// <summary>
|
/// 显示查询面板
|
/// </summary>
|
[Browsable(true)]
|
[Description("显示查询面板")]
|
[DefaultValue(true)]
|
public bool ShowFindPanel
|
{
|
get { return this.gridView1.OptionsFind.AlwaysVisible; }
|
set { this.gridView1.OptionsFind.AlwaysVisible = value; }
|
}
|
|
/// <summary>
|
/// 是否拥有水利列表
|
/// </summary>
|
public bool HasHydroList
|
{
|
get { return _allBindingList != null && _allBindingList.Count > 0; }
|
}
|
|
|
|
//所有绑定列表
|
private List<HydroHydrantViewModel> _allBindingList = null;
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, List<IHydroCalcuResult> allCalcuResultList)
|
{
|
_allBindingList = new List<HydroHydrantViewModel>();
|
if (hydroInfo != null && hydroInfo.Hydrants != null && hydroInfo.Hydrants.Count > 0)
|
{
|
foreach (var hydrant in hydroInfo.Hydrants)
|
{
|
var calcuNodeResult = allCalcuResultList?.Find(x => x.Code == hydrant.Code) as HydroCalcuNodeResult;
|
var vm = new HydroHydrantViewModel(hydrant, calcuNodeResult);
|
_allBindingList.Add(vm);
|
}
|
}
|
this.hydroHydrantViewModelBindingSource.DataSource = _allBindingList;
|
this.hydroHydrantViewModelBindingSource.ResetBindings(false);
|
if (allCalcuResultList == null || allCalcuResultList.Count < 1)
|
{
|
SetNormalView();
|
}
|
else
|
{
|
SetCalcuView();
|
}
|
}
|
|
/// <summary>
|
/// 设置简单显示模式
|
/// </summary>
|
public void SetSimpleView()
|
{
|
this.colDbLocked.Visible = true;
|
this.colCode.Visible = true;
|
this.colName.Visible = true;
|
this.colModelType.Visible = true;
|
this.colHasDb.Visible = true;
|
this.colCoefficient.Visible = true;
|
this.colQuality.Visible = false;
|
this.colElev.Visible = false;
|
this.colMinorLoss.Visible = false;
|
this.colDemand.Visible = false;
|
this.colDemandPattern.Visible = false;
|
this.colCalcuPress.Visible = false;
|
this.colCalcuHead.Visible = false;
|
this.colCalcuDemand.Visible = false;
|
this.colFlagsString.Visible = true;
|
this.colDescription.Visible = true;
|
}
|
|
/// <summary>
|
/// 设置正常显示模式
|
/// </summary>
|
public void SetNormalView()
|
{
|
this.colDbLocked.Visible = true;
|
this.colCode.Visible = true;
|
this.colName.Visible = true;
|
this.colModelType.Visible = true;
|
this.colHasDb.Visible = true;
|
this.colCoefficient.Visible = true;
|
this.colQuality.Visible = false;
|
this.colElev.Visible = true;
|
this.colMinorLoss.Visible = true;
|
this.colDemand.Visible = true;
|
this.colDemandPattern.Visible = false;
|
this.colCalcuPress.Visible = false;
|
this.colCalcuHead.Visible = false;
|
this.colCalcuDemand.Visible = false;
|
this.colFlagsString.Visible = true;
|
this.colDescription.Visible = true;
|
}
|
|
/// <summary>
|
/// 设置计算显示模式
|
/// </summary>
|
public void SetCalcuView()
|
{
|
this.colDbLocked.Visible = true;
|
this.colCode.Visible = true;
|
this.colName.Visible = true;
|
this.colModelType.Visible = true;
|
this.colHasDb.Visible = true;
|
this.colCoefficient.Visible = true;
|
this.colQuality.Visible = false;
|
this.colElev.Visible = true;
|
this.colMinorLoss.Visible = true;
|
this.colDemand.Visible = true;
|
this.colDemandPattern.Visible = false;
|
this.colCalcuPress.Visible = true;
|
this.colCalcuHead.Visible = true;
|
this.colCalcuDemand.Visible = true;
|
this.colFlagsString.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 HydroHydrantViewModel;
|
if (row == null)
|
{
|
return;
|
}
|
this.HydroClickEvent?.Invoke(row.Vmo);
|
}
|
}
|
}
|