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 UCEphXYZParam : DevExpress.XtraEditors.XtraUserControl { private int? SatCode; public UCEphXYZParam() { InitializeComponent(); } public void SetParam(string title, int? satCode, (double? x, double? y, double? z, double? vx, double? vy, double? vz) 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"; ephVX.EditValue = eph.vx.HasValue ? Math.Round(eph.vx.Value, 3) : 0; layoutControlItemvx.Text = $"{title}星历VX"; ephVY.EditValue = eph.vy.HasValue ? Math.Round(eph.vy.Value, 3) : 0; layoutControlItemvy.Text = $"{title}星历VY"; ephVZ.EditValue = eph.vz.HasValue ? Math.Round(eph.vz.Value, 3) : 0; layoutControlItemvz.Text = $"{title}星历VZ"; ephX.ForeColor = ephY.ForeColor = ephZ.ForeColor = ephVX.ForeColor = ephVY.ForeColor = ephVZ.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不能为空!"); } if (string.IsNullOrWhiteSpace(ephVX.Text)) { return (false, $"{layoutControlItemvx.Text}星历VX不能为空!"); } if (string.IsNullOrWhiteSpace(ephVY.Text)) { return (false, $"{layoutControlItemvy.Text}星历VY不能为空!"); } if (string.IsNullOrWhiteSpace(ephVZ.Text)) { return (false, $"{layoutControlItemvz.Text}星历VZ不能为空!"); } return (true, string.Empty); } public double[] EphParam() { try { var x = Convert.ToDouble(ephX.EditValue); var y = Convert.ToDouble(ephY.EditValue); var z = Convert.ToDouble(ephZ.EditValue); var vx = Convert.ToDouble(ephVX.EditValue); var vy = Convert.ToDouble(ephVY.EditValue); var vz = Convert.ToDouble(ephVZ.EditValue); return new double[6] { x, y, z, vx, vy, vz }; } catch (Exception ex) { throw new Exception(ex.Message); } } public int GetSatCode() { return SatCode.HasValue ? SatCode.Value : 0; } } }