using DevExpress.XtraBars.Customization; using Yw.CAL.HttpClient; namespace HStation.WinFrmUI { public partial class InputXhsProjectInfoWizardPage : DevExpress.XtraEditors.XtraUserControl, Yw.WinFrmUI.IWizardPage { public InputXhsProjectInfoWizardPage() { InitializeComponent(); } /// /// 页面状态改变事件 /// public event Action PageStateChangedEvent; private ImportXhsProjectViewModel _vm = null;//操作对象 private bool _isInitialize = false;//是否初始化 private Lazy _bllProject = new(() => new HStation.BLL.XhsProject());//项目bll private Lazy _bllFlag = new(() => new Yw.BLL.SysFlag());//标签bll public static Action AutoAddItem; public static Action DeleteItem; public static bool AllowImport = false; /// /// 初始化 /// public async void InitialPage(ImportXhsProjectViewModel t) { if (_isInitialize) { return; } _vm = t; _isInitialize = true; var allFlagList = await _bllFlag.Value.GetBySysType(HStation.Xhs.DataType.XhsProject); if (allFlagList == null) return; this.setFlagsEditCtrl1.SetBindingData(allFlagList.Select(x => x.Name).ToList(), null); } /// /// 允许上一步 /// public bool AllowPrev { get { return false; } } /// /// 允许下一步 /// public bool AllowNext { get { _vm.ZipFile = this.btnEditSelectModelFile.Text.Trim(); /* if (_vm.ZipFile != string.Empty) { AllowImport = true; AutoAddItem.Invoke(); } else { AllowImport = false; DeleteItem.Invoke(); }*/ return _isInitialize; } } /// /// 允许取消 /// public bool AllowCancel { get { return true; } } /// /// 允许完成 /// public bool AllowComplete { get { return false; } } /// /// 能否上一步 /// public bool CanPrev() { return true; } /// /// 能否下一步 /// public bool CanNext() { if (!_isInitialize) { return false; } this.dxErrorProvider1.ClearErrors(); if (string.IsNullOrEmpty(this.txtName.Text.Trim())) { this.dxErrorProvider1.SetError(this.txtName, "必填项"); return false; } var tagName = this.txtTagNme.Text.Trim(); if (!string.IsNullOrEmpty(tagName)) { if (_bllProject.Value.IsExistTagName(tagName).Result) { this.dxErrorProvider1.SetError(this.txtTagNme, "标记已存在"); return false; } } _vm.Name = this.txtName.Text.Trim(); _vm.Customer = this.txtCustomer.Text.Trim(); // _vm.Address = this.txtAddress.Text.Trim(); _vm.Flags = null; _vm.TagName = tagName; _vm.Description = this.txtDescription.Text.Trim(); return true; } /// /// 能否关闭 /// public bool CanCancel() { return true; } /// /// 能否完成 /// public bool CanComplete() { return false; } private void btnEditSelectModelFile_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { if (e.Button.Tag.ToString() == "Local") { var suffix = Settings.XhsParasHelper.Xhs.File.Suffix; var dlg = new OpenFileDialog(); dlg.Filter = $"模型文件(*{suffix})|*{suffix}"; dlg.FilterIndex = 1; if (dlg.ShowDialog() == DialogResult.OK) { var fileName = dlg.FileName; this.btnEditSelectModelFile.EditValue = fileName; } } else { var dlg = new SelectXhsProjectTransferFileDlg(); dlg.SetBindingData(); dlg.ReloadDataEvent += async (rhs) => { var fileName = await BLLFactory.Instance.Download(rhs.StorageHouse, rhs.StorageCode); this.btnEditSelectModelFile.EditValue = fileName; }; dlg.ShowDialog(); } } } }