using DevExpress.XtraLayout.Utils;
|
|
namespace HStation.WinFrmUI
|
{
|
public partial class CreateXhsSchemeDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public CreateXhsSchemeDlg()
|
{
|
InitializeComponent();
|
this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
|
|
}
|
|
private readonly CreateXhsSchemeViewModel _vm = new();
|
private CreateXhsSchemeManager _wizard;
|
|
private Dictionary<int, bool> _page_visible_dict = null;
|
|
|
|
/// <summary>
|
///
|
/// </summary>
|
public CreateXhsSchemeViewModel ViewModel
|
{
|
get { return _vm; }
|
}
|
|
|
/// <summary>
|
///
|
/// </summary>
|
public async void SetBindingData
|
(
|
HStation.Vmo.XhsProjectVmo project,
|
HStation.Vmo.XhsProjectSiteVmo project_site,
|
Yw.Model.HydroModelInfo hydro_info
|
)
|
{
|
if (project == null)
|
{
|
return;
|
}
|
_vm.Project = project;
|
_vm.ProjectSite = project_site;
|
_vm.HydroInfo = hydro_info;
|
_vm.ProjectSite ??= await BLLFactory<HStation.BLL.XhsProjectSite>.Instance.GetDefaultByProjectID(_vm.Project.ID);
|
if (_vm.HydroInfo == null)
|
{
|
var hydroRelation = await BLLFactory<Yw.BLL.HydroModelRelation>.Instance
|
.GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, _vm.ProjectSite.ID, HStation.Xhs.Purpose.Simulation);
|
_vm.HydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(hydroRelation.ModelID);
|
}
|
_vm.AllSchemeList = await BLLFactory<HStation.BLL.XhsScheme>.Instance.GetBySiteID(_vm.ProjectSite.ID);
|
|
_wizard = new CreateXhsSchemeManager(_vm);
|
_wizard.SelectedPageChangedEvent += _wizard_SelectedPageChangedEvent;
|
_wizard.SelectedPageStateChangedEvent += _wizard_SelectedPageStateChangedEvent;
|
_wizard.InitialManager(new IWizardPage<CreateXhsSchemeViewModel>[] {
|
this.createXhsSchemeInfoPage1,
|
this.createXhsSchemePumpChangePage1,
|
});
|
_page_visible_dict.Add(0,false);
|
|
this.createXhsSchemeInfoPage1.ChangeTypeChangedEvent += CreateXhsSchemeInfoPage1_ChangeTypeChangedEvent;
|
}
|
|
|
//变更类型变换
|
private void CreateXhsSchemeInfoPage1_ChangeTypeChangedEvent(List<string> change_type_list)
|
{
|
for (int i = this.stepProgressBar1.Items.Count; i > 0; i--)
|
{
|
if (this.stepProgressBar1.Items.Count < 2)
|
break;
|
this.stepProgressBar1.Items.RemoveAt(1);
|
}
|
if (change_type_list == null || !change_type_list.Any())
|
{
|
|
}
|
else
|
{
|
foreach (var change_type in change_type_list)
|
{
|
var name = HydroParterCatalogHelper.GetName(change_type);
|
Add(name);
|
}
|
Add("变更记录");
|
}
|
}
|
|
private void Add(string caption)
|
{
|
var step_pb_item = new StepProgressBarItem();
|
step_pb_item.ContentBlock2.Caption = caption;
|
step_pb_item.Options.Indicator.ActiveStateDrawMode = IndicatorDrawMode.Full;
|
step_pb_item.Options.Indicator.ActiveStateImageOptions.SvgImage = null;
|
step_pb_item.Options.Indicator.InactiveStateImageOptions.SvgImage = null;
|
step_pb_item.State = StepProgressBarItemState.Inactive;
|
this.stepProgressBar1.Items.Add(step_pb_item);
|
}
|
|
|
//选择页面改变
|
private void _wizard_SelectedPageChangedEvent(IWizardPage<CreateXhsSchemeViewModel> page, int index)
|
{
|
this.itemForPrev.Visibility = page.AllowPrev ? LayoutVisibility.Always : LayoutVisibility.Never;
|
this.itemForNext.Visibility = page.AllowNext ? LayoutVisibility.Always : LayoutVisibility.Never;
|
this.itemForCancel.Visibility = page.AllowCancel ? LayoutVisibility.Always : LayoutVisibility.Never;
|
this.itemForComplete.Visibility = page.AllowComplete ? LayoutVisibility.Always : LayoutVisibility.Never;
|
this.navigationFrame1.SelectedPageIndex = index;
|
this.stepProgressBar1.SelectedItemIndex = index;
|
}
|
|
//选择页面状态改变
|
private void _wizard_SelectedPageStateChangedEvent(IWizardPage<CreateXhsSchemeViewModel> page, int index)
|
{
|
this.itemForPrev.Visibility = page.AllowPrev ? LayoutVisibility.Always : LayoutVisibility.Never;
|
this.itemForNext.Visibility = page.AllowNext ? LayoutVisibility.Always : LayoutVisibility.Never;
|
this.itemForCancel.Visibility = page.AllowCancel ? LayoutVisibility.Always : LayoutVisibility.Never;
|
this.itemForComplete.Visibility = page.AllowComplete ? 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 btnCancel_Click(object sender, EventArgs e)
|
{
|
if (_wizard != null)
|
{
|
var bol = _wizard.Cancel();
|
if (bol)
|
{
|
this.DialogResult = DialogResult.Cancel;
|
this.Close();
|
}
|
}
|
|
}
|
|
//完成
|
private void btnComplete_Click(object sender, EventArgs e)
|
{
|
if (_wizard != null)
|
{
|
var bol = _wizard.Complete();
|
if (bol)
|
{
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
}
|
|
}
|
|
//正在关闭
|
private void CreateXhsSchemeDlg_FormClosing(object sender, FormClosingEventArgs e)
|
{
|
if (_wizard != null)
|
{
|
if (this.DialogResult == DialogResult.OK)
|
{
|
/* if (!_wizard.Complete())
|
{
|
e.Cancel = true;
|
}*/
|
}
|
else if (this.DialogResult == DialogResult.Cancel)
|
{
|
if (!_wizard.Cancel())
|
{
|
e.Cancel = true;
|
}
|
}
|
else
|
{
|
e.Cancel = true;
|
}
|
}
|
|
}
|
|
|
|
}
|
}
|