X1D1DTOParamEditor.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. using DevExpress.Mvvm.ModuleInjection.Native;
  2. using DevExpress.XtraEditors;
  3. using DevExpress.XtraEditors.DXErrorProvider;
  4. using DevExpress.XtraLayout;
  5. using DevExpress.XtraMap;
  6. using DevExpress.XtraTreeList.Data;
  7. using DxHelper;
  8. using ExtensionsDev;
  9. using System;
  10. using System.CodeDom;
  11. using System.Collections.Generic;
  12. using System.ComponentModel;
  13. using System.Data;
  14. using System.Data.Entity;
  15. using System.Data.Entity.Migrations;
  16. using System.Drawing;
  17. using System.Linq;
  18. using System.Text;
  19. using System.Threading.Tasks;
  20. using System.Windows.Documents;
  21. using System.Windows.Forms;
  22. using XdCxRhDW.Core.Api;
  23. using XdCxRhDW.Repostory.EFContext;
  24. using XdCxRhDW.Repostory.Model;
  25. namespace XdCxRhDW.App.EditForms
  26. {
  27. public partial class X1D1DTOParamEditor : DevExpress.XtraEditors.XtraUserControl
  28. {
  29. private MapControl mapControl1;
  30. private PosRes info;
  31. private CgRes cg;
  32. private List<SatInfo> listSat;
  33. public X1D1DTOParamEditor(PosRes info, MapControl mapControl)
  34. {
  35. InitializeComponent();
  36. this.Text = $"{info.PosResType.GetEnumDisplayName()}时差参数";
  37. this.info = info;
  38. this.listSat = new List<SatInfo>();
  39. this.mapControl1 = mapControl;
  40. //this.StartPosition = FormStartPosition.CenterParent;
  41. txtsatStation.EditValueChanged += TxtsatStation_EditValueChanged;
  42. txtcdbStation.EditValueChanged += TxtcdbStation_EditValueChanged;
  43. txtRefLocation.EditValueChanged += TxtRefLocation_EditValueChanged;
  44. }
  45. private void TxtRefLocation_EditValueChanged(object sender, EventArgs e)
  46. {
  47. txtRefLocation.CheckLonLat(dxErrorProvider, "参考站");
  48. }
  49. private void TxtcdbStation_EditValueChanged(object sender, EventArgs e)
  50. {
  51. txtcdbStation.CheckLonLat(dxErrorProvider, "超短波");
  52. }
  53. private void TxtsatStation_EditValueChanged(object sender, EventArgs e)
  54. {
  55. txtsatStation.CheckLonLat(dxErrorProvider, "接收站");
  56. }
  57. private async void X1D1DTOParamEditor_Load(object sender, EventArgs e)
  58. {
  59. StationRes station;
  60. using (RHDWContext db = new RHDWContext())
  61. {
  62. listSat = await db.SatInfos.ToListAsync();
  63. }
  64. using (RHDWPartContext db = RHDWPartContext.GetContext(info.SigTime))
  65. {
  66. cg = await db.CgRes.Where(m => m.ID == info.CgResID).FirstOrDefaultAsync();
  67. station = await db.StationRes.Where(m => m.ID == info.StationResID).FirstOrDefaultAsync();
  68. }
  69. if (cg != null)
  70. {
  71. this.txtDtoCdb.Text = $"{cg.DtoCdb.Value:f3}";
  72. this.txtYbMain.Text = $"{cg.YbMainDto.Value:f3}";
  73. this.sigTime.EditValue = info.SigTime;
  74. this.txtMainX.Text = $"{cg.MainX.Value:f3}";
  75. this.txtMainY.Text = $"{cg.MainY.Value:f3}";
  76. this.txtMainZ.Text = $"{cg.MainZ.Value:f3}";
  77. }
  78. if (station != null)
  79. {
  80. this.txtsatStation.Text = $"{station.SatTxLon:f3},{station.SatTxLat:f3}";
  81. this.txtcdbStation.Text = $"{station.CdbTxLon:f3},{station.CdbTxLat:f3}";
  82. this.txtRefLocation.Text = $"{station.RefLon:f3},{station.RefLat:f3}";
  83. }
  84. }
  85. public bool CheckParam()
  86. {
  87. if (!txtsatStation.CheckLonLat(dxErrorProvider, "接收站"))
  88. {
  89. return false;
  90. }
  91. if (!txtcdbStation.CheckLonLat(dxErrorProvider, "超短波"))
  92. {
  93. return false;
  94. }
  95. if (!txtRefLocation.CheckLonLat(dxErrorProvider, "参考站"))
  96. {
  97. return false;
  98. }
  99. return true;
  100. }
  101. private void btnOk_Click(object sender, EventArgs e)
  102. {
  103. if (!CheckParam()) { return; }
  104. try
  105. {
  106. var MsAnt = txtsatStation.GetLonLat();
  107. var CDBAnt = txtcdbStation.GetLonLat();
  108. var RefGeod = txtRefLocation.GetLonLat();
  109. var DtoCdb = Convert.ToDouble(this.txtDtoCdb.Text);
  110. var YbMainDto = Convert.ToDouble(this.txtYbMain.Text);
  111. var MainX = Convert.ToDouble(this.txtMainX.Text);
  112. var MainY = Convert.ToDouble(this.txtMainY.Text);
  113. var MainZ = Convert.ToDouble(this.txtMainZ.Text);
  114. double[] msEph = new double[] { MainX, MainY, MainZ, 0, 0, 0 };
  115. DtoLineXdOption dtoLineXd = new DtoLineXdOption();
  116. dtoLineXd.MsEph = msEph;
  117. dtoLineXd.MsAnt = MsAnt;
  118. dtoLineXd.CDBAnt = CDBAnt;
  119. dtoLineXd.RefGeod = RefGeod;
  120. dtoLineXd.xdDto = DtoCdb;
  121. dtoLineXd.RefDto = YbMainDto;
  122. dtoLineXd.PosLon = info.PosLon;
  123. dtoLineXd.PosLat = info.PosLat;
  124. var msat = listSat.FirstOrDefault(m => m.SatCode == cg.MainCode.Value)?.Sat;
  125. if (string.IsNullOrWhiteSpace(msat)) msat = cg.MainCode.Value.ToString();
  126. var xdDtoLine = DrawDtoLineHelper.DtoLineXd(dtoLineXd);
  127. mapControl1.DrawDtoPonit($"[{msat},超短{CDBAnt[0]}°]带参时差线", xdDtoLine);
  128. }
  129. catch (Exception ex)
  130. {
  131. Serilog.Log.Error(ex, $"绘制{info.PosResType.GetEnumDisplayName()}时差线失败.PosID={info.ID},SigTime={info.SigTime}");
  132. DxHelper.MsgBoxHelper.ShowWarning($"绘制{info.PosResType.GetEnumDisplayName()}时差线失败");
  133. }
  134. }
  135. }
  136. }