using DevExpress.XtraMap; using DxHelper; using ExtensionsDev; using System; using System.CodeDom; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.Entity; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using XdCxRhDW.Api; using XdCxRhDW.Entity; using XdCxRhDW.Repostory; namespace XdCxRhDW.App.EditForms { public partial class X1D1DTOParamEditor : DevExpress.XtraEditors.XtraUserControl { private MapControl mapControl1; private PosRes info; private CgRes cg; private List listSat; public X1D1DTOParamEditor(PosRes info, MapControl mapControl) { InitializeComponent(); this.Text = $"{info.PosResType.GetEnumDisplayName()}时差参数"; this.info = info; this.listSat = new List(); this.mapControl1 = mapControl; //this.StartPosition = FormStartPosition.CenterParent; txtsatStation.EditValueChanged += TxtsatStation_EditValueChanged; txtcdbStation.EditValueChanged += TxtcdbStation_EditValueChanged; txtRefLocation.EditValueChanged += TxtRefLocation_EditValueChanged; } private void TxtRefLocation_EditValueChanged(object sender, EventArgs e) { txtRefLocation.CheckLonLat(dxErrorProvider, "参考站"); } private void TxtcdbStation_EditValueChanged(object sender, EventArgs e) { txtcdbStation.CheckLonLat(dxErrorProvider, "超短波"); } private void TxtsatStation_EditValueChanged(object sender, EventArgs e) { txtsatStation.CheckLonLat(dxErrorProvider, "接收站"); } private async void X1D1DTOParamEditor_Load(object sender, EventArgs e) { StationRes station; using (RHDWContext db = new RHDWContext()) { listSat = await db.SatInfos.ToListAsync(); } using (RHDWPartContext db = RHDWPartContext.GetContext(info.SigTime)) { cg = await db.CgRes.Where(m => m.ID == info.CgResID).FirstOrDefaultAsync(); station = await db.StationRes.Where(m => m.ID == info.StationResID).FirstOrDefaultAsync(); } if (cg != null) { this.txtDtoCdb.Text = $"{cg.DtoCdb.Value:f3}"; this.txtYbMain.Text = $"{cg.YbMainDto.Value:f3}"; this.sigTime.EditValue = info.SigTime; this.txtMainX.Text = $"{cg.MainX.Value:f3}"; this.txtMainY.Text = $"{cg.MainY.Value:f3}"; this.txtMainZ.Text = $"{cg.MainZ.Value:f3}"; } if (station != null) { this.txtsatStation.Text = $"{station.SatTxLon:f3},{station.SatTxLat:f3}"; this.txtcdbStation.Text = $"{station.CdbTxLon:f3},{station.CdbTxLat:f3}"; this.txtRefLocation.Text = $"{station.RefLon:f3},{station.RefLat:f3}"; } } public bool CheckParam() { if (!txtsatStation.CheckLonLat(dxErrorProvider, "接收站")) { return false; } if (!txtcdbStation.CheckLonLat(dxErrorProvider, "超短波")) { return false; } if (!txtRefLocation.CheckLonLat(dxErrorProvider, "参考站")) { return false; } return true; } private void btnOk_Click(object sender, EventArgs e) { if (!CheckParam()) { return; } try { var MsAnt = txtsatStation.GetLonLat(); var CDBAnt = txtcdbStation.GetLonLat(); var RefGeod = txtRefLocation.GetLonLat(); var DtoCdb = Convert.ToDouble(this.txtDtoCdb.Text); var YbMainDto = Convert.ToDouble(this.txtYbMain.Text); var MainX = Convert.ToDouble(this.txtMainX.Text); var MainY = Convert.ToDouble(this.txtMainY.Text); var MainZ = Convert.ToDouble(this.txtMainZ.Text); double[] msEph = new double[] { MainX, MainY, MainZ, 0, 0, 0 }; DtoLineXdOption dtoLineXd = new DtoLineXdOption(); dtoLineXd.MsEph = msEph; dtoLineXd.MsAnt = MsAnt; dtoLineXd.CDBAnt = CDBAnt; dtoLineXd.RefGeod = RefGeod; dtoLineXd.xdDto = DtoCdb; dtoLineXd.RefDto = YbMainDto; dtoLineXd.PosLon = info.PosLon; dtoLineXd.PosLat = info.PosLat; var msat = listSat.FirstOrDefault(m => m.SatCode == cg.MainCode.Value)?.Sat; if (string.IsNullOrWhiteSpace(msat)) msat = cg.MainCode.Value.ToString(); var xdDtoLine = DrawDtoLineHelper.DtoLineXd(dtoLineXd); mapControl1.DrawDtoLine($"[{msat},超短{CDBAnt[0]}°]带参时差线", xdDtoLine); } catch (Exception ex) { Serilog.Log.Error(ex, $"绘制{info.PosResType.GetEnumDisplayName()}时差线失败.PosID={info.ID},SigTime={info.SigTime}"); DxHelper.MsgBoxHelper.ShowWarning($"绘制{info.PosResType.GetEnumDisplayName()}时差线失败"); } } } }