UCEphXYZParam.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 XdCxRhDW.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. if (!ephVX.CheckDouble(dxErrorProvider, $"{_title}星历VX"))
  87. {
  88. return false;
  89. }
  90. if (!ephVY.CheckDouble(dxErrorProvider, $"{_title}星历VY"))
  91. {
  92. return false;
  93. }
  94. if (!ephVZ.CheckDouble(dxErrorProvider, $"{_title}星历VZ"))
  95. {
  96. return false;
  97. }
  98. return true;
  99. }
  100. public double[] EphParam()
  101. {
  102. var x = Convert.ToDouble(ephX.EditValue);
  103. var y = Convert.ToDouble(ephY.EditValue);
  104. var z = Convert.ToDouble(ephZ.EditValue);
  105. var vx = Convert.ToDouble(ephVX.EditValue);
  106. var vy = Convert.ToDouble(ephVY.EditValue);
  107. var vz = Convert.ToDouble(ephVZ.EditValue);
  108. return new double[6] { x, y, z, vx, vy, vz };
  109. }
  110. public int GetSatCode()
  111. {
  112. return SatCode.HasValue ? SatCode.Value : 0;
  113. }
  114. }
  115. }