UCEphXYZ.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 DW5S.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 CheckEphXYZ(DXErrorProvider dxErrorProvider)
  53. {
  54. if (!ephX.CheckDouble(dxErrorProvider, $"{_title}星历X"))
  55. {
  56. return false;
  57. }
  58. if (!ephY.CheckDouble(dxErrorProvider, $"{_title}星历Y"))
  59. {
  60. return false;
  61. }
  62. if (!ephZ.CheckDouble(dxErrorProvider, $"{_title}星历Z"))
  63. {
  64. return false;
  65. }
  66. return true;
  67. }
  68. public double[] EphXYZ()
  69. {
  70. var x = Convert.ToDouble(ephX.EditValue);
  71. var y = Convert.ToDouble(ephY.EditValue);
  72. var z = Convert.ToDouble(ephZ.EditValue);
  73. return new double[6] { x, y, z, 0, 0, 0 };
  74. }
  75. public int GetSatCode()
  76. {
  77. return SatCode.HasValue ? SatCode.Value : 0;
  78. }
  79. }
  80. }