UCEphXYZ.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. ephX.EditValue = eph.x.HasValue ? Math.Round(eph.x.Value, 4) : 0;
  27. layoutControlItemx.Text = $"{title}<size=12><color=0,103,192> [{satCode}]</color></size>星历X";
  28. ephY.EditValue = eph.y.HasValue ? Math.Round(eph.y.Value, 4) : 0;
  29. layoutControlItemy.Text = $"{title}星历Y";
  30. ephZ.EditValue = eph.z.HasValue ? Math.Round(eph.z.Value, 4) : 0;
  31. layoutControlItemz.Text = $"{title}星历Z";
  32. ephX.ForeColor = ephY.ForeColor = ephZ.ForeColor = color;
  33. }
  34. public (bool, string) ValidateParam()
  35. {
  36. if (!double.TryParse(ephX.Text, out double _))
  37. {
  38. return (false, $"{layoutControlItemx.Text}星历X格式错误!");
  39. }
  40. if (!double.TryParse(ephY.Text, out double _))
  41. {
  42. return (false, $"{layoutControlItemx.Text}星历Y格式错误!");
  43. }
  44. if (!double.TryParse(ephZ.Text, out double _))
  45. {
  46. return (false, $"{layoutControlItemx.Text}星历Z格式错误!");
  47. }
  48. return (true, string.Empty);
  49. }
  50. public double[] EphXYZ()
  51. {
  52. var x = Convert.ToDouble(ephX.EditValue);
  53. var y = Convert.ToDouble(ephY.EditValue);
  54. var z = Convert.ToDouble(ephZ.EditValue);
  55. return new double[6] { x, y, z, 0, 0, 0 };
  56. }
  57. public int GetSatCode()
  58. {
  59. return SatCode.HasValue ? SatCode.Value : 0;
  60. }
  61. }
  62. }