UCEphXYZ.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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, 3) : 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, 3) : 0;
  29. layoutControlItemy.Text = $"{title}星历Y";
  30. ephZ.EditValue = eph.z.HasValue ? Math.Round(eph.z.Value, 3) : 0;
  31. layoutControlItemz.Text = $"{title}星历Z";
  32. ephX.ForeColor = ephY.ForeColor = ephZ.ForeColor = color;
  33. }
  34. public (bool, string) ValidateParam()
  35. {
  36. if (string.IsNullOrWhiteSpace(ephX.Text))
  37. {
  38. return (false, $"{layoutControlItemx.Text}星历X不能为空!");
  39. }
  40. if (string.IsNullOrWhiteSpace(ephY.Text))
  41. {
  42. return (false, $"{layoutControlItemy.Text}星历Y不能为空!");
  43. }
  44. if (string.IsNullOrWhiteSpace(ephZ.Text))
  45. {
  46. return (false, $"{layoutControlItemz.Text}星历Z不能为空!");
  47. }
  48. return (true, string.Empty);
  49. }
  50. public double[] EphXYZ()
  51. {
  52. try
  53. {
  54. var x = Convert.ToDouble(ephX.EditValue);
  55. var y = Convert.ToDouble(ephY.EditValue);
  56. var z = Convert.ToDouble(ephZ.EditValue);
  57. return new double[6] { x, y, z, 0, 0, 0 };
  58. }
  59. catch (Exception ex)
  60. {
  61. throw new Exception(ex.Message);
  62. }
  63. }
  64. public int GetSatCode()
  65. {
  66. return SatCode.HasValue ? SatCode.Value : 0;
  67. }
  68. }
  69. }