using HStation.Vmo; namespace HStation.WinFrmUI.Xhs { public partial class AddProjectDlg : DevExpress.XtraEditors.XtraForm { public AddProjectDlg() { InitializeComponent(); this.Load += AddProjectDlg_Load; } private async void AddProjectDlg_Load(object sender, EventArgs e) { this.mapSetSimpleMarkerContainer1.SetMarkerEvent += MapSetSimpleMarkerContainer1_SetMarkerEvent; await this.mapSetSimpleMarkerContainer1.InitialContainer(); } public event Func> ReloadDataEvent; private Yw.Model.Map.Marker _maker = null; //地图点信息 private Yw.Vmo.MapInfoVmo _mapinfo = null; //地图信息 //数据验证 private bool Valid() { this.dxErrorProvider1.ClearErrors(); if (string.IsNullOrEmpty(TextProjectName.Text.Trim())) { this.dxErrorProvider1.SetError(this.TextProjectName, "必填项"); return false; } if (string.IsNullOrEmpty(TextCustomerName.Text.Trim())) { this.dxErrorProvider1.SetError(this.TextCustomerName, "必填项"); return false; } return true; } //设置位置 private void MapSetSimpleMarkerContainer1_SetMarkerEvent(Yw.Model.Map.Marker obj) { _maker = obj; this.TextAddress.EditValue = obj.Address; } //确定 private async void BtnOk_Click(object sender, EventArgs e) { if (!Valid()) return; var model = new XhsProjectExtensionsVmo(); model.Address = this.TextAddress.Text.Trim(); model.Customer = this.TextCustomerName.Text.Trim(); model.Description = this.TextDescription.Text.Trim(); model.Name = this.TextProjectName.Text.Trim(); model.TagName = this.TextTagName.Text.Trim(); model.SiteList = new List { new XhsProjectSiteVmo { Name=this.TextProjectName.Text, Description=this.TextDescription.Text, } }; if (_maker != null) { _mapinfo = new Yw.Vmo.MapInfoVmo(); _mapinfo.ObjectType = HStation.Xhs.DataType.XhsProject; _mapinfo.Purpose = Yw.Map.Purpose.Location; _mapinfo.Kind = Yw.Map.Kind.Gaodei; _mapinfo.Shape = Yw.Map.Shape.Marker; _mapinfo.Position = _maker.ToJson(); } if (await this.ReloadDataEvent.Invoke(model, _mapinfo)) { TipFormHelper.ShowSucceed("添加成功!"); } else { TipFormHelper.ShowError("添加失败!"); } this.DialogResult = DialogResult.OK; this.Close(); } } }