using DevExpress.XtraLayout.Utils;
|
|
namespace HStation.WinFrmUI
|
{
|
public partial class ImportXhsProjectDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public ImportXhsProjectDlg()
|
{
|
InitializeComponent();
|
this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
|
}
|
|
private ImportXhsProjectViewModel _vm = null;//操作对象
|
private ImportXhsProjectManager _wizard;//步骤
|
|
/// <summary>
|
///
|
/// </summary>
|
public ImportXhsProjectViewModel ViewModel
|
{
|
get { return _vm; }
|
}
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData()
|
{
|
_vm = new ImportXhsProjectViewModel();
|
_wizard = new ImportXhsProjectManager(_vm);
|
_wizard.SelectedPageChangedEvent += _wizard_SelectedPageChangedEvent;
|
_wizard.SelectedPageStateChangedEvent += _wizard_SelectedPageStateChangedEvent; ;
|
_wizard.InitialManager(new IWizardPageAsync<ImportXhsProjectViewModel>[] {
|
this.inputXhsProjectInfoWizardPage,
|
this.setXhsProjectMapLocationWizardPage,
|
this.generateXhsProjectWizardPage,
|
this.projectResultShowPanel1
|
});
|
}
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(XhsProjectExtensionsVmo project, Yw.Vmo.MapInfoVmo mapInfo)
|
{
|
_vm = new ImportXhsProjectViewModel(project, mapInfo);
|
_wizard = new ImportXhsProjectManager(_vm);
|
_wizard.SelectedPageChangedEvent += _wizard_SelectedPageChangedEvent;
|
_wizard.SelectedPageStateChangedEvent += _wizard_SelectedPageStateChangedEvent; ;
|
_wizard.InitialManager(new IWizardPageAsync<ImportXhsProjectViewModel>[] {
|
this.inputXhsProjectInfoWizardPage,
|
this.setXhsProjectMapLocationWizardPage,
|
this.generateXhsProjectWizardPage,
|
this.projectResultShowPanel1
|
});
|
}
|
|
//选择页面改变
|
private void _wizard_SelectedPageChangedEvent(IWizardPageAsync<ImportXhsProjectViewModel> 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(IWizardPageAsync<ImportXhsProjectViewModel> 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 async void btnPrev_Click(object sender, EventArgs e)
|
{
|
if (_wizard != null)
|
{
|
await _wizard.Prev();
|
}
|
}
|
|
//下一步
|
private async void btnNext_Click(object sender, EventArgs e)
|
{
|
if (_wizard != null)
|
{
|
await _wizard.Next();
|
}
|
}
|
|
//取消
|
private async void btnCancel_Click(object sender, EventArgs e)
|
{
|
if (_wizard != null)
|
{
|
var bol = await _wizard.Cancel();
|
if (bol)
|
{
|
this.DialogResult = DialogResult.Cancel;
|
this.Close();
|
}
|
}
|
}
|
|
//完成
|
private async void btnComplete_Click(object sender, EventArgs e)
|
{
|
if (_wizard != null)
|
{
|
var bol = await _wizard.Complete();
|
if (bol)
|
{
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
}
|
}
|
|
//正在关闭
|
private async void ImportXhsProjectDlg_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 (!await _wizard.Cancel())
|
{
|
e.Cancel = true;
|
}
|
}
|
else
|
{
|
e.Cancel = true;
|
}
|
}
|
}
|
}
|
}
|