123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- using DevExpress.Mvvm.ModuleInjection.Native;
- using DevExpress.XtraEditors;
- using DevExpress.XtraEditors.DXErrorProvider;
- using ExtensionsDev;
- using System;
- 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 XdDw.App.Api;
- using XdDw.App.EFContext;
- using XzXdDw.App.Model;
- using static System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox;
- namespace XdDw.App.EditForms
- {
- public partial class X2D1PosParamEditor : DevExpress.XtraEditors.XtraForm
- {
- public XDPosRes info;
- public List<TxInfo> listTx;
- private CgRes cgRes;
- private double[] PosRes;
- private Action callBack;
- public X2D1PosParamEditor(XDPosRes info, CgRes cgRes, List<TxInfo> listTx, Action callBack)
- {
- InitializeComponent();
- this.Text = "两星一地定位";
- this.info = info;
- if (cgRes == null)
- {
- cgRes = new CgRes();
- }
- this.cgRes = cgRes;
- this.listTx = listTx;
- this.callBack = callBack;
- 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 X2D1PosParamEditor_Load(object sender, EventArgs e)
- {
- List<string> list = new List<string>();
- using (RHDWContext db = new RHDWContext())
- {
- var res = await db.XlInfos.OrderBy(p => p.SatName).ToListAsync();
- if (res != null)
- list.AddRange(res.Select(p => p.Sat));
- }
- var satTx = listTx.Find(p => p.TxType == EnumTxType.MainSat);
- var cdbTx = listTx.Find(p => p.TxType == EnumTxType.Cdb);
- var refTx = listTx.Find(p => p.TxType == EnumTxType.Ref);
- this.txtsatStation.Text = $"{satTx.Lon},{satTx.Lat}";
- this.txtcdbStation.Text = $"{cdbTx.Lon},{cdbTx.Lat}";
- this.txtRefLocation.Text = $"{refTx.Lon},{refTx.Lat}";
- this.txtDtoSx.Text = $"{cgRes.DtoSx}";
- this.txtDtoCdb.Text = $"{cgRes.DtoCdb}";
- this.txtYbMain.Text = $"{cgRes.YbMain}";
- this.txtYbAdja.Text = $"{cgRes.YbAdja}";
- this.sigTime.EditValue = cgRes.SigTime;
- this.txtMainX.Text = $"{cgRes.MainX}";
- this.txtMainY.Text = $"{cgRes.MainY}";
- this.txtMainZ.Text = $"{cgRes.MainZ}";
- this.txtAdjaX.Text = $"{cgRes.AdjaX}";
- this.txtAdjaY.Text = $"{cgRes.AdjaY}";
- this.txtAdjaZ.Text = $"{cgRes.AdjaZ}";
- }
- private void btnUpdate_Click(object sender, EventArgs e)
- {
- try
- {
- if (!CheckParam()) { return; }
- if (this.listBox.Items.Count == 0)
- {
- XtraMessageBox.Show($"两星一地未定位不能更新到数据库中");
- return;
- }
- cgRes.DtoSx = Convert.ToDouble(this.txtDtoSx.Text);
- cgRes.DtoCdb = Convert.ToDouble(this.txtDtoCdb.Text);
- cgRes.YbMain = Convert.ToDouble(this.txtYbMain.Text);
- cgRes.YbAdja = Convert.ToDouble(this.txtYbAdja.Text);
- cgRes.SigTime = this.sigTime.DateTime;
- cgRes.MainX = Convert.ToDouble(this.txtMainX.Text);
- cgRes.MainY = Convert.ToDouble(this.txtMainY.Text);
- cgRes.MainZ = Convert.ToDouble(this.txtMainZ.Text);
- cgRes.AdjaX = Convert.ToDouble(this.txtAdjaX.Text);
- cgRes.AdjaY = Convert.ToDouble(this.txtAdjaY.Text);
- cgRes.AdjaZ = Convert.ToDouble(this.txtAdjaZ.Text);
- string posstr = this.listBox.Items[0].ToString();
- var allstrs = posstr.Split(new string[] { ":", "定位经度", "定位纬度", "镜像经度", "镜像纬度" }, StringSplitOptions.RemoveEmptyEntries);
- if (allstrs.Length == 4)
- {
- using (RHDWContext db = new RHDWContext())
- {
- info.PosLon = Convert.ToDouble(PosRes[0]);
- info.PosLat = Convert.ToDouble(PosRes[1]);
- info.MirrLon = Convert.ToDouble(PosRes[3]);
- info.MirrLat = Convert.ToDouble(PosRes[4]);
- db.CgRes.AddOrUpdate(cgRes);//参估结果入库
- db.XDPosRes.AddOrUpdate(info);//定位结果入库
- db.SaveChangesAsync();
- }
- callBack?.Invoke();
- XtraMessageBox.Show($"两星一地更新数据成功");
- }
- }
- catch (Exception ex)
- {
- XtraMessageBox.Show($"两星一地更新定位数据失败,失败信息:{ex.Message}");
- }
- }
- 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)
- {
- listBox.Items.Clear();
- if (!CheckParam()) { return; }
- try
- {
- TxInfo satTx = new TxInfo();
- satTx.Lon = Convert.ToDouble(txtsatStation.Text.Replace(",", ",").Split(',')[0].Trim());
- satTx.Lat = Convert.ToDouble(txtsatStation.Text.Replace(",", ",").Split(',')[1].Trim());
- TxInfo cdbTx = new TxInfo();
- cdbTx.Lon = Convert.ToDouble(txtcdbStation.Text.Replace(",", ",").Split(',')[0].Trim());
- cdbTx.Lat = Convert.ToDouble(txtcdbStation.Text.Replace(",", ",").Split(',')[1].Trim());
- TxInfo refTx = new TxInfo();
- refTx.Lon = Convert.ToDouble(txtRefLocation.Text.Replace(",", ",").Split(',')[0].Trim());
- refTx.Lat = Convert.ToDouble(txtRefLocation.Text.Replace(",", ",").Split(',')[1].Trim());
- CgRes cgRes = new CgRes();
- cgRes.DtoSx = Convert.ToDouble(this.txtDtoSx.Text);
- cgRes.DtoCdb = Convert.ToDouble(this.txtDtoCdb.Text);
- cgRes.YbMain = Convert.ToDouble(this.txtYbMain.Text);
- cgRes.YbAdja = Convert.ToDouble(this.txtYbAdja.Text);
- cgRes.SigTime = this.sigTime.DateTime;
- cgRes.MainX = Convert.ToDouble(this.txtMainX.Text);
- cgRes.MainY = Convert.ToDouble(this.txtMainY.Text);
- cgRes.MainZ = Convert.ToDouble(this.txtMainZ.Text);
- cgRes.AdjaX = Convert.ToDouble(this.txtAdjaX.Text);
- cgRes.AdjaY = Convert.ToDouble(this.txtAdjaY.Text);
- cgRes.AdjaZ = Convert.ToDouble(this.txtAdjaZ.Text);
- PosRes = PosApi.X2D1_POS(cgRes, satTx, cdbTx, refTx);
- listBox.Items.Add($"定位经度:{PosRes[0]:f4} 定位纬度:{PosRes[1]:f4} 镜像经度:{PosRes[3]:f4} 镜像纬度:{PosRes[4]:f4}");
- }
- catch (Exception ex)
- {
- XtraMessageBox.Show($"两星一地定位失败,失败信息:{ex.Message}");
- }
- }
- }
- }
|