UCEphXYZParam.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. using DevExpress.XtraEditors;
  2. using DevExpress.XtraEditors.DXErrorProvider;
  3. using DevExpress.XtraLayout;
  4. using ExtensionsDev;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.ComponentModel;
  8. using System.Data;
  9. using System.Drawing;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows.Forms;
  14. using System.Xml.Serialization;
  15. namespace DW5S.App.UserControl
  16. {
  17. public partial class UCEphXYZParam : DevExpress.XtraEditors.XtraUserControl
  18. {
  19. private int? SatCode;
  20. private string _title;
  21. public UCEphXYZParam()
  22. {
  23. InitializeComponent();
  24. }
  25. public void SetParam(string title, int? satCode, (double? x, double? y, double? z, double? vx, double? vy, double? vz) eph, Color color)
  26. {
  27. SatCode = satCode;
  28. _title = $"{title}[{SatCode}]";
  29. layoutControlItemx.AllowHtmlStringInCaption = true;
  30. ephX.EditValue = eph.x.HasValue ? eph.x.Value : 0;
  31. layoutControlItemx.Text = $"{title}<size=12><color=0,103,192> [{satCode}]</color></size>星历X";
  32. ephY.EditValue = eph.y.HasValue ? eph.y.Value: 0;
  33. layoutControlItemy.Text = $"{title}星历Y";
  34. ephZ.EditValue = eph.z.HasValue ? eph.z.Value : 0;
  35. layoutControlItemz.Text = $"{title}星历Z";
  36. ephVX.EditValue = eph.vx.HasValue ? eph.vx.Value : 0;
  37. layoutControlItemvx.Text = $"{title}星历VX";
  38. ephVY.EditValue = eph.vy.HasValue ? eph.vy.Value : 0;
  39. layoutControlItemvy.Text = $"{title}星历VY";
  40. ephVZ.EditValue = eph.vz.HasValue ? eph.vz.Value : 0;
  41. layoutControlItemvz.Text = $"{title}星历VZ";
  42. ephX.ForeColor = ephY.ForeColor = ephZ.ForeColor = ephVX.ForeColor = ephVY.ForeColor = ephVZ.ForeColor = color;
  43. }
  44. public (bool, string) ValidateParam()
  45. {
  46. if (!double.TryParse(ephX.Text, out double _))
  47. {
  48. return (false, $"{_title}星历X格式错误!");
  49. }
  50. if (!double.TryParse(ephY.Text, out double _))
  51. {
  52. return (false, $"{_title}星历Y格式错误!");
  53. }
  54. if (!double.TryParse(ephZ.Text, out double _))
  55. {
  56. return (false, $"{_title}星历Z格式错误!");
  57. }
  58. if (!double.TryParse(ephVX.Text, out double _))
  59. {
  60. return (false, $"{_title}星历VX格式错误!");
  61. }
  62. if (!double.TryParse(ephVY.Text, out double _))
  63. {
  64. return (false, $"{_title}星历VY格式错误!");
  65. }
  66. if (!double.TryParse(ephVZ.Text, out double _))
  67. {
  68. return (false, $"{_title}星历VZ格式错误!");
  69. }
  70. return (true, string.Empty);
  71. }
  72. public bool CheckEphXYZ(DXErrorProvider dxErrorProvider)
  73. {
  74. if (!ephX.CheckDouble(dxErrorProvider, $"{_title}星历X"))
  75. {
  76. return false;
  77. }
  78. if (!ephY.CheckDouble(dxErrorProvider, $"{_title}星历Y"))
  79. {
  80. return false;
  81. }
  82. if (!ephZ.CheckDouble(dxErrorProvider, $"{_title}星历Z"))
  83. {
  84. return false;
  85. }
  86. return true;
  87. }
  88. public bool CheckEph(DXErrorProvider dxErrorProvider)
  89. {
  90. if (!ephX.CheckDouble(dxErrorProvider, $"{_title}星历X"))
  91. {
  92. return false;
  93. }
  94. if (!ephY.CheckDouble(dxErrorProvider, $"{_title}星历Y"))
  95. {
  96. return false;
  97. }
  98. if (!ephZ.CheckDouble(dxErrorProvider, $"{_title}星历Z"))
  99. {
  100. return false;
  101. }
  102. if (!ephVX.CheckDouble(dxErrorProvider, $"{_title}星历VX"))
  103. {
  104. return false;
  105. }
  106. if (!ephVY.CheckDouble(dxErrorProvider, $"{_title}星历VY"))
  107. {
  108. return false;
  109. }
  110. if (!ephVZ.CheckDouble(dxErrorProvider, $"{_title}星历VZ"))
  111. {
  112. return false;
  113. }
  114. return true;
  115. }
  116. public double[] EphParam()
  117. {
  118. var x = Convert.ToDouble(ephX.EditValue);
  119. var y = Convert.ToDouble(ephY.EditValue);
  120. var z = Convert.ToDouble(ephZ.EditValue);
  121. var vx = Convert.ToDouble(ephVX.EditValue);
  122. var vy = Convert.ToDouble(ephVY.EditValue);
  123. var vz = Convert.ToDouble(ephVZ.EditValue);
  124. return new double[6] { x, y, z, vx, vy, vz };
  125. }
  126. public double[] EphXYZ()
  127. {
  128. var x = Convert.ToDouble(ephX.EditValue);
  129. var y = Convert.ToDouble(ephY.EditValue);
  130. var z = Convert.ToDouble(ephZ.EditValue);
  131. return new double[3] { x, y, z };
  132. }
  133. public int GetSatCode()
  134. {
  135. return SatCode.HasValue ? SatCode.Value : 0;
  136. }
  137. }
  138. }