X1D1PosParamEditor.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 X1D1PosParamEditor : DevExpress.XtraEditors.XtraUserControl
  28. {
  29. private MapControl mapControl1;
  30. private PosRes info;
  31. private CgRes cg;
  32. private List<SatInfo> listSat;
  33. public X1D1PosParamEditor(PosRes info, MapControl mapControl)
  34. {
  35. InitializeComponent();
  36. this.info = info;
  37. this.listSat = new List<SatInfo>();
  38. this.mapControl1 = mapControl;
  39. //this.StartPosition = FormStartPosition.CenterParent;
  40. txtsatStation.EditValueChanged += TxtsatStation_EditValueChanged;
  41. txtcdbStation.EditValueChanged += TxtcdbStation_EditValueChanged;
  42. txtRefLocation.EditValueChanged += TxtRefLocation_EditValueChanged;
  43. }
  44. private void TxtRefLocation_EditValueChanged(object sender, EventArgs e)
  45. {
  46. txtRefLocation.CheckLonLat(dxErrorProvider, "参考站");
  47. }
  48. private void TxtcdbStation_EditValueChanged(object sender, EventArgs e)
  49. {
  50. txtcdbStation.CheckLonLat(dxErrorProvider, "超短波");
  51. }
  52. private void TxtsatStation_EditValueChanged(object sender, EventArgs e)
  53. {
  54. txtsatStation.CheckLonLat(dxErrorProvider, "接收站");
  55. }
  56. private async void X1D1DTOParamEditor_Load(object sender, EventArgs e)
  57. {
  58. StationRes station;
  59. using (RHDWContext db = new RHDWContext())
  60. {
  61. listSat = await db.SatInfos.ToListAsync();
  62. }
  63. using (RHDWPartContext db = RHDWPartContext.GetContext(info.SigTime))
  64. {
  65. cg = await db.CgRes.Where(m => m.ID == info.CgResID).FirstOrDefaultAsync();
  66. station = await db.StationRes.Where(m => m.ID == info.StationResID).FirstOrDefaultAsync();
  67. }
  68. if (cg != null)
  69. {
  70. this.txtDtoCdb.Text = $"{cg.DtoCdb.Value:f3}";
  71. this.txtYbMain.Text = $"{cg.YbMainDto.Value:f3}";
  72. this.sigTime.EditValue = info.SigTime;
  73. this.txtMainX.Text = $"{cg.MainX.Value:f3}";
  74. this.txtMainY.Text = $"{cg.MainY.Value:f3}";
  75. this.txtMainZ.Text = $"{cg.MainZ.Value:f3}";
  76. }
  77. if (station != null)
  78. {
  79. this.txtsatStation.Text = $"{station.SatTxLon:f3},{station.SatTxLat:f3}";
  80. this.txtcdbStation.Text = $"{station.CdbTxLon:f3},{station.CdbTxLat:f3}";
  81. this.txtRefLocation.Text = $"{station.RefLon:f3},{station.RefLat:f3}";
  82. }
  83. }
  84. public bool CheckParam()
  85. {
  86. if (!txtsatStation.CheckLonLat(dxErrorProvider, "接收站"))
  87. {
  88. return false;
  89. }
  90. if (!txtcdbStation.CheckLonLat(dxErrorProvider, "超短波"))
  91. {
  92. return false;
  93. }
  94. if (!txtRefLocation.CheckLonLat(dxErrorProvider, "参考站"))
  95. {
  96. return false;
  97. }
  98. return true;
  99. }
  100. private void btnOk_Click(object sender, EventArgs e)
  101. {
  102. if (!CheckParam()) { return; }
  103. try
  104. {
  105. var MsAnt = txtsatStation.GetLonLat();
  106. var CDBAnt = txtcdbStation.GetLonLat();
  107. var RefGeod = txtRefLocation.GetLonLat();
  108. var DtoCdb = Convert.ToDouble(this.txtDtoCdb.Text);
  109. var YbMainDto = Convert.ToDouble(this.txtYbMain.Text);
  110. var MainX = Convert.ToDouble(this.txtMainX.Text);
  111. var MainY = Convert.ToDouble(this.txtMainY.Text);
  112. var MainZ = Convert.ToDouble(this.txtMainZ.Text);
  113. double[] msEph = new double[] { MainX, MainY, MainZ, 0, 0, 0 };
  114. //DtoLineXdOption dtoLineXd = new DtoLineXdOption();
  115. //dtoLineXd.MsEph = msEph;
  116. //dtoLineXd.MsAnt = MsAnt;
  117. //dtoLineXd.CDBAnt = CDBAnt;
  118. //dtoLineXd.RefGeod = RefGeod;
  119. //dtoLineXd.xdDto = DtoCdb;
  120. //dtoLineXd.RefDto = YbMainDto;
  121. //dtoLineXd.PosLon = info.PosLon;
  122. //dtoLineXd.PosLat = info.PosLat;
  123. //var msat = listSat.FirstOrDefault(m => m.SatCode == cg.MainCode.Value)?.Sat;
  124. //if (string.IsNullOrWhiteSpace(msat)) msat = cg.MainCode.Value.ToString();
  125. //var xdDtoLine = PosApi.X1D1_Pos(dtoLineXd);
  126. //mapControl1.DrawDtoPonit($"[{msat},超短{CDBAnt[0]}°]带参时差线", xdDtoLine);
  127. }
  128. catch (Exception ex)
  129. {
  130. Serilog.Log.Error(ex, $"绘制{info.PosResType.GetEnumDisplayName()}时差线失败.PosID={info.ID},SigTime={info.SigTime}");
  131. DxHelper.MsgBoxHelper.ShowWarning($"绘制{info.PosResType.GetEnumDisplayName()}时差线失败");
  132. }
  133. }
  134. }
  135. }