namespace HStation.WinFrmUI
|
{
|
public partial class SetXhsProjectMapDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public SetXhsProjectMapDlg()
|
{
|
InitializeComponent();
|
this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
|
this.layoutControl1.SetupLayoutControl();
|
this.generalOkAndCancelCtrl1.OkEvent += GeneralOkAndCancelCtrl1_OkEvent;
|
this.mapSetSimpleMarkerContainer1.LoadCompletedEvent += MapSetSimpleMarkerContainer1_LoadCompletedEvent;
|
this.mapSetSimpleMarkerContainer1.SetMarkerEvent += MapSetSimpleMarkerContainer1_SetMarkerEvent;
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public event Action<XhsProjectExtensionsVmo, Yw.Vmo.MapInfoVmo> ReloadDataEvent;
|
|
private XhsProjectExtensionsVmo _project = null;//项目信息
|
private Yw.Vmo.MapInfoVmo _mapinfo = null; //地图信息
|
private Yw.Model.Map.Marker _maker = null; //地图点信息
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public async void SetBindingData(XhsProjectExtensionsVmo project, Yw.Vmo.MapInfoVmo mapInfo)
|
{
|
if (project == null)
|
{
|
return;
|
}
|
_project = project;
|
_mapinfo = mapInfo;
|
if (_mapinfo == null)
|
{
|
_mapinfo.ObjectType = HStation.Xhs.DataType.XhsProject;
|
_mapinfo.ObjectID = _project.ID;
|
_mapinfo.ObjectName = _project.Name;
|
_mapinfo.Purpose = Yw.Map.Purpose.Location;
|
_mapinfo.Kind = Yw.Map.Kind.Gaodei;
|
_mapinfo.Shape = Yw.Map.Shape.Marker;
|
}
|
if (mapInfo != null)
|
{
|
_maker = Yw.Model.Map.Marker.ToModel(_mapinfo.Position);
|
}
|
await this.mapSetSimpleMarkerContainer1.InitialContainer();
|
this.txtAddress.EditValue = _project.Address;
|
if (string.IsNullOrEmpty(_project.Address))
|
{
|
if (_maker != null)
|
{
|
this.txtAddress.EditValue = _maker.Address;
|
}
|
}
|
|
}
|
|
//加载完成事件
|
private async void MapSetSimpleMarkerContainer1_LoadCompletedEvent()
|
{
|
if (_maker != null)
|
{
|
await this.mapSetSimpleMarkerContainer1.LoadMarker(_maker);
|
}
|
}
|
|
//设置
|
private void MapSetSimpleMarkerContainer1_SetMarkerEvent(Yw.Model.Map.Marker obj)
|
{
|
_maker = obj;
|
if (string.IsNullOrEmpty(this.txtAddress.Text.Trim()))
|
{
|
this.txtAddress.EditValue = obj.Address;
|
}
|
}
|
|
//确定
|
private async void GeneralOkAndCancelCtrl1_OkEvent()
|
{
|
if (_project == null)
|
{
|
return;
|
}
|
if (_mapinfo == null)
|
{
|
return;
|
}
|
if (_maker == null)
|
{
|
TipFormHelper.ShowWarn("请设置地图位置!");
|
return;
|
}
|
var address = this.txtAddress.Text.Trim();
|
if (!string.IsNullOrEmpty(address))
|
{
|
_project.Address = this.txtAddress.Text.Trim();
|
var bol = await BLLFactory<HStation.BLL.XhsProjectExtensions>.Instance.Update(_project);
|
if (!bol)
|
{
|
TipFormHelper.ShowError("地址更新失败!");
|
return;
|
}
|
}
|
|
_mapinfo.Position = _maker.ToJson();
|
if (_mapinfo.ID < 1)
|
{
|
_mapinfo.ID = await BLLFactory<Yw.BLL.MapInfo>.Instance.Insert(_mapinfo);
|
if (_mapinfo.ID < 1)
|
{
|
TipFormHelper.ShowError("地图位置设置失败!");
|
return;
|
}
|
}
|
else
|
{
|
var bol = await BLLFactory<Yw.BLL.MapInfo>.Instance.Update(_mapinfo);
|
if (!bol)
|
{
|
TipFormHelper.ShowError("地图位置设置失败!");
|
return;
|
}
|
}
|
|
var mapInfo = await BLLFactory<Yw.BLL.MapInfo>.Instance.GetByID(_mapinfo.ID);
|
this.ReloadDataEvent?.Invoke(_project, mapInfo);
|
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
|
}
|
|
}
|
}
|