X2DTOParamEditor.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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 X2DTOParamEditor : DevExpress.XtraEditors.XtraForm
  28. {
  29. private MapControl mapControl1;
  30. private PosRes info;
  31. private CgRes cg;
  32. private List<SatInfo> listSat;
  33. public X2DTOParamEditor(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. txtRefLocation.EditValueChanged += TxtRefLocation_EditValueChanged;
  43. }
  44. private void TxtRefLocation_EditValueChanged(object sender, EventArgs e)
  45. {
  46. txtRefLocation.CheckLonLat(dxErrorProvider, "参考站");
  47. }
  48. private void TxtsatStation_EditValueChanged(object sender, EventArgs e)
  49. {
  50. txtsatStation.CheckLonLat(dxErrorProvider, "接收站");
  51. }
  52. private async void X2DTOParamEditor_Load(object sender, EventArgs e)
  53. {
  54. StationRes station;
  55. using (RHDWContext db = new RHDWContext())
  56. {
  57. listSat = db.SatInfos.ToList();
  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.txtDtoSx.Text = $"{cg.Dto1.Value}";
  64. this.txtYbMain.Text = $"{cg.YbMainDto.Value}";
  65. this.txtYbAdja.Text = $"{cg.YbAdja1Dto.Value}";
  66. this.sigTime.EditValue = info.SigTime;
  67. this.txtMainX.Text = $"{cg.MainX.Value}";
  68. this.txtMainY.Text = $"{cg.MainY.Value}";
  69. this.txtMainZ.Text = $"{cg.MainZ.Value}";
  70. this.txtAdjaX.Text = $"{cg.Adja1X.Value}";
  71. this.txtAdjaY.Text = $"{cg.Adja1Y.Value}";
  72. this.txtAdjaZ.Text = $"{cg.Adja1Z.Value}";
  73. }
  74. if (station != null)
  75. {
  76. this.txtsatStation.Text = $"{station.SatTxLon},{station.SatTxLat}";
  77. this.txtRefLocation.Text = $"{station.RefLon},{station.RefLat}";
  78. }
  79. }
  80. public bool CheckParam()
  81. {
  82. if (!txtsatStation.CheckLonLat(dxErrorProvider, "接收站"))
  83. {
  84. return false;
  85. }
  86. if (!txtRefLocation.CheckLonLat(dxErrorProvider, "参考站"))
  87. {
  88. return false;
  89. }
  90. return true;
  91. }
  92. private void btnOk_Click(object sender, EventArgs e)
  93. {
  94. if (!CheckParam()) { return; }
  95. try
  96. {
  97. var MsAnt = txtsatStation.GetLonLat();
  98. var RefGeod = txtRefLocation.GetLonLat();
  99. var DtoSx = Convert.ToDouble(this.txtDtoSx.Text);
  100. var YbMainDto = Convert.ToDouble(this.txtYbMain.Text);
  101. var YbAdja1Dto = Convert.ToDouble(this.txtYbAdja.Text);
  102. var MainX = Convert.ToDouble(this.txtMainX.Text);
  103. var MainY = Convert.ToDouble(this.txtMainY.Text);
  104. var MainZ = Convert.ToDouble(this.txtMainZ.Text);
  105. var AdjaX = Convert.ToDouble(this.txtAdjaX.Text);
  106. var AdjaY = Convert.ToDouble(this.txtAdjaY.Text);
  107. var AdjaZ = Convert.ToDouble(this.txtAdjaZ.Text);
  108. double[] msEph = new double[] { MainX, MainY, MainZ, 0, 0, 0 };
  109. double[] Ns1Eph = new double[] { AdjaX, AdjaY, AdjaZ, 0, 0, 0 };
  110. DtoLineTwoStartOption twoStartOption = new DtoLineTwoStartOption();
  111. twoStartOption.MsEph = msEph;
  112. twoStartOption.NsEph = Ns1Eph;
  113. twoStartOption.MsAnt = MsAnt;
  114. twoStartOption.NsAnt = MsAnt;
  115. twoStartOption.RefGeod = RefGeod;
  116. twoStartOption.TargetDto = DtoSx;
  117. twoStartOption.RefDto = YbMainDto - YbAdja1Dto;
  118. twoStartOption.PosLon = info.PosLon;
  119. twoStartOption.PosLat = info.PosLat;
  120. string msat = string.Empty;
  121. if (cg.MainCode.HasValue)
  122. {
  123. msat = listSat.FirstOrDefault(m => m.SatCode == cg.MainCode.Value)?.Sat;
  124. }
  125. string nsat = string.Empty;
  126. if (cg.Adja1Code.HasValue)
  127. {
  128. nsat = listSat.FirstOrDefault(m => m.SatCode == cg.Adja1Code.Value)?.Sat;
  129. }
  130. var tsDtoLine = DrawDtoLineHelper.DtoLine2XStart(twoStartOption);
  131. mapControl1.DrawDtoPonit($"双星[{msat},[{nsat}]]时差线", tsDtoLine);
  132. }
  133. catch (Exception ex)
  134. {
  135. Serilog.Log.Error(ex,$"绘制{info.PosResType.GetEnumDisplayName()}时差线失败");
  136. DxHelper.MsgBoxHelper.ShowWarning($"绘制{info.PosResType.GetEnumDisplayName()}时差线失败,失败信息:{ex.Message}");
  137. }
  138. }
  139. }
  140. }