UCEphXYZ.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 UCEphXYZ : DevExpress.XtraEditors.XtraUserControl
  16. {
  17. private int? SatCode;
  18. public UCEphXYZ()
  19. {
  20. InitializeComponent();
  21. }
  22. public void SetXYZ(string title, int? satCode, (double? x, double? y, double? z) eph, Color color)
  23. {
  24. SatCode = satCode;
  25. layoutControlItemx.AllowHtmlStringInCaption = true;
  26. double.TryParse(ephX.EditValue?.ToString(), out double x);
  27. double.TryParse(ephY.EditValue?.ToString(), out double y);
  28. double.TryParse(ephZ.EditValue?.ToString(), out double z);
  29. if (ephX.EditValue!=null&&x != eph.x)
  30. {
  31. ephX.ForeColor = color;
  32. }
  33. if (ephY.EditValue != null && y != eph.y)
  34. {
  35. ephY.ForeColor = color;
  36. }
  37. if (ephZ.EditValue != null && z != eph.z)
  38. {
  39. ephZ.ForeColor = color;
  40. }
  41. ephX.EditValue = eph.x.HasValue ? eph.x.Value : 0;
  42. layoutControlItemx.Text = $"{title}<size=12><color=0,103,192> [{satCode}]</color></size>星历X";
  43. ephY.EditValue = eph.y.HasValue ?eph.y.Value : 0;
  44. layoutControlItemy.Text = $"{title}星历Y";
  45. ephZ.EditValue = eph.z.HasValue ? eph.z.Value : 0;
  46. layoutControlItemz.Text = $"{title}星历Z";
  47. }
  48. public (bool, string) ValidateParam()
  49. {
  50. if (!double.TryParse(ephX.Text, out double _))
  51. {
  52. return (false, $"{layoutControlItemx.Text}星历X格式错误!");
  53. }
  54. if (!double.TryParse(ephY.Text, out double _))
  55. {
  56. return (false, $"{layoutControlItemx.Text}星历Y格式错误!");
  57. }
  58. if (!double.TryParse(ephZ.Text, out double _))
  59. {
  60. return (false, $"{layoutControlItemx.Text}星历Z格式错误!");
  61. }
  62. return (true, string.Empty);
  63. }
  64. public double[] EphXYZ()
  65. {
  66. var x = Convert.ToDouble(ephX.EditValue);
  67. var y = Convert.ToDouble(ephY.EditValue);
  68. var z = Convert.ToDouble(ephZ.EditValue);
  69. return new double[6] { x, y, z, 0, 0, 0 };
  70. }
  71. public int GetSatCode()
  72. {
  73. return SatCode.HasValue ? SatCode.Value : 0;
  74. }
  75. }
  76. }