UCEphXYZ.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 UCEphXYZ : DevExpress.XtraEditors.XtraUserControl
  18. {
  19. private int? SatCode;
  20. private string _title;
  21. public UCEphXYZ()
  22. {
  23. InitializeComponent();
  24. }
  25. public void SetXYZ(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. double.TryParse(ephX.EditValue?.ToString(), out double x);
  31. double.TryParse(ephY.EditValue?.ToString(), out double y);
  32. double.TryParse(ephZ.EditValue?.ToString(), out double z);
  33. if (ephX.EditValue!=null&&x != eph.x)
  34. {
  35. ephX.ForeColor = color;
  36. }
  37. if (ephY.EditValue != null && y != eph.y)
  38. {
  39. ephY.ForeColor = color;
  40. }
  41. if (ephZ.EditValue != null && z != eph.z)
  42. {
  43. ephZ.ForeColor = color;
  44. }
  45. ephX.EditValue = eph.x.HasValue ? eph.x.Value : 0;
  46. layoutControlItemx.Text = $"{title}<size=12><color=0,103,192> [{satCode}]</color></size>星历X";
  47. ephY.EditValue = eph.y.HasValue ?eph.y.Value : 0;
  48. layoutControlItemy.Text = $"{title}星历Y";
  49. ephZ.EditValue = eph.z.HasValue ? eph.z.Value : 0;
  50. layoutControlItemz.Text = $"{title}星历Z";
  51. }
  52. public (bool, string) ValidateParam()
  53. {
  54. if (!double.TryParse(ephX.Text, out double _))
  55. {
  56. return (false, $"{_title}星历X格式错误!");
  57. }
  58. if (!double.TryParse(ephY.Text, out double _))
  59. {
  60. return (false, $"{_title}星历Y格式错误!");
  61. }
  62. if (!double.TryParse(ephZ.Text, out double _))
  63. {
  64. return (false, $"{_title}星历Z格式错误!");
  65. }
  66. return (true, string.Empty);
  67. }
  68. public bool CheckEphXYZ(DXErrorProvider dxErrorProvider)
  69. {
  70. if (!ephX.CheckDouble(dxErrorProvider, $"{_title}星历X"))
  71. {
  72. return false;
  73. }
  74. if (!ephY.CheckDouble(dxErrorProvider, $"{_title}星历Y"))
  75. {
  76. return false;
  77. }
  78. if (!ephZ.CheckDouble(dxErrorProvider, $"{_title}星历Z"))
  79. {
  80. return false;
  81. }
  82. return true;
  83. }
  84. public double[] EphXYZ()
  85. {
  86. var x = Convert.ToDouble(ephX.EditValue);
  87. var y = Convert.ToDouble(ephY.EditValue);
  88. var z = Convert.ToDouble(ephZ.EditValue);
  89. return new double[6] { x, y, z, 0, 0, 0 };
  90. }
  91. public int GetSatCode()
  92. {
  93. return SatCode.HasValue ? SatCode.Value : 0;
  94. }
  95. }
  96. }