UCEphXYZParam.cs 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using DevExpress.XtraEditors;
  2. using DevExpress.XtraLayout;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. using System.Xml.Serialization;
  13. namespace XdCxRhDW.App.UserControl
  14. {
  15. public partial class UCEphXYZParam : DevExpress.XtraEditors.XtraUserControl
  16. {
  17. private int? SatCode;
  18. public UCEphXYZParam()
  19. {
  20. InitializeComponent();
  21. }
  22. public void SetParam(string title, int? satCode, (double? x, double? y, double? z, double? vx, double? vy, double? vz) eph, Color color)
  23. {
  24. SatCode = satCode;
  25. layoutControlItemx.AllowHtmlStringInCaption = true;
  26. ephX.EditValue = eph.x.HasValue ? eph.x.Value : 0;
  27. layoutControlItemx.Text = $"{title}<size=12><color=0,103,192> [{satCode}]</color></size>星历X";
  28. ephY.EditValue = eph.y.HasValue ? eph.y.Value: 0;
  29. layoutControlItemy.Text = $"{title}星历Y";
  30. ephZ.EditValue = eph.z.HasValue ? eph.z.Value : 0;
  31. layoutControlItemz.Text = $"{title}星历Z";
  32. ephVX.EditValue = eph.vx.HasValue ? eph.vx.Value : 0;
  33. layoutControlItemvx.Text = $"{title}星历VX";
  34. ephVY.EditValue = eph.vy.HasValue ? eph.vy.Value : 0;
  35. layoutControlItemvy.Text = $"{title}星历VY";
  36. ephVZ.EditValue = eph.vz.HasValue ? eph.vz.Value : 0;
  37. layoutControlItemvz.Text = $"{title}星历VZ";
  38. ephX.ForeColor = ephY.ForeColor = ephZ.ForeColor = ephVX.ForeColor = ephVY.ForeColor = ephVZ.ForeColor = color;
  39. }
  40. public (bool, string) ValidateParam()
  41. {
  42. if (!double.TryParse(ephX.Text, out double _))
  43. {
  44. return (false, $"{layoutControlItemx.Text}星历X格式错误!");
  45. }
  46. if (!double.TryParse(ephY.Text, out double _))
  47. {
  48. return (false, $"{layoutControlItemx.Text}星历Y格式错误!");
  49. }
  50. if (!double.TryParse(ephZ.Text, out double _))
  51. {
  52. return (false, $"{layoutControlItemx.Text}星历Z格式错误!");
  53. }
  54. if (!double.TryParse(ephVX.Text, out double _))
  55. {
  56. return (false, $"{layoutControlItemx.Text}星历VX格式错误!");
  57. }
  58. if (!double.TryParse(ephVY.Text, out double _))
  59. {
  60. return (false, $"{layoutControlItemx.Text}星历VY格式错误!");
  61. }
  62. if (!double.TryParse(ephVZ.Text, out double _))
  63. {
  64. return (false, $"{layoutControlItemx.Text}星历VZ格式错误!");
  65. }
  66. return (true, string.Empty);
  67. }
  68. public double[] EphParam()
  69. {
  70. var x = Convert.ToDouble(ephX.EditValue);
  71. var y = Convert.ToDouble(ephY.EditValue);
  72. var z = Convert.ToDouble(ephZ.EditValue);
  73. var vx = Convert.ToDouble(ephVX.EditValue);
  74. var vy = Convert.ToDouble(ephVY.EditValue);
  75. var vz = Convert.ToDouble(ephVZ.EditValue);
  76. return new double[6] { x, y, z, vx, vy, vz };
  77. }
  78. public int GetSatCode()
  79. {
  80. return SatCode.HasValue ? SatCode.Value : 0;
  81. }
  82. }
  83. }