using DevExpress.XtraEditors.Repository;
|
using Yw.WinFrmUI.Hydro;
|
|
namespace Yw.WinFrmUI
|
{
|
public partial class SetHydroMarkCtrl : DevExpress.XtraEditors.XtraUserControl
|
{
|
public SetHydroMarkCtrl()
|
{
|
InitializeComponent();
|
this.gridView1.SetNormalEditView();
|
this.colName.OptionsColumn.AllowEdit = false;
|
this.gridView1.CustomRowCellEdit += GridView1_CustomRowCellEdit;
|
}
|
|
//获取水力信息方法
|
private Func<Yw.Model.HydroModelInfo> _hydroInfoFunc;
|
//所有绑定列表
|
private BindingList<HydroMarkSetViewModel> _allBindingList = null;
|
|
/// <summary>
|
/// 初始化数据
|
/// </summary>
|
public void InitialData(Func<Yw.Model.HydroModelInfo> hydroInfoFunc)
|
{
|
_hydroInfoFunc = hydroInfoFunc;
|
}
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(List<HydroMarkSetViewModel> list)
|
{
|
_allBindingList = new BindingList<HydroMarkSetViewModel>();
|
list?.ForEach(x =>
|
{
|
_allBindingList.Add(x);
|
});
|
this.hydroMarkSetViewModelBindingSource.DataSource = _allBindingList;
|
this.hydroMarkSetViewModelBindingSource.ResetBindings(false);
|
}
|
|
/// <summary>
|
/// 获取结果列表
|
/// </summary>
|
public List<HydroMarkResultViewModel> GetResultList()
|
{
|
var hydroInfo = _hydroInfoFunc?.Invoke();
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
|
var resultList = new List<HydroMarkResultViewModel>();
|
_allBindingList?.ToList().ForEach(x =>
|
{
|
switch (x.Code)
|
{
|
case Yw.Hydro.ParterCatalog.Waterbox:
|
{
|
if (hydroInfo.Waterboxs != null && hydroInfo.Waterboxs.Count > 0)
|
{
|
switch ((eWaterboxMarkType)x.MarkType)
|
{
|
case eWaterboxMarkType.None:
|
{
|
|
}
|
break;
|
case eWaterboxMarkType.PoolElev:
|
{
|
hydroInfo.Waterboxs.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"池底标高:{Math.Round(t.PoolElev, 4)}m"
|
});
|
});
|
}
|
break;
|
case eWaterboxMarkType.InitLevel:
|
{
|
hydroInfo.Waterboxs.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"初始水位:{Math.Round(t.InitLevel, 4)}m"
|
});
|
});
|
}
|
break;
|
case eWaterboxMarkType.MinLevel:
|
{
|
hydroInfo.Waterboxs.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"最小水位:{Math.Round(t.MinLevel, 4)}m"
|
});
|
});
|
}
|
break;
|
case eWaterboxMarkType.MaxLevel:
|
{
|
hydroInfo.Waterboxs.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"最高水位:{Math.Round(t.MaxLevel, 4)}m"
|
});
|
});
|
}
|
break;
|
case eWaterboxMarkType.DN:
|
{
|
hydroInfo.Waterboxs.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"直径:{Math.Round(t.DN, 4)}m"
|
});
|
});
|
}
|
break;
|
case eWaterboxMarkType.MinVol:
|
{
|
hydroInfo.Waterboxs.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"最小容积:{Math.Round(t.MinVol, 1)}m"
|
});
|
});
|
}
|
break;
|
default: break;
|
}
|
}
|
}
|
break;
|
case Yw.Hydro.ParterCatalog.Pump:
|
{
|
if (hydroInfo.Pumps != null && hydroInfo.Pumps.Count > 0)
|
{
|
switch ((ePumpMarkType)x.MarkType)
|
{
|
case ePumpMarkType.None:
|
{
|
|
}
|
break;
|
case ePumpMarkType.PumpStatus:
|
{
|
hydroInfo.Pumps.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"开机状态:{Yw.WinFrmUI.HydroLinkStatusHelper.GetStatusName(t.LinkStatus)}"
|
});
|
});
|
}
|
break;
|
case ePumpMarkType.RatedP:
|
{
|
hydroInfo.Pumps.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"额定功率:{t.RatedP}kW"
|
});
|
});
|
}
|
break;
|
case ePumpMarkType.RatedQ:
|
{
|
hydroInfo.Pumps.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"额定流量:{t.RatedQ}m³/h"
|
});
|
});
|
}
|
break;
|
case ePumpMarkType.RatedH:
|
{
|
hydroInfo.Pumps.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"额定扬程:{t.RatedH}m"
|
});
|
});
|
}
|
break;
|
case ePumpMarkType.RatedN:
|
{
|
hydroInfo.Pumps.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"额定转速:{t.RatedN}r/min"
|
});
|
});
|
}
|
break;
|
case ePumpMarkType.RatedHz:
|
{
|
hydroInfo.Pumps.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"额定频率:{t.RatedHz}"
|
});
|
});
|
}
|
break;
|
case ePumpMarkType.CurrentN:
|
{
|
hydroInfo.Pumps.ForEach(t =>
|
{
|
if (t.RatedN.HasValue)
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"设定转速:{Math.Round(t.RatedN.Value * t.SpeedRatio, 1)}r/min"
|
});
|
}
|
});
|
}
|
break;
|
case ePumpMarkType.CurrentHz:
|
{
|
hydroInfo.Pumps.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"设定频率:{Math.Round(t.RatedHz * t.SpeedRatio, 1)}hz"
|
});
|
});
|
}
|
break;
|
default: break;
|
}
|
}
|
}
|
break;
|
case Yw.Hydro.ParterCatalog.Valve:
|
{
|
if (hydroInfo.Valves != null && hydroInfo.Valves.Count > 0)
|
{
|
switch ((eValveMarkType)x.MarkType)
|
{
|
case eValveMarkType.None:
|
{
|
|
}
|
break;
|
case eValveMarkType.ValveStatus:
|
{
|
hydroInfo.Valves.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"阀门状态:{HydroLinkStatusHelper.GetStatusName(t.LinkStatus)}"
|
});
|
});
|
}
|
break;
|
case eValveMarkType.ValveType:
|
{
|
hydroInfo.Valves.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"阀门类型:{HydroValveTypeHelper.GetTypeName(t.ValveType)}"
|
});
|
});
|
}
|
break;
|
case eValveMarkType.Diameter:
|
{
|
hydroInfo.Valves.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"直径:{t.Diameter}mm"
|
});
|
});
|
}
|
break;
|
case eValveMarkType.MinorLoss:
|
{
|
hydroInfo.Valves.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"局阻系数:{t.MinorLoss}"
|
});
|
});
|
}
|
break;
|
default: break;
|
}
|
}
|
}
|
break;
|
case Yw.Hydro.ParterCatalog.Pipe:
|
{
|
if (hydroInfo.Pipes != null && hydroInfo.Pipes.Count > 0)
|
{
|
switch ((ePipeMarkType)x.MarkType)
|
{
|
case ePipeMarkType.None:
|
{
|
|
}
|
break;
|
case ePipeMarkType.PipeStatus:
|
{
|
hydroInfo.Pipes.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"状态:{Yw.WinFrmUI.HydroLinkStatusHelper.GetStatusName(t.LinkStatus)}"
|
});
|
});
|
}
|
break;
|
case ePipeMarkType.Diameter:
|
{
|
hydroInfo.Pipes.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"直径:{t.Diameter}mm"
|
});
|
});
|
}
|
break;
|
case ePipeMarkType.Length:
|
{
|
hydroInfo.Pipes.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"长度:{t.Length}m"
|
});
|
});
|
}
|
break;
|
case ePipeMarkType.Roughness:
|
{
|
hydroInfo.Pipes.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"粗糙系数:{t.Roughness}"
|
});
|
});
|
}
|
break;
|
case ePipeMarkType.MinorLoss:
|
{
|
hydroInfo.Pipes.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"局阻系数:{t.MinorLoss}"
|
});
|
});
|
}
|
break;
|
default: break;
|
}
|
}
|
}
|
break;
|
case Yw.Hydro.ParterCatalog.Nozzle:
|
{
|
if (hydroInfo.Nozzles != null && hydroInfo.Nozzles.Count > 0)
|
{
|
switch ((eNozzleMarkType)x.MarkType)
|
{
|
case eNozzleMarkType.None:
|
{
|
|
}
|
break;
|
case eNozzleMarkType.Elev:
|
{
|
hydroInfo.Nozzles.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"标高:{Math.Round(t.Elev, 4)}m"
|
});
|
});
|
}
|
break;
|
case eNozzleMarkType.Demand:
|
{
|
hydroInfo.Nozzles.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"需水量:{t.Demand}m³/h"
|
});
|
});
|
}
|
break;
|
case eNozzleMarkType.Coefficient:
|
{
|
hydroInfo.Nozzles.ForEach(t =>
|
{
|
resultList.Add(new HydroMarkResultViewModel()
|
{
|
Code = t.Code,
|
Text = $"喷射系数:{t.Coefficient}"
|
});
|
});
|
}
|
break;
|
default: break;
|
}
|
}
|
}
|
break;
|
default: break;
|
}
|
});
|
|
return resultList;
|
}
|
|
//自定义
|
private void GridView1_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
|
{
|
var row = this.gridView1.GetRow(e.RowHandle) as HydroMarkSetViewModel;
|
if (row == null)
|
{
|
return;
|
}
|
if (e.Column == this.colMarkType)
|
{
|
var repositoryItem = new RepositoryItemImageComboBox();
|
switch (row.Code)
|
{
|
case Yw.Hydro.ParterCatalog.Waterbox:
|
{
|
repositoryItem.AddEnum(typeof(eWaterboxMarkType), true);
|
}
|
break;
|
case Yw.Hydro.ParterCatalog.Pump:
|
{
|
repositoryItem.AddEnum(typeof(ePumpMarkType), true);
|
}
|
break;
|
case Yw.Hydro.ParterCatalog.Valve:
|
{
|
repositoryItem.AddEnum(typeof(eValveMarkType), true);
|
}
|
break;
|
case Yw.Hydro.ParterCatalog.Pipe:
|
{
|
repositoryItem.AddEnum(typeof(ePipeMarkType), true);
|
}
|
break;
|
case Yw.Hydro.ParterCatalog.Nozzle:
|
{
|
repositoryItem.AddEnum(typeof(eNozzleMarkType), true);
|
}
|
break;
|
default: break;
|
}
|
e.RepositoryItem = repositoryItem;
|
}
|
}
|
|
|
}
|
}
|