| | |
| | | namespace HStation.WinFrmUI |
| | | { |
| | | public partial class GenerateXhsProjectWizardPage : DevExpress.XtraEditors.XtraUserControl, IWizardPage<ImportXhsProjectViewModel> |
| | | public partial class GenerateXhsProjectWizardPage : DevExpress.XtraEditors.XtraUserControl, IWizardPageAsync<ImportXhsProjectViewModel> |
| | | { |
| | | public GenerateXhsProjectWizardPage() |
| | | { |
| | |
| | | /// </summary> |
| | | public event Action PageStateChangedEvent; |
| | | |
| | | private bool _isInitialize = false;//是否初始化 |
| | | private bool _importResult = false;//导入结果 |
| | | private ImportXhsProjectViewModel _vm = null;//操作对象 |
| | | private bool _importResult = false;//导入结果 |
| | | |
| | | private class ListItemWithColor |
| | | |
| | | //绘制视图 |
| | | private class DrawItemViewModel |
| | | { |
| | | /// <summary> |
| | | /// 文本 |
| | | /// </summary> |
| | | public string Text { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 颜色 |
| | | /// </summary> |
| | | public Color Color { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public override string ToString() |
| | | { |
| | | return null; |
| | | return string.Empty; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// 初始化页面 |
| | | /// </summary> |
| | | public async void InitialPage(ImportXhsProjectViewModel vm) |
| | | { |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | _vm = vm; |
| | | _isInitialize = false; |
| | | _importResult = false; |
| | | this.listBoxControl1.Items.Clear(); |
| | | _importResult = await ImportXhsProjectHelper.Import(vm, (msg, color) => |
| | | { |
| | | ListItemWithColor itemWithColor = new ListItemWithColor |
| | | var drawItem = new DrawItemViewModel |
| | | { |
| | | Text = msg, |
| | | Color = color |
| | | }; |
| | | this.listBoxControl1.Items.Add(itemWithColor); |
| | | this.listBoxControl1.Items.Add(drawItem); |
| | | }, (max, current) => |
| | | { |
| | | this.progressBarControl1.Properties.Maximum = max; |
| | |
| | | this.progressBarControl1.Position = 0; |
| | | this.itemForProgress.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
| | | } |
| | | _isInitialize = true; |
| | | this.PageStateChangedEvent?.Invoke(); |
| | | } |
| | | |
| | |
| | | { |
| | | get |
| | | { |
| | | if (_isInitialize) |
| | | if (!_importResult) |
| | | { |
| | | if (!_importResult) |
| | | { |
| | | return true; |
| | | } |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | |
| | | { |
| | | get |
| | | { |
| | | if (_isInitialize) |
| | | if (_importResult) |
| | | { |
| | | if (_importResult) |
| | | { |
| | | return true; |
| | | } |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | |
| | | { |
| | | get |
| | | { |
| | | if (_isInitialize) |
| | | if (!_importResult) |
| | | { |
| | | if (!_importResult) |
| | | { |
| | | return true; |
| | | } |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | |
| | | /// </summary> |
| | | public bool AllowComplete |
| | | { |
| | | get { return false; } |
| | | get |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 能否上一步 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public bool CanPrev() |
| | | public Task<bool> CanPrev() |
| | | { |
| | | return this.AllowPrev; |
| | | return Task.Run(() => this.AllowPrev); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 能否下一步 |
| | | /// </summary> |
| | | public bool CanNext() |
| | | public Task<bool> CanNext() |
| | | { |
| | | return this.AllowNext; |
| | | return Task.Run(() => this.AllowNext); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 能否取消 |
| | | /// </summary> |
| | | public bool CanCancel() |
| | | public Task<bool> CanCancel() |
| | | { |
| | | return this.AllowCancel; |
| | | return Task.Run(() => this.AllowCancel); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 能否完成 |
| | | /// </summary> |
| | | public bool CanComplete() |
| | | public Task<bool> CanComplete() |
| | | { |
| | | return false; |
| | | return Task.Run(() => this.AllowComplete); |
| | | } |
| | | |
| | | //绘制项 |
| | | private void listBoxControl1_DrawItem(object sender, DevExpress.XtraEditors.ListBoxDrawItemEventArgs e) |
| | | { |
| | | // 获取当前项目的索引 |
| | |
| | | if (index >= 0) |
| | | { |
| | | // 获取当前项目 |
| | | ListItemWithColor item = (ListItemWithColor)listBoxControl1.Items[index]; |
| | | DrawItemViewModel item = (DrawItemViewModel)listBoxControl1.Items[index]; |
| | | |
| | | // 设置字体和颜色 |
| | | Font font = new Font("Arial", 15); |
| | |
| | | e.Graphics.DrawString(item.Text, font, brush, e.Bounds); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |