using DevExpress.XtraLayout.Utils;
|
|
namespace Yw.WinFrmUI
|
{
|
public partial class SetHydroCalcuPrefixCtrl : DevExpress.XtraEditors.XtraUserControl
|
{
|
public SetHydroCalcuPrefixCtrl()
|
{
|
InitializeComponent();
|
}
|
|
/// <summary>
|
/// 控件最小宽度
|
/// </summary>
|
public const int ControlMinWidth = 350;
|
|
/// <summary>
|
/// 计算事件
|
/// </summary>
|
public event Action<Yw.Model.HydroModelInfo> CalcuEvent;
|
|
private SetHydroCalcuPrefixViewModel _vm = null;
|
private SetHydroCalcuPrefixManager _wizard;
|
private Func<Yw.Model.HydroModelInfo> _hydroInfoFunc = null;
|
|
/// <summary>
|
/// 初始化数据
|
/// </summary>
|
public void InitialData(Func<Yw.Model.HydroModelInfo> hydroInfoFunc)
|
{
|
_hydroInfoFunc = hydroInfoFunc;
|
}
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData()
|
{
|
var hydroInfo = _hydroInfoFunc?.Invoke();
|
if (hydroInfo == null)
|
{
|
return;
|
}
|
_vm = new SetHydroCalcuPrefixViewModel();
|
_vm.HydroInfo = hydroInfo;
|
_vm.FirstPage = this.setWaterboxCalcuPrefixListCtrl1;
|
_vm.LastPage = this.setNozzleCalcuPrefixListCtrl1;
|
_wizard = new SetHydroCalcuPrefixManager(_vm);
|
_wizard.SelectedPageChangedEvent += _wizard_SelectedPageChangedEvent;
|
_wizard.SelectedPageStateChangedEvent += _wizard_SelectedPageStateChangedEvent; ;
|
_wizard.InitialManager(new IWizardPage<SetHydroCalcuPrefixViewModel>[] {
|
this.setWaterboxCalcuPrefixListCtrl1,
|
this.setPumpCalcuPrefixListCtrl1,
|
this.setNozzleCalcuPrefixListCtrl1
|
});
|
}
|
|
//选择页面改变
|
private void _wizard_SelectedPageChangedEvent(IWizardPage<SetHydroCalcuPrefixViewModel> page, int index)
|
{
|
this.itemForPrev.Visibility = page.AllowPrev ? LayoutVisibility.Always : LayoutVisibility.Never;
|
this.itemForNext.Visibility = page.AllowNext ? LayoutVisibility.Always : LayoutVisibility.Never;
|
this.navigationFrame1.SelectedPageIndex = index;
|
}
|
|
//选择页面状态改变
|
private void _wizard_SelectedPageStateChangedEvent(IWizardPage<SetHydroCalcuPrefixViewModel> page, int index)
|
{
|
this.itemForPrev.Visibility = page.AllowPrev ? LayoutVisibility.Always : LayoutVisibility.Never;
|
this.itemForNext.Visibility = page.AllowNext ? LayoutVisibility.Always : LayoutVisibility.Never;
|
}
|
|
//上一步
|
private void btnPrev_Click(object sender, EventArgs e)
|
{
|
if (_wizard != null)
|
{
|
_wizard.Prev();
|
}
|
}
|
|
//下一步
|
private void btnNext_Click(object sender, EventArgs e)
|
{
|
if (_wizard != null)
|
{
|
_wizard.Next();
|
}
|
}
|
|
//计算
|
private void btnComplete_Click(object sender, EventArgs e)
|
{
|
if (_wizard != null)
|
{
|
var bol = _wizard.Complete();
|
if (bol)
|
{
|
var hydroInfo = _hydroInfoFunc?.Invoke();
|
if (hydroInfo == null)
|
{
|
return;
|
}
|
this.CalcuEvent?.Invoke(hydroInfo);
|
}
|
}
|
}
|
|
}
|
}
|