using DevExpress.XtraEditors; using DevExpress.XtraLayout; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Xml.Serialization; namespace XdCxRhDW.App.UserControl { public partial class UCEphXYZ : DevExpress.XtraEditors.XtraUserControl { private int? SatCode; public UCEphXYZ() { InitializeComponent(); } public void SetXYZ(string title, int? satCode, (double? x, double? y, double? z) eph, Color color) { SatCode = satCode; layoutControlItemx.AllowHtmlStringInCaption = true; ephX.EditValue = eph.x.HasValue ? Math.Round(eph.x.Value, 3) : 0; layoutControlItemx.Text = $"{title} [{satCode}]星历X"; ephY.EditValue = eph.y.HasValue ? Math.Round(eph.y.Value, 3) : 0; layoutControlItemy.Text = $"{title}星历Y"; ephZ.EditValue = eph.z.HasValue ? Math.Round(eph.z.Value, 3) : 0; layoutControlItemz.Text = $"{title}星历Z"; ephX.ForeColor = ephY.ForeColor = ephZ.ForeColor = color; } public (bool, string) ValidateParam() { if (string.IsNullOrWhiteSpace(ephX.Text)) { return (false, $"{layoutControlItemx.Text}星历X不能为空!"); } if (string.IsNullOrWhiteSpace(ephY.Text)) { return (false, $"{layoutControlItemy.Text}星历Y不能为空!"); } if (string.IsNullOrWhiteSpace(ephZ.Text)) { return (false, $"{layoutControlItemz.Text}星历Z不能为空!"); } return (true, string.Empty); } public double[] EphXYZ() { try { var x = Convert.ToDouble(ephX.EditValue); var y = Convert.ToDouble(ephY.EditValue); var z = Convert.ToDouble(ephZ.EditValue); return new double[6] { x, y, z, 0, 0, 0 }; } catch (Exception ex) { throw new Exception(ex.Message); } } public int GetSatCode() { return SatCode.HasValue ? SatCode.Value : 0; } } }