using DevExpress.Mvvm.ModuleInjection.Native; using DevExpress.XtraEditors; using DevExpress.XtraEditors.DXErrorProvider; using DevExpress.XtraLayout; using DevExpress.XtraMap; using DevExpress.XtraTreeList.Data; 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.Data.Entity.Migrations; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Documents; using System.Windows.Forms; using XdCxRhDW.Core.Api; using XdCxRhDW.Repostory; using XdCxRhDW.Repostory.EFContext; using XdCxRhDW.Repostory.Model; using static System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox; namespace XdCxRhDW.App.EditForms { public partial class X3PosParamEditor : DevExpress.XtraEditors.XtraUserControl { private MapControl mapControl1; private PosRes info; private CgRes cg; private List listSat; public X3PosParamEditor(PosRes info, MapControl mapControl) { InitializeComponent(); this.info = info; this.labelControl1.Text = $""; this.mapControl1 = mapControl; txtsatStation.EditValueChanged += TxtsatStation_EditValueChanged; txtRefLocation.EditValueChanged += TxtRefLocation_EditValueChanged; } private void TxtRefLocation_EditValueChanged(object sender, EventArgs e) { txtRefLocation.CheckLonLat(dxErrorProvider, "参考站"); } private void TxtsatStation_EditValueChanged(object sender, EventArgs e) { txtsatStation.CheckLonLat(dxErrorProvider, "接收站"); } private async void X3DTOParamEditor_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.txtDtoSx.Text = $"{cg.Dto1.Value:f3}"; this.txtDtoSx1.Text = $"{cg.Dto2.Value:f3}"; if (info.PosResType == EnumPosResType.X3) { this.txtYbMain.Text = $"{cg.YbMainDto.Value:f3}"; this.txtYbAdja.Text = $"{cg.YbAdja1Dto.Value:f3}"; this.txtYbAdja1.Text = $"{cg.YbAdja2Dto.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}"; this.txtAdjaX.Text = $"{cg.Adja1X.Value:f3}"; this.txtAdjaY.Text = $"{cg.Adja1Y.Value:f3}"; this.txtAdjaZ.Text = $"{cg.Adja1Z.Value:f3}"; this.txtAdjaX1.Text = $"{cg.Adja2X.Value:f3}"; this.txtAdjaY1.Text = $"{cg.Adja2Y.Value:f3}"; this.txtAdjaZ1.Text = $"{cg.Adja2Z.Value:f3}"; } if (station != null) { this.txtsatStation.Text = $"{station.SatTxLon:f3},{station.SatTxLat:f3}"; this.txtRefLocation.Text = $"{station.RefLon:f3},{station.RefLat:f3}"; } if (info.PosResType == EnumPosResType.X3NoRef) { txtYbMain.Properties.ReadOnly = true; txtYbAdja.Properties.ReadOnly = true; txtYbAdja1.Properties.ReadOnly = true; txtRefLocation.Properties.ReadOnly = true; this.txtRefLocation.Text = $"{0},{0}"; } } public bool CheckParam() { if (!txtsatStation.CheckLonLat(dxErrorProvider, "接收站")) { return false; } if (info.PosResType == EnumPosResType.X3 && !txtRefLocation.CheckLonLat(dxErrorProvider, "参考站")) { return false; } return true; } private void btnOk_Click(object sender, EventArgs e) { if (!CheckParam()) { return; } try { var MsAnt = txtsatStation.GetLonLat(); var RefGeod = info.PosResType == EnumPosResType.X3 ? txtRefLocation.GetLonLat() : new double[3] { 0, 0, 0 }; var sigTime = this.sigTime.DateTime; var DtoSx = Convert.ToDouble(this.txtDtoSx.Text); var DtoSx1 = Convert.ToDouble(this.txtDtoSx1.Text); var YbMainDto = info.PosResType == EnumPosResType.X3 ? Convert.ToDouble(this.txtYbMain.Text) : 0; var YbAdja1Dto = info.PosResType == EnumPosResType.X3 ? Convert.ToDouble(this.txtYbAdja.Text) : 0; var YbAdja2Dto = info.PosResType == EnumPosResType.X3 ? Convert.ToDouble(this.txtYbAdja1.Text) : 0; var MainX = Convert.ToDouble(this.txtMainX.Text); var MainY = Convert.ToDouble(this.txtMainY.Text); var MainZ = Convert.ToDouble(this.txtMainZ.Text); var AdjaX = Convert.ToDouble(this.txtAdjaX.Text); var AdjaY = Convert.ToDouble(this.txtAdjaY.Text); var AdjaZ = Convert.ToDouble(this.txtAdjaZ.Text); var AdjaX2 = Convert.ToDouble(this.txtAdjaX1.Text); var AdjaY2 = Convert.ToDouble(this.txtAdjaY1.Text); var AdjaZ2 = Convert.ToDouble(this.txtAdjaZ1.Text); double[] msEph = new double[] { MainX, MainY, MainZ, 0, 0, 0 }; double[] Ns1Eph = new double[] { AdjaX, AdjaY, AdjaZ, 0, 0, 0 }; double[] Ns2Eph = new double[] { AdjaX2, AdjaY2, AdjaZ2, 0, 0, 0 }; var StationRes = new StationRes() { SatTxLon = MsAnt[0], SatTxLat = MsAnt[1], RefLon = RefGeod[0], RefLat = RefGeod[1], }; var cgRes = new CgRes() { SigTime = sigTime, Dto1 = DtoSx, Dto2 = DtoSx1, YbMainDto = YbMainDto, YbAdja1Dto = YbAdja1Dto, YbAdja2Dto = YbAdja2Dto, MainX = MainX, MainY = MainY, MainZ = MainZ, Adja1X = AdjaX, Adja1Y = AdjaY, Adja1Z = AdjaZ, Adja2X = AdjaX2, Adja2Y = AdjaY2, Adja2Z = AdjaZ2, }; var res = info.PosResType == EnumPosResType.X3 ? PosApi.X3_Pos(cgRes, StationRes) : PosApi.X3_PosNoRef(cgRes, StationRes); this.labelControl1.Text = $"{info.PosResType.GetEnumDisplayName()}定位点:[{res[0]},{res[1]}] 镜像点:[{res[3]},{res[4]}]"; } catch (Exception ex) { Serilog.Log.Error(ex, $"绘制{info.PosResType.GetEnumDisplayName()}时差线失败.PosID={info.ID},SigTime={info.SigTime}"); DxHelper.MsgBoxHelper.ShowWarning($"绘制{info.PosResType.GetEnumDisplayName()}时差线失败"); } } private async void btnXl_Click(object sender, EventArgs e) { try { var sigTime = this.sigTime.DateTime; var xlInfo = await XlCache.GetLatestAsync(cg.MainCode.Value, sigTime); if (xlInfo == null) { DxHelper.MsgBoxHelper.ShowWarning($"卫星:{cg.MainCode.Value}未找到对应的星历信息,请导入星历"); return; } var xlInfo1 = await XlCache.GetLatestAsync(cg.Adja1Code.Value, sigTime); if (xlInfo1 == null) { DxHelper.MsgBoxHelper.ShowWarning($"卫星:{cg.Adja1Code.Value}未找到对应的星历信息,请导入星历"); return; } var xlInfo2 = await XlCache.GetLatestAsync(cg.Adja2Code.Value, sigTime); if (xlInfo2 == null) { DxHelper.MsgBoxHelper.ShowWarning($"卫星:{cg.Adja2Code.Value}未找到对应的星历信息,请导入星历"); return; } var mEph = EphHelper.Calc(xlInfo.TwoLine, sigTime); this.txtMainX.Text = $"{mEph.X:f3}"; this.txtMainY.Text = $"{mEph.Y:f3}"; this.txtMainZ.Text = $"{mEph.Z:f3}"; var nEph1 = EphHelper.Calc(xlInfo1.TwoLine, sigTime); this.txtAdjaX.Text = $"{nEph1.X:f3}"; this.txtAdjaY.Text = $"{nEph1.Y:f3}"; this.txtAdjaZ.Text = $"{nEph1.Z:f3}"; var nEph2 = EphHelper.Calc(xlInfo2.TwoLine, sigTime); this.txtAdjaX1.Text = $"{nEph2.X:f3}"; this.txtAdjaY1.Text = $"{nEph2.Y:f3}"; this.txtAdjaZ1.Text = $"{nEph2.Z:f3}"; } catch (Exception ex) { Serilog.Log.Error(ex, $"手动{info.PosResType.GetEnumDisplayName()}推算星历失败.PosID={info.ID},SigTime={info.SigTime}"); DxHelper.MsgBoxHelper.ShowWarning($"手动{info.PosResType.GetEnumDisplayName()}推算星历失败"); } } } }