using DevExpress.Utils.About; using DevExpress.Utils.Extensions; using DevExpress.XtraBars.Customization; using DevExpress.XtraEditors; using DevExpress.XtraEditors.Controls; using DevExpress.XtraEditors.DXErrorProvider; using DevExpress.XtraGrid; using DevExpress.XtraPrinting.Native; using DPP_YH_Core.Extensions; using DxHelper; using ExtensionsDev; using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Data; using System.Data.Entity; using System.Drawing; using System.Linq; using System.Reflection; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Windows.Documents; using System.Windows.Forms; using XdCxRhDW.Dto; using XdCxRhDW.Entity; using XdCxRhDW.Repostory; namespace XdCxRhDW.App.EditForms { public partial class TaskEditorSignal : DevExpress.XtraEditors.XtraForm { public TaskInfo info; public List listSigInfo = new List(); public List listSigInfoSelected = new List(); public TaskEditorSignal() { InitializeComponent(); this.Text = "任务信号选择"; info = new TaskInfo(); this.StartPosition = FormStartPosition.CenterParent; } public TaskEditorSignal(TaskInfo info, List listSigInfoSelected) : this() { this.Text = $"任务[{info.TaskName}]信号选择"; this.info = info; this.listSigInfoSelected = listSigInfoSelected.Skip(0).ToList(); } private async void TaskEditorSignal_Load(object sender, EventArgs e) { try { gridTaskSignal.UseDefault(listSigInfo).UseMultiSelect().UseRowNumber().DrawGridColumnHeaderCheckBox(); using (var db = new RHDWContext()) { var fixedStations = await db.FixedStation.Where(p => p.Enable).ToListAsync(); var items = await db.SigInfos.OrderBy(p => p.FreqUp).ToListAsync(); listSigInfo.AddRange(items); foreach (var item in listSigInfo) { if (fixedStations.Any(p => p.FreqUpHz == item.FreqUp)) item.IsFixedStationFreq = "✔"; else item.IsFixedStationFreq = "✖"; } } foreach (var item in listSigInfoSelected) { var selectedIdx = listSigInfo.FindIndex(p => p.ID == item.ID); if (selectedIdx >= 0) this.gridViewTaskSignal.SelectRow(selectedIdx); } gridViewTaskSignal.BestFitColumns(); } catch (Exception ex) { XdCxRhDW.Framework.LogHelper.Error("查询信号信息异常", ex); DxHelper.MsgBoxHelper.ShowError("查询信号信息异常"); } } private void btnCancle_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; } private void btnOk_Click(object sender, EventArgs e) { var selectedRows = gridViewTaskSignal.GetSelectedRows(); listSigInfoSelected.Clear(); for (int i = 0; i < selectedRows.Count(); i++) { var res = gridViewTaskSignal.GetRow(selectedRows[i]) as SigInfo; listSigInfoSelected.Add(res); } int count = listSigInfoSelected.Count(s => s.IsFixedStationFreq.Trim() == "✔".Trim()); if (count >= 2) { DxHelper.MsgBoxHelper.ShowError("只支持一个固定站频点"); return; } this.DialogResult = DialogResult.OK; } } }