using Yw.Model;
|
|
namespace Yw.WinFrmUI
|
{
|
public partial class HydroMeterListCtrl : DevExpress.XtraEditors.XtraUserControl, IHydroParterList
|
{
|
public HydroMeterListCtrl()
|
{
|
InitializeComponent();
|
this.gridView1.SetNormalView(30);
|
this.gridView1.RegistCustomDrawRowIndicator(40);
|
}
|
|
/// <summary>
|
/// 水力点击事件
|
/// </summary>
|
public event Action<Yw.Model.HydroParterInfo> HydroClickEvent;
|
public event Action<List<HydroParterInfo>> HydroChangedEvent;
|
|
/// <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<HydroMeterViewModel> _allList = null;//所有列表
|
private List<HydroMeterViewModel> _allBindingList = null;//所有绑定列表
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
/// <param name="allMeterList"></param>
|
public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuResult> allCalcuResultList)
|
{
|
_allBindingList = new List<HydroMeterViewModel>();
|
if (hydroInfo != null && hydroInfo.Meters != null && hydroInfo.Meters.Count > 0)
|
{
|
foreach (var meter in hydroInfo.Meters)
|
{
|
var calcuNodeResult = allCalcuResultList?.Find(x => x.Code == meter.Code) as HydroCalcuNodeResult;
|
var vm = new HydroMeterViewModel(meter, hydroInfo);
|
_allBindingList.Add(vm);
|
}
|
}
|
this.hydroMeterViewModelBindingSource.DataSource = _allBindingList;
|
this.hydroMeterViewModelBindingSource.ResetBindings(false);
|
if (allCalcuResultList == null || allCalcuResultList.Count < 1)
|
{
|
SetNormalView();
|
}
|
else
|
{
|
SetCalcuView();
|
}
|
}
|
|
/// <summary>
|
/// 更新属性
|
/// </summary>
|
public void UpdateProperty()
|
{
|
if (_allList == null || _allList.Count < 1)
|
{
|
return;
|
}
|
_allList.ForEach(x => x.UpdateProperty());
|
this.hydroMeterViewModelBindingSource.ResetBindings(false);
|
}
|
|
/// <summary>
|
/// 更新属性
|
/// </summary>
|
public void UpdateProperty(Yw.Model.HydroParterInfo parter)
|
{
|
if (_allList == null || _allList.Count < 1)
|
{
|
return;
|
}
|
if (parter == null)
|
{
|
return;
|
}
|
var vm = _allList.Find(x => x.Code == parter.Code);
|
if (vm == null)
|
{
|
return;
|
}
|
vm.UpdateProperty();
|
this.hydroMeterViewModelBindingSource.ResetBindings(false);
|
}
|
|
/// <summary>
|
/// 更新属性
|
/// </summary>
|
public void UpdateProperty(List<Yw.Model.HydroParterInfo> parterList)
|
{
|
if (_allList == null || _allList.Count < 1)
|
{
|
return;
|
}
|
if (parterList == null || parterList.Count < 1)
|
{
|
return;
|
}
|
parterList.ForEach(x =>
|
{
|
var vm = _allList.Find(t => x.Code == x.Code);
|
if (vm != null)
|
{
|
vm.UpdateProperty();
|
}
|
});
|
this.hydroMeterViewModelBindingSource.ResetBindings(false);
|
}
|
|
/// <summary>
|
/// 更新计算属性
|
/// </summary>
|
public void UpdateCalcuProperty(List<HydroCalcuResult> allCalcuResultList)
|
{
|
if (allCalcuResultList != null && allCalcuResultList.Count > 0)
|
{
|
if (_allList != null && _allList.Count > 0)
|
{
|
foreach (var parter in _allList)
|
{
|
var calcuResult = allCalcuResultList.Find(x => x.Code == parter.Code);
|
if (calcuResult != null)
|
{
|
parter.UpdateCalcuProperty(calcuResult);
|
}
|
}
|
this.hydroMeterViewModelBindingSource.ResetBindings(false);
|
}
|
}
|
}
|
|
/// <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.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.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.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 HydroMeterViewModel;
|
if (row == null)
|
{
|
return;
|
}
|
this.HydroClickEvent?.Invoke(row.Vmo);
|
}
|
|
public void SetBindingData(HydroModelInfo hydroInfo)
|
{
|
throw new NotImplementedException();
|
}
|
|
public void SetBulkSetView()
|
{
|
throw new NotImplementedException();
|
}
|
|
|
}
|
}
|