using DevExpress.Utils.Extensions;
using DevExpress.Utils.Svg;
using Yw.DAL.Basic;
using Yw.Vmo;
namespace HStation.WinFrmUI
{
public partial class XhsProjectSimulationFunctionCtrl : DevExpress.XtraEditors.XtraUserControl
{
public XhsProjectSimulationFunctionCtrl()
{
InitializeComponent();
this.layoutControl1.SetupLayoutControl();
}
///
/// 显示项目信息事件
///
public event Action ShowProjectInfoEvent;
///
/// 显示项目模拟事件
///
public event Action ShowProjectSimulationEvent;
///
/// 显示项目方案事件
///
public event Action ShowProjectSchemeEvent;
///
/// 创建项目方案事件
///
public event Action CreateProjectSchemeEvent;
///
/// 比对项目工况事件
///
public event Action CompareProjectWorkingEvent;
///
/// 显示项目工况事件
///
public event Action ShowProjectWorkingEvent;
private XhsProjectVmo _project = null;//项目
private XhsProjectSiteVmo _projectSite = null;//项目站
private List _allSchemeList = null;//所有方案列表
///
/// 绑定数据
///
public async void SetBindingData(XhsProjectVmo project, XhsProjectSiteVmo projectSite)
{
_project = project;
_projectSite = projectSite;
var relation = await BLLFactory.Instance.GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, _projectSite.ID, HStation.Xhs.Purpose.Simulation);
if (relation != null)
{
var allWorkingList = await BLLFactory.Instance.GetByModelID(relation.ModelID);
allWorkingList?.ForEach(x => AppendSimulationWorking(x));
}
_allSchemeList = await BLLFactory.Instance.GetBySiteID(_projectSite.ID);
_allSchemeList?.ForEach(async x =>
{
AppendScheme(x);
var schemeRelation = await BLLFactory.Instance.GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsScheme, x.ID, HStation.Xhs.Purpose.Simulation);
if (schemeRelation != null)
{
var allSchemeWorkingList = await BLLFactory.Instance.GetByModelID(schemeRelation.ModelID);
allSchemeWorkingList?.ForEach(y => AppendSchemeWorking(x, y));
}
});
}
///
/// 添加水力模拟工况
///
public void AppendSimulationWorking(Yw.Vmo.HydroWorkingVmo working)
{
if (working == null)
{
return;
}
this.elementSimulation.Style = DevExpress.XtraBars.Navigation.ElementStyle.Group;
var ckEdit = new CheckEdit();
ckEdit.Properties.AutoWidth = true;
ckEdit.Properties.Caption = string.Empty;
this.accordionControl1.Controls.Add(ckEdit);
var elementWorking = new DevExpress.XtraBars.Navigation.AccordionControlElement();
elementWorking.HeaderControl = ckEdit;
elementWorking.Style = DevExpress.XtraBars.Navigation.ElementStyle.Item;
elementWorking.Text = working.Name;
elementWorking.Tag = working;
elementWorking.Click += (sender, e) => this.ShowProjectWorkingEvent?.Invoke(working, svgImg32[4]);
this.elementSimulation.Elements.Add(elementWorking);
}
///
/// 添加方案
///
public void AppendScheme(XhsSchemeVmo scheme)
{
if (scheme == null)
{
return;
}
this.elementSchemeList.Style = DevExpress.XtraBars.Navigation.ElementStyle.Group;
var elementScheme = new DevExpress.XtraBars.Navigation.AccordionControlElement();
elementScheme.Text = scheme.Name;
elementScheme.Style = DevExpress.XtraBars.Navigation.ElementStyle.Item;
elementScheme.ImageOptions.ImageIndex = 3;
elementScheme.Tag = scheme;
elementScheme.Click += (sender, e) => this.ShowProjectSchemeEvent?.Invoke(scheme, svgImg32[3]);
this.elementSchemeList.Elements.Add(elementScheme);
}
///
/// 添加方案工况
///
public void AppendSchemeWorking(XhsSchemeVmo scheme, Yw.Vmo.HydroWorkingVmo working)
{
if (scheme == null)
{
return;
}
if (working == null)
{
return;
}
var elementScheme = this.elementSchemeList.Elements.FirstOrDefault(x => x.Tag is XhsSchemeVmo && (x.Tag as XhsSchemeVmo).ID == scheme.ID);
if (elementScheme == null)
{
return;
}
elementScheme.Style = DevExpress.XtraBars.Navigation.ElementStyle.Group;
var ckEdit = new CheckEdit();
ckEdit.Properties.AutoWidth = true;
ckEdit.Properties.Caption = string.Empty;
this.accordionControl1.Controls.Add(ckEdit);
var elementWorking = new DevExpress.XtraBars.Navigation.AccordionControlElement();
elementWorking.HeaderControl = ckEdit;
elementWorking.Style = DevExpress.XtraBars.Navigation.ElementStyle.Item;
elementWorking.Text = working.Name;
elementWorking.Tag = working;
elementWorking.Click += (sender, e) => this.ShowProjectWorkingEvent?.Invoke(working, svgImg32[4]);
elementScheme.Elements.Add(elementWorking);
}
//元素点击事件
private void accordionControl1_ElementClick(object sender, DevExpress.XtraBars.Navigation.ElementClickEventArgs e)
{
}
//项目概况
private void elementInfo_Click(object sender, EventArgs e)
{
this.ShowProjectInfoEvent?.Invoke(this.svgImg32[0]);
}
//水力模拟
private void elementSimulation_Click(object sender, EventArgs e)
{
this.ShowProjectSimulationEvent?.Invoke(this.svgImg32[1]);
}
//方案管理
private void elementSchemeList_Click(object sender, EventArgs e)
{
this.CreateProjectSchemeEvent?.Invoke(this.svgImg32[3]);
}
//创建方案
private void btnCreateScheme_Click(object sender, EventArgs e)
{
this.CreateProjectSchemeEvent?.Invoke(this.svgImg32[3]);
}
//工况对比
private void btnCompareWorking_Click(object sender, EventArgs e)
{
this.CompareProjectWorkingEvent?.Invoke(this.svgImg32[5]);
}
}
}