ningshuxia
2025-03-28 ce9752fd657c6689ea64929eb962146e2730624e
WinFrmUI/PBS.WinFrmUI.Hydro/02-quick-modeling/02-place/QuickModelingPlaceWizardPage.cs
@@ -1,4 +1,6 @@
namespace PBS.WinFrmUI.Hydro
using Microsoft.Web.WebView2.Core;
namespace PBS.WinFrmUI.Hydro
{
    public partial class QuickModelingPlaceWizardPage : DevExpress.XtraEditors.XtraUserControl, IWizardPageAsync<QuickModelingViewModel>
    {
@@ -6,10 +8,12 @@
        {
            InitializeComponent();
            this.layoutControl1.SetupLayoutControl();
            this.mapSetSimpleMarkerContainer1.LoadCompletedEvent += MapSetSimpleMarkerContainer1_LoadCompletedEvent;
            this.mapSetSimpleMarkerContainer1.SetMarkerEvent += MapSetSimpleMarkerContainer1_SetMarkerEvent;
            this.mapSetPlaceMarkerContainer1.LoadCompletedEvent += MapSetPlaceMarkerContainer1_LoadCompletedEvent;
            this.mapSetPlaceMarkerContainer1.SetMarkerEvent += MapSetPlaceMarkerContainer1_SetMarkerEvent;
            this.mapSetPlaceMarkerContainer1.SetMapBoundsEvent += MapSetPlaceMarkerContainer1_SetMapBoundsEvent;
            this.imgCmbPlaceType.Properties.AddEnum<PBS.ePlaceType>();
        }
        /// <summary>
        /// 状态改变事件
@@ -33,9 +37,9 @@
            _vm = vm;  
            _isCompleted = false;
            if (!this.mapSetSimpleMarkerContainer1.IsInitialized)
            if (!this.mapSetPlaceMarkerContainer1.IsInitialized)
            {
                await this.mapSetSimpleMarkerContainer1.InitialContainer();
                await this.mapSetPlaceMarkerContainer1.InitialContainer();
            } 
            this.txtName.EditValue = _vm.Place.Name;
@@ -53,19 +57,27 @@
        //加载完成事件
        private async void MapSetSimpleMarkerContainer1_LoadCompletedEvent()
        private async void MapSetPlaceMarkerContainer1_LoadCompletedEvent()
        {
            if (_vm.Marker != null)
            {
                await this.mapSetSimpleMarkerContainer1.LoadMarker(_vm.Marker);
                await this.mapSetPlaceMarkerContainer1.LoadMarker(_vm.Marker);
            }
        }
        //设置
        private void MapSetSimpleMarkerContainer1_SetMarkerEvent(Yw.Model.Map.Marker obj)
        //设置地图边界
        private void MapSetPlaceMarkerContainer1_SetMapBoundsEvent(Yw.Model.Map.Point southWest, Yw.Model.Map.Point northEast)
        {
            _vm.Marker = obj;
            this.txtAddress.EditValue = obj.Address;
            _vm.SouthWest = southWest;
            _vm.NorthEast = northEast;
        }
        //设置点
        private void MapSetPlaceMarkerContainer1_SetMarkerEvent(Yw.Model.Map.Marker marker)
        {
            _vm.Marker = marker;
            this.txtAddress.EditValue = marker.Address;
        }
@@ -75,6 +87,9 @@
            var placeType = (PBS.ePlaceType)this.imgCmbPlaceType.EditValue;
            this.placeInfoCtrl1.Set(placeType);
        }
        //验证
        private bool Verify()
@@ -92,23 +107,43 @@
                if (!this.placeInfoCtrl1.Verify())
                {
                    isExist = false;
                }
                }
                if (_vm.Marker==null)
                {
                    isExist = false;
                    TipFormHelper.ShowWarn("请设置地图信息!");
                    TipFormHelper.ShowWarn("请设置地图信息!");
                }
                if (_vm.SouthWest == null || _vm.NorthEast == null)
                {
                    isExist = false;
                    TipFormHelper.ShowWarn("请设置地图边界信息!");
                }
                return isExist;
            });
        }
        //保存
        private bool Save()
        private async Task<bool> Save()
        {
            if (!Verify())
            {
                return false;
            }
            var sizeInfo= await this.mapSetPlaceMarkerContainer1.CaptureImage(_vm.TempBackgroundImageUrl,_vm.SouthWest,_vm.NorthEast);
            if (sizeInfo == null)
            {
                _vm.IsCaptureImage = false;
                TipFormHelper.ShowError("截图失败!");
                return false;
            }
            _vm.BackgroundHeight = sizeInfo.Value.Height;
            _vm.BackgroundWidth = sizeInfo.Value.Width;
            _vm.Zoom = sizeInfo.Value.Zoom;
            _vm.IsCaptureImage = true;
            _vm.Place.Name = this.txtName.Text.Trim();
            _vm.Place.PlaceType = (ePlaceType)this.imgCmbPlaceType.EditValue;
@@ -184,7 +219,7 @@
        /// </summary>
        public Task<bool> CanNext()
        {
            return Task.Run(() => Save());
            return Task.Run(async () => await Save());
        }
        /// <summary>