| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 | 
							- using DevExpress.Internal.WinApi.Windows.UI.Notifications;
 
- using DevExpress.XtraEditors;
 
- using DevExpress.XtraLayout.Utils;
 
- using System;
 
- using System.Collections.Generic;
 
- using System.ComponentModel;
 
- using System.Data;
 
- using System.Drawing;
 
- using System.IO;
 
- using System.Linq;
 
- using System.Text;
 
- using System.Threading.Tasks;
 
- using System.Windows.Forms;
 
- using XdCxRhDW.Core.Api;
 
- namespace XdCxRhDW.App.CorTools
 
- {
 
-     public partial class CorToolForm : DevExpress.XtraEditors.XtraForm
 
-     {
 
-         static readonly string inifile = Path.Combine(Application.StartupPath, "par.ini");
 
-         volatile bool beRunning = false;
 
-         BindingList<CafResult> gridSource = new BindingList<CafResult>();
 
-         public CorToolForm()
 
-         {
 
-             InitializeComponent();
 
-         }
 
-         void openfile(object sender)
 
-         {
 
-             if (openFileDialog1.ShowDialog() == DialogResult.OK)
 
-             {
 
-                 if (sender == btnFile1)
 
-                 {
 
-                     btnFile1.Text = openFileDialog1.FileName;
 
-                 }
 
-                 else
 
-                 {
 
-                     btnFile2.Text = openFileDialog1.FileName;
 
-                 }
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 读取配置
 
-         /// </summary>
 
-         void ReadIni()
 
-         {
 
-             if (File.Exists(inifile))
 
-             {
 
-                 var lines = File.ReadAllLines(inifile);
 
-                 if (lines.Length != 9)
 
-                 {
 
-                     return;
 
-                 }
 
-                 btnFile1.Text = lines[0];
 
-                 btnFile2.Text = lines[1];
 
-                 teCount.Text = lines[2];
 
-                 tefs.Text = lines[3];
 
-                 teCenter.Text = lines[4];
 
-                 teRange.Text = lines[5];
 
-                 teSnr.Text = lines[6];
 
-                 tePos.Text = lines[7];
 
-                 teDfRange.Text = lines[8];
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 写入配置
 
-         /// </summary>
 
-         void WriteIni()
 
-         {
 
-             var lines = new List<String>();
 
-             lines.Add(btnFile1.Text);
 
-             lines.Add(btnFile2.Text);
 
-             lines.Add(teCount.Text);
 
-             lines.Add(tefs.Text);
 
-             lines.Add(teCenter.Text);
 
-             lines.Add(teRange.Text);
 
-             lines.Add(teSnr.Text);
 
-             lines.Add(tePos.Text);
 
-             lines.Add(teDfRange.Text);
 
-             File.WriteAllLines(inifile, lines);
 
-         }
 
-         private void MainForm_Load(object sender, EventArgs e)
 
-         {
 
-             this.gridControl1.DataSource = gridSource;
 
-             ReadIni();
 
-         }
 
-         private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 
-         {
 
-             //if (!DxHelper.MsgBoxHelper.ShowConfirm("是否退出当前程序"))
 
-             //{
 
-             //    e.Cancel = true;
 
-             //}
 
-         }
 
-         private bool ValidateFile(string filename)
 
-         {
 
-             if (string.IsNullOrWhiteSpace(filename))
 
-             {
 
-                 DxHelper.MsgBoxHelper.ShowError($"请选择文件!");
 
-                 return false;
 
-             }
 
-             if (!File.Exists(filename))
 
-             {
 
-                 DxHelper.MsgBoxHelper.ShowError($"文件【{filename}】不存在");
 
-                 return false;
 
-             }
 
-             return true;
 
-         }
 
-         private async void btnOK_Click(object sender, EventArgs e)
 
-         {
 
-             if (btnOK.Text == "停止")
 
-             {
 
-                 //XcorrUtils.Stop();
 
-                 return;
 
-             }
 
-             //开始计算
 
-             //校验文件名称
 
-             if (!ValidateFile(btnFile1.Text))
 
-             {
 
-                 return;
 
-             }
 
-             if (!ValidateFile(btnFile2.Text))
 
-             {
 
-                 return;
 
-             }
 
-             XcorrStruct xItem = new XcorrStruct();
 
-             xItem.file1 = btnFile1.Text;
 
-             xItem.file2 = btnFile2.Text;
 
-             try
 
-             {
 
-                 xItem.smpCount = int.Parse(teCount.Text);
 
-                 xItem.samplingRate = Convert.ToInt32(double.Parse(tefs.Text) * 1e6);
 
-                 xItem.dtCenter = int.Parse(teCenter.Text);
 
-                 xItem.dtRange = int.Parse(teRange.Text);
 
-                 xItem.dfRange = int.Parse(teDfRange.Text);
 
-                 xItem.smpStart = int.Parse(tePos.Text);
 
-                 xItem.snrThreshold = int.Parse(teSnr.Text);
 
-             }
 
-             catch
 
-             {
 
-                 DxHelper.MsgBoxHelper.ShowError($"参数错误");
 
-                 return;
 
-             }
 
-             WriteIni();
 
-             btnOK.Text = "停止";
 
-             beRunning = true;
 
-             //if (chkDama.Checked is false)
 
-             //{
 
-                 var result = await ExecuteCorAsync(xItem);
 
-                 if (result != null)
 
-                 {
 
-                     gridSource.Add(result);
 
-                     gridView1.FocusedRowHandle = gridSource.Count - 1;
 
-                 }
 
-             //}
 
-             //else
 
-             //{
 
-             //    foreach (var cafItem in gridSource)
 
-             //    {
 
-             //        if (!beRunning) continue;
 
-             //        xItem.smpStart = (int)cafItem.smpstart;
 
-             //        xItem.smpCount = (int)cafItem.smplen;
 
-             //        var result = await ExecuteCorAsync(xItem);
 
-             //        if (result != null)
 
-             //        {
 
-             //            cafItem.dt = result.dt;
 
-             //            cafItem.df = result.df;
 
-             //            cafItem.snr = result.snr;
 
-             //            cafItem.tm = result.tm;
 
-             //        }
 
-             //    }
 
-             //    gridControl1.RefreshDataSource();
 
-             //}
 
-             btnOK.Text = "计算";
 
-             beRunning = false;
 
-         }
 
-         private async Task<CafResult> ExecuteCorAsync(XcorrStruct xItem)
 
-         {
 
-             XcorrUtils xcorr = new XcorrUtils();
 
-             var result = await xcorr.Calc(xItem);
 
-             //开始计算
 
-             if (result.flag == -2)
 
-             {
 
-                 DxHelper.MsgBoxHelper.ShowError($"内部错误");
 
-                 btnOK.Text = "计算";
 
-                 beRunning = false;
 
-                 return null;
 
-             }
 
-             else if (result.flag == -1)
 
-             {
 
-                 DxHelper.MsgBoxHelper.ShowError($"计算所需数据超出文件范围");
 
-                 btnOK.Text = "计算";
 
-                 beRunning = false;
 
-                 return null;
 
-             }
 
-             else if (result.flag == -3)
 
-             {
 
-                 btnOK.Text = "计算";
 
-                 beRunning = false;
 
-                 return null;
 
-             }
 
-             return result;
 
-         }
 
-         private void ExecuteDamaAsync()
 
-         {
 
-         }
 
-         /// <summary>
 
-         /// 网格右键菜单弹出
 
-         /// </summary>
 
-         /// <param name="sender"></param>
 
-         /// <param name="e"></param>
 
-         private void gridView1_MouseDown(object sender, MouseEventArgs e)
 
-         {
 
-             if (e.Button == MouseButtons.Right && !beRunning)
 
-             {
 
-                 popupMenu1.ShowPopup(Cursor.Position);
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 清除网格
 
-         /// </summary>
 
-         /// <param name="sender"></param>
 
-         /// <param name="e"></param>
 
-         private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 
-         {
 
-             gridSource.Clear();
 
-         }
 
-         /// <summary>
 
-         /// 文件拖拽
 
-         /// </summary>
 
-         /// <param name="sender"></param>
 
-         /// <param name="e"></param>
 
-         private void btnFile_DragOver(object sender, DragEventArgs e)
 
-         {
 
-             e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None;
 
-         }
 
-         private void btnFile_DragDrop(object sender, DragEventArgs e)
 
-         {
 
-             string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
 
-             if (files != null && files.Length != 0)
 
-             {
 
-                 if (sender == btnFile1)
 
-                 {
 
-                     btnFile1.Text = files[0];
 
-                 }
 
-                 else if (sender == btnFile2)
 
-                 {
 
-                     btnFile2.Text = files[0];
 
-                 }
 
-             }
 
-         }
 
-         private void btnFile_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
 
-         {
 
-             openfile(sender);
 
-         }
 
-         private void btnFile_DoubleClick(object sender, EventArgs e)
 
-         {
 
-             openfile(sender);
 
-         }
 
-         private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 
-         {
 
-             SaveFileDialog dialog = new SaveFileDialog();
 
-             dialog.Filter = "csv|*.csv";
 
-             if (dialog.ShowDialog() == DialogResult.OK)
 
-             {
 
-                 gridView1.ExportToCsv(dialog.FileName);
 
-             }
 
-         }
 
-         private async void btnCheck_Click(object sender, EventArgs e)
 
-         {
 
-             //if (!ValidateFile(btnFile1.Text))
 
-             //{
 
-             //    return;
 
-             //}
 
-             //var dmcResult = await XcorrUtils.DmcCheckAsync(btnFile1.Text, double.Parse(tefs.Text));
 
-             //gridSource.Clear();
 
-             //foreach (var dmcItem in dmcResult)
 
-             //{
 
-             //    gridSource.Add(new CafResult()
 
-             //    {
 
-             //        file1 = btnFile1.Text,
 
-             //        file2 = btnFile2.Text,
 
-             //        smpstart = dmcItem.Start,
 
-             //        smplen = dmcItem.Length
 
-             //    });
 
-             //}
 
-         }
 
-         private void chkDama_CheckedChanged(object sender, EventArgs e)
 
-         {
 
-             //lciBtnCheck.Visibility = chkDama.Checked ? LayoutVisibility.Always : LayoutVisibility.Never;
 
-             //lciStartPos.Visibility = lciSampleLength.Visibility = chkDama.Checked ? LayoutVisibility.Never : LayoutVisibility.Always;
 
-             //layoutControl1.BestFit();
 
-         }
 
-     }
 
- }
 
 
  |