UCEphXYZParam.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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) 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. ephX.ForeColor = ephY.ForeColor = ephZ.ForeColor = ephVX.ForeColor = ephVY.ForeColor = ephVZ.ForeColor = color;
  37. }
  38. public (bool, string) ValidateParam()
  39. {
  40. if (!double.TryParse(ephX.Text, out double _))
  41. {
  42. return (false, $"{_title}星历X格式错误!");
  43. }
  44. if (!double.TryParse(ephY.Text, out double _))
  45. {
  46. return (false, $"{_title}星历Y格式错误!");
  47. }
  48. if (!double.TryParse(ephZ.Text, out double _))
  49. {
  50. return (false, $"{_title}星历Z格式错误!");
  51. }
  52. if (!double.TryParse(ephVX.Text, out double _))
  53. {
  54. return (false, $"{_title}星历VX格式错误!");
  55. }
  56. if (!double.TryParse(ephVY.Text, out double _))
  57. {
  58. return (false, $"{_title}星历VY格式错误!");
  59. }
  60. if (!double.TryParse(ephVZ.Text, out double _))
  61. {
  62. return (false, $"{_title}星历VZ格式错误!");
  63. }
  64. return (true, string.Empty);
  65. }
  66. public bool CheckEphXYZ(DXErrorProvider dxErrorProvider)
  67. {
  68. if (!ephX.CheckDouble(dxErrorProvider, $"{_title}星历X"))
  69. {
  70. return false;
  71. }
  72. if (!ephY.CheckDouble(dxErrorProvider, $"{_title}星历Y"))
  73. {
  74. return false;
  75. }
  76. if (!ephZ.CheckDouble(dxErrorProvider, $"{_title}星历Z"))
  77. {
  78. return false;
  79. }
  80. return true;
  81. }
  82. public bool CheckEph(DXErrorProvider dxErrorProvider)
  83. {
  84. if (!ephX.CheckDouble(dxErrorProvider, $"{_title}星历X"))
  85. {
  86. return false;
  87. }
  88. if (!ephY.CheckDouble(dxErrorProvider, $"{_title}星历Y"))
  89. {
  90. return false;
  91. }
  92. if (!ephZ.CheckDouble(dxErrorProvider, $"{_title}星历Z"))
  93. {
  94. return false;
  95. }
  96. if (!ephVX.CheckDouble(dxErrorProvider, $"{_title}星历VX"))
  97. {
  98. return false;
  99. }
  100. if (!ephVY.CheckDouble(dxErrorProvider, $"{_title}星历VY"))
  101. {
  102. return false;
  103. }
  104. if (!ephVZ.CheckDouble(dxErrorProvider, $"{_title}星历VZ"))
  105. {
  106. return false;
  107. }
  108. return true;
  109. }
  110. public double[] EphParam()
  111. {
  112. var x = Convert.ToDouble(ephX.EditValue);
  113. var y = Convert.ToDouble(ephY.EditValue);
  114. var z = Convert.ToDouble(ephZ.EditValue);
  115. var vx = Convert.ToDouble(ephVX.EditValue);
  116. var vy = Convert.ToDouble(ephVY.EditValue);
  117. var vz = Convert.ToDouble(ephVZ.EditValue);
  118. return new double[6] { x, y, z, vx, vy, vz };
  119. }
  120. public double[] EphXYZ()
  121. {
  122. var x = Convert.ToDouble(ephX.EditValue);
  123. var y = Convert.ToDouble(ephY.EditValue);
  124. var z = Convert.ToDouble(ephZ.EditValue);
  125. return new double[3] { x, y, z };
  126. }
  127. public int GetSatCode()
  128. {
  129. return SatCode.HasValue ? SatCode.Value : 0;
  130. }
  131. }
  132. }