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; double.TryParse(ephX.EditValue?.ToString(), out double x); double.TryParse(ephY.EditValue?.ToString(), out double y); double.TryParse(ephZ.EditValue?.ToString(), out double z); if (ephX.EditValue!=null&&x != eph.x) { ephX.ForeColor = color; } if (ephY.EditValue != null && y != eph.y) { ephY.ForeColor = color; } if (ephZ.EditValue != null && z != eph.z) { ephZ.ForeColor = color; } ephX.EditValue = eph.x.HasValue ? eph.x.Value : 0; layoutControlItemx.Text = $"{title} [{satCode}]星历X"; ephY.EditValue = eph.y.HasValue ?eph.y.Value : 0; layoutControlItemy.Text = $"{title}星历Y"; ephZ.EditValue = eph.z.HasValue ? eph.z.Value : 0; layoutControlItemz.Text = $"{title}星历Z"; } public (bool, string) ValidateParam() { if (!double.TryParse(ephX.Text, out double _)) { return (false, $"{layoutControlItemx.Text}星历X格式错误!"); } if (!double.TryParse(ephY.Text, out double _)) { return (false, $"{layoutControlItemx.Text}星历Y格式错误!"); } if (!double.TryParse(ephZ.Text, out double _)) { return (false, $"{layoutControlItemx.Text}星历Z格式错误!"); } return (true, string.Empty); } public double[] EphXYZ() { 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 }; } public int GetSatCode() { return SatCode.HasValue ? SatCode.Value : 0; } } }