using Yw.Model;
|
|
namespace HStation.WinFrmUI
|
{
|
public partial class SetSchemePipeListCtrl : DevExpress.XtraEditors.XtraUserControl, ISetSchemeParterList
|
{
|
public SetSchemePipeListCtrl()
|
{
|
InitializeComponent();
|
this.layoutControl1.SetupLayoutControl();
|
this.gridView1.SetNormalView(30);
|
this.gridView1.RegistCustomDrawRowIndicator(40);
|
this.gridView1.BorderStyle = BorderStyles.NoBorder;
|
this.generalSearchAndSelectCtrl1.SearchEvent += () =>
|
{
|
Search();
|
};
|
this.generalSearchAndSelectCtrl1.ClearEvent += () =>
|
{
|
Clear();
|
};
|
this.generalSearchAndSelectCtrl1.SelectEvent += () =>
|
{
|
TipFormHelper.Show(eTipStatus.Info, "批量选择待更新");
|
};
|
}
|
|
/// <summary>
|
/// 水力点击事件
|
/// </summary>
|
public event Action<Yw.Model.HydroParterInfo> HydroClickEvent;
|
|
/// <summary>
|
/// 水力改变事件
|
/// </summary>
|
public event Action<List<HydroParterInfo>> HydroChangedEvent;
|
|
/// <summary>
|
/// 水力记录改变事件
|
/// </summary>
|
public event Action<SetSchemeParterRecord> HydroRecordChangedEvent;
|
|
/// <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 _allList != null && _allList.Count > 0; }
|
}
|
|
//水力信息
|
private Yw.Model.HydroModelInfo _hydroInfo = null;
|
|
//所有列表
|
private List<HydroPipeViewModel> _allList = null;
|
|
//所有绑定列表
|
private List<HydroPipeViewModel> _allBindingList = null;
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(HydroModelInfo hydroInfo)
|
{
|
_hydroInfo = hydroInfo;
|
_allList = new List<HydroPipeViewModel>();
|
if (hydroInfo != null && hydroInfo.Pipes != null && hydroInfo.Pipes.Count > 0)
|
{
|
foreach (var pipe in hydroInfo.Pipes)
|
{
|
var vm = new HydroPipeViewModel(pipe, hydroInfo);
|
_allList.Add(vm);
|
}
|
}
|
Search();
|
}
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuVisualResult> allCalcuResultList)
|
{
|
_allList = new List<HydroPipeViewModel>();
|
if (hydroInfo != null && hydroInfo.Pipes != null && hydroInfo.Pipes.Count > 0)
|
{
|
foreach (var pipe in hydroInfo.Pipes)
|
{
|
var vm = new HydroPipeViewModel(pipe, hydroInfo);
|
var calcuResult = allCalcuResultList?.Find(x => x.Code == pipe.Code);
|
if (calcuResult != null)
|
{
|
vm.UpdateCalcuProperty(calcuResult);
|
}
|
_allList.Add(vm);
|
}
|
}
|
Search();
|
}
|
|
/// <summary>
|
/// 更新属性
|
/// </summary>
|
public void UpdateProperty()
|
{
|
if (_allList == null || _allList.Count < 1)
|
{
|
return;
|
}
|
_allList.ForEach(x => x.UpdateProperty());
|
this.hydroPipeViewModelBindingSource.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.hydroPipeViewModelBindingSource.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.hydroPipeViewModelBindingSource.ResetBindings(false);
|
}
|
|
/// <summary>
|
/// 更新计算属性
|
/// </summary>
|
public void UpdateCalcuProperty(List<HydroCalcuVisualResult> 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.hydroPipeViewModelBindingSource.ResetBindings(false);
|
}
|
}
|
}
|
|
//查询
|
private void Search()
|
{
|
if (_allList == null || _allList.Count < 1)
|
{
|
return;
|
}
|
var name = this.txtName.Text.Trim();
|
var code = this.txtCode.Text.Trim();
|
var modelType = this.txtModelType.Text.Trim();
|
_allBindingList = _allList;
|
if (!string.IsNullOrEmpty(name))
|
{
|
_allBindingList = _allBindingList.Where(x => !string.IsNullOrEmpty(x.Name) && x.Name.Contains(name)).ToList();
|
}
|
if (!string.IsNullOrEmpty(code))
|
{
|
_allBindingList = _allBindingList.Where(x => !string.IsNullOrEmpty(x.Code) && x.Code.Contains(code)).ToList();
|
}
|
if (!string.IsNullOrEmpty(modelType))
|
{
|
_allBindingList = _allBindingList.Where(x => !string.IsNullOrEmpty(x.ModelType) && x.ModelType.Contains(modelType)).ToList();
|
}
|
this.hydroPipeViewModelBindingSource.DataSource = _allBindingList;
|
this.hydroPipeViewModelBindingSource.ResetBindings(false);
|
}
|
|
//重置
|
private void Clear()
|
{
|
this.txtName.EditValue = null;
|
this.txtCode.EditValue = null;
|
this.txtModelType.EditValue = null;
|
Search();
|
}
|
|
//设置
|
private void SelectChange()
|
{
|
Search();
|
var row = this.gridView1.GetFocusedRow() as HydroPipeViewModel;
|
if (row == null)
|
{
|
XtraMessageBox.Show("无可设置管道数据");
|
return;
|
}
|
}
|
|
private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
|
{
|
/* var row = this.gridView1.GetRow(e.RowHandle) as HydroPipeViewModel;
|
if (row == null)
|
{
|
return;
|
}
|
|
if (e.Column == this.colSelect)
|
{
|
var input = AssetsMatchingParasHelper.Create(_hydroInfo, row.Vmo, null);
|
var dlg = new SimulationPipeSingleMatchingDlg();
|
dlg.SetBindingData(input);
|
dlg.ReloadDataEvent += (output) =>
|
{
|
var bol = AssetsMatchingParasHelper.Apply(_hydroInfo, output);
|
if (bol)
|
{
|
row.UpdateProperty();
|
this.gridView1.RefreshRow(e.RowHandle);
|
this.HydroChangedEvent?.Invoke(new List<Yw.Model.HydroParterInfo>() { row.Vmo });
|
|
var record = new SetSchemeParterRecord();
|
record.Name = row.Vmo.Name;
|
record.Code = row.Vmo.Code;
|
record.Catalog = Yw.Hydro.ParterCatalog.Pipe;
|
record.MatchingModel = output;
|
|
record.Items = new List<SetSchemeParterRecordItem>() {
|
new() {Name="型号",BeforeValue=$"{output.ModelType}",AfterValue=$"{output.MatchingModelType}"},
|
new() {Name="材料",BeforeValue=$"{output.Material}",AfterValue=$"{output.MatchingMaterial}"},
|
new() {Name="直径(mm)",BeforeValue=$"{output.Diameter}",AfterValue=$"{output.MatchingDiameter}"},
|
new() {Name="粗糙系数",BeforeValue=$"{output.Roughness}",AfterValue=$"{output.MatchingRoughness}"},
|
new() {Name="局阻系数",BeforeValue=$"{output.MinorLoss}",AfterValue=$"{output.MatchingMinorLoss}"},
|
};
|
this.HydroRecordChangedEvent?.Invoke(record);
|
}
|
};
|
dlg.ShowDialog();
|
}
|
else
|
{
|
this.HydroClickEvent?.Invoke(row.Vmo);
|
}*/
|
}
|
}
|
}
|