ningshuxia
2025-03-20 5aa0bae63df66d66fefb6a0d180eb3774c172d3a
WinFrmUI/PBS.WinFrmUI.Hydro/02-quick-modeling/02-place/QuickModelingPlaceWizardPage.cs
@@ -8,7 +8,7 @@
            this.layoutControl1.SetupLayoutControl();
            this.mapSetSimpleMarkerContainer1.LoadCompletedEvent += MapSetSimpleMarkerContainer1_LoadCompletedEvent;
            this.mapSetSimpleMarkerContainer1.SetMarkerEvent += MapSetSimpleMarkerContainer1_SetMarkerEvent;
            this.imgCmbPlaceType.Properties.AddEnum<PBS.ePlaceType>();
        }
        /// <summary>
@@ -17,10 +17,9 @@
        public event Action PageStateChangedEvent;
        private QuickModelingViewModel _vm = null;//操作对象
        private bool _isCompleted = false;//是否创建完成
        private bool _createResult = false;//创建结果
        private bool _isCompleted = false;//是否创建完成
        /// <summary>
        /// 初始化页面
@@ -31,32 +30,24 @@
            {
                return;
            }
            _vm = vm;
            _vm = vm;
            _isCompleted = false;
            _createResult = false;
            //_createResult = await QuickModelingHelper.Create(vm, (msg, color) =>
            // {
            //     var drawItem = new DrawItemViewModel
            //     {
            //         Text = msg,
            //         Color = color
            //     };
            //     this.listBoxControl1.Items.Add(drawItem);
            // }, (max, current) =>
            // {
            //     this.progressBarControl1.Properties.Maximum = max;
            //     this.progressBarControl1.Position = current;
            //     //替代方案
            //     // this.progressBarControl1.Properties.Step = current;
            //     // this.progressBarControl1.PerformStep();
            // });
            _isCompleted = true;
            if (!_createResult)
            if (!this.mapSetSimpleMarkerContainer1.IsInitialized)
            {
                //this.progressBarControl1.Position = 0;
                //this.itemForProgress.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            }
                await this.mapSetSimpleMarkerContainer1.InitialContainer();
            }
            this.txtName.EditValue = _vm.Place.Name;
            this.txtTagName.EditValue = _vm.Place.TagName;
            this.txtAddress.EditValue = _vm.Place.Address;
            this.txtDescription.EditValue = _vm.Place.Description;
            this.placeInfoCtrl1.Set(_vm.Place.PlaceType, _vm.Place.PlaceInfo);
            var allFlagsList = await BLLFactory<Yw.BLL.SysFlag>.Instance.GetBySysType(DataType.PBSPlace);
            this.setFlagsEditCtrl1.SetBindingData(allFlagsList?.Select(x => x.Name).Distinct().ToList(), _vm.Place.Flags);
            this.imgCmbPlaceType.EditValue = _vm.Place.PlaceType;
            _isCompleted = true;
            this.PageStateChangedEvent?.Invoke();
        }
@@ -73,11 +64,61 @@
        //设置
        private void MapSetSimpleMarkerContainer1_SetMarkerEvent(Yw.Model.Map.Marker obj)
        {
            _vm.Marker = obj;
            if (string.IsNullOrEmpty(this.txtAddress.Text.Trim()))
            _vm.Marker = obj;
            this.txtAddress.EditValue = obj.Address;
        }
        //场所类型变换
        private void imgCmbPlaceType_EditValueChanged(object sender, EventArgs e)
        {
            var placeType = (PBS.ePlaceType)this.imgCmbPlaceType.EditValue;
            this.placeInfoCtrl1.Set(placeType);
        }
        //验证
        private bool Verify()
        {
            return this.Invoke(() =>
            {
                this.txtAddress.EditValue = obj.Address;
                var isExist = true;
                this.dxErrorProvider1.ClearErrors();
                var name = this.txtName.Text.Trim();
                if (string.IsNullOrEmpty(name))
                {
                    this.dxErrorProvider1.SetError(this.txtName, "必填项");
                    isExist= false;
                }
                if (!this.placeInfoCtrl1.Verify())
                {
                    isExist = false;
                }
                if (_vm.Marker==null)
                {
                    isExist = false;
                    TipFormHelper.ShowWarn("请设置地图信息!");
                }
                return isExist;
            });
        }
        //保存
        private bool Save()
        {
            if (!Verify())
            {
                return false;
            }
            _vm.Place.Name = this.txtName.Text.Trim();
            _vm.Place.PlaceType = (ePlaceType)this.imgCmbPlaceType.EditValue;
            _vm.Place.Flags = this.setFlagsEditCtrl1.SelectedFlagList;
            _vm.Place.TagName = this.txtTagName.Text.Trim();
            _vm.Place.Address = this.txtAddress.Text.Trim();
            _vm.Place.Description = this.txtDescription.Text.Trim();
            _vm.Place.PlaceInfo=this.placeInfoCtrl1.Get();
            return true;
        }
@@ -87,15 +128,7 @@
        public bool AllowPrev
        {
            get
            {
                if (!_isCompleted)
                {
                    return false;
                }
                if (!_createResult)
                {
                    return true;
                }
            {
                return false;
            }
        }
@@ -107,11 +140,11 @@
        {
            get
            {
                if (_createResult)
                if (!_isCompleted)
                {
                    return true;
                }
                return false;
                    return false;
                }
                return true;
            }
        }
@@ -121,11 +154,7 @@
        public bool AllowCancel
        {
            get
            {
                if (!_createResult)
                {
                    return true;
                }
            {
                return false;
            }
        }
@@ -155,7 +184,7 @@
        /// </summary>
        public Task<bool> CanNext()
        {
            return Task.Run(() => this.AllowNext);
            return Task.Run(() => Save());
        }
        /// <summary>
@@ -174,6 +203,5 @@
            return Task.Run(() => this.AllowComplete);
        }
    }
}