namespace Yw.WinFrmUI
|
{
|
public partial class SetHydroMonitorListCtrl : DevExpress.XtraEditors.XtraUserControl
|
{
|
public SetHydroMonitorListCtrl()
|
{
|
InitializeComponent();
|
this.gridView1.SetNormalEditView(30);
|
this.colRelation.OptionsColumn.AllowEdit = false;
|
this.colPropName.OptionsColumn.AllowEdit = false;
|
InitialFlags();
|
}
|
|
private Yw.Model.HydroModelInfo _hydroInfo = null;//水力信息
|
private Yw.Model.HydroVisualInfo _visualInfo = null;//构件信息
|
private BindingList<SetHydroMonitorViewModel> _allBindingList = null;//所有绑定列表
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData
|
(
|
Yw.Model.HydroModelInfo hydroInfo,
|
Yw.Model.HydroVisualInfo visualInfo,
|
List<HydroMonitorVmo> allMonitorList
|
)
|
{
|
_hydroInfo = hydroInfo;
|
_visualInfo = visualInfo;
|
_allBindingList = new BindingList<SetHydroMonitorViewModel>();
|
if (hydroInfo != null)
|
{
|
if (visualInfo != null)
|
{
|
var propList = HydroVisualCalcuPropHelper.GetNameDict(visualInfo.Catalog);
|
if (propList != null && propList.Count > 0)
|
{
|
var sortCode = allMonitorList == null || allMonitorList.Count < 1 ? 0 : allMonitorList.Max(x => x.SortCode);
|
foreach (var prop in propList)
|
{
|
var vmo = allMonitorList?.Find(x => x.ModelID == hydroInfo.ID && x.Relation == visualInfo.Code && x.PropName == prop.Key);
|
if (vmo == null)
|
{
|
sortCode++;
|
vmo = new HydroMonitorVmo()
|
{
|
ID = 0,
|
ModelID = hydroInfo.ID,
|
Relation = visualInfo.Code,
|
PropName = prop.Key,
|
SortCode = sortCode,
|
Description = string.Empty
|
};
|
}
|
var vm = new SetHydroMonitorViewModel(vmo, visualInfo);
|
_allBindingList.Add(vm);
|
}
|
}
|
}
|
}
|
this.setHydroMonitorViewModelBindingSource.DataSource = _allBindingList;
|
this.setHydroMonitorViewModelBindingSource.ResetBindings(false);
|
}
|
|
private async void InitialFlags()
|
{
|
var flags = await BLLFactory<Yw.BLL.SysFlag>.Instance.GetBySysType(Yw.Hydro.DataType.HydroMonitor);
|
this.repositoryItemCheckedComboBoxEdit1.Items.BeginUpdate();
|
this.repositoryItemCheckedComboBoxEdit1.Items.Clear();
|
if (flags != null && flags.Count > 0)
|
{
|
foreach (var flag in flags)
|
{
|
this.repositoryItemCheckedComboBoxEdit1.Items.Add(flag.Name);
|
}
|
}
|
this.repositoryItemCheckedComboBoxEdit1.Items.EndUpdate();
|
}
|
|
/// <summary>
|
/// 获取监测列表
|
/// </summary>
|
public List<HydroMonitorVmo> GetMonitorList()
|
{
|
var list = _allBindingList?.Where(x => x.Checked).ToList();
|
list?.ForEach(x =>
|
{
|
x.Vmo.Flags = HydroFlagsHelper.ToList(x.Flags);
|
x.Vmo.Description = x.Description;
|
});
|
return list?.Select(x => x.Vmo).ToList();
|
}
|
|
|
}
|
}
|