123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- using DevExpress.Xpo;
- using DevExpress.XtraEditors;
- using Ips.Library.Basic;
- using Ips.Library.DxpLib;
- using Ips.Library.Entity;
- using Ips.Sps.Sats;
- 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;
- namespace Ips.Sps.Ephs
- {
- public partial class EphCalcForm : DevExpress.XtraEditors.XtraForm
- {
- public EphCalcForm()
- {
- InitializeComponent();
- txtTime.UseTimeEdit();
- txtEphType.Properties.Items.AddEnum<EphType>();
- _session = new Session();
- }
- Session _session;
- List<Sat> _satList;
- BindingList<EphResult> ephList = new BindingList<EphResult>();
- private void EphCalcForm_Load(object sender, EventArgs e)
- {
- _satList = _session.Query<Sat>().Where(m => m.Enable).OrderBy(m => m.Lon).ToList();
- colSatNumEdit.DataSource = _satList;
- txtSatNum.Properties.Items.AddRange(_satList);
- bsEphResultList.DataSource = ephList;
- }
- private async void btnCalc_Click(object sender, EventArgs e)
- {
- if (txtTime.DateTime == DateTime.MinValue)
- {
- MsgHelper.ShowError("请输入时间");
- return;
- }
- int satNum;
- var sat = txtSatNum.EditValue as Sat;
- if (sat != null)
- {
- satNum = sat.SatNum;
- }
- else if (!int.TryParse(txtSatNum.Text.Trim(), out satNum))
- {
- MsgHelper.ShowError("卫星编号格式不正确!");
- return;
- }
- btnCalc.Enabled = false;
- try
- {
- var time = txtTime.DateTime;
- EphResult result = null;
- if (txtEphType.EditValue == null)
- {
- result = await Task.Run(() => EphManager.Default.GetEph(satNum, time));
- }
- else
- {
- var ephType = (EphType)txtEphType.EditValue;
- if (ephType == EphType.Tle)
- {
- result = await Task.Run(() => EphManager.Default.GetEphTle(satNum, time));
- }
- else if (ephType == EphType.High)
- {
- result = await Task.Run(() => EphManager.Default.GetEphHigh(satNum, time));
- }
- }
- if (result == null)
- {
- MsgHelper.ShowWarn("计算结果为空!");
- }
- else
- {
- ephList.Add(result);
- }
- }
- catch (Exception ex)
- {
- MsgHelper.ShowError("计算星历出错,错误消息:" + ex.Message);
- }
- finally
- {
- btnCalc.Enabled = true;
- }
- }
- private void btnClear_Click(object sender, EventArgs e)
- {
- ephList.Clear();
- }
- private void txtSatNum_CustomDisplayText(object sender, DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs e)
- {
- //var sat = e.Value as Sat;
- //if (sat != null)
- //{
- // e.DisplayText = sat.SatNum.ToString();
- //}
- }
- private void gvEphResult_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
- {
- if (e.Column == colSatNum && e.DisplayText.IsNullOrWhitespace())
- {
- e.DisplayText = e.Value?.ToString();
- }
- }
- }
- }
|