X1D1DTOParamEditor.cs 5.3 KB

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