123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- 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 DxHelper;
- using ExtensionsDev;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.ComponentModel.DataAnnotations;
- using System.Data;
- 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 DW5S.DTO;
- using DW5S.Entity;
- using DW5S.Repostory;
- using Microsoft.Extensions.Logging;
- using Serilog.Core;
- using Microsoft.EntityFrameworkCore;
- namespace DW5S.App.EditForms
- {
- public partial class TaskEditorSignal : DevExpress.XtraEditors.XtraForm
- {
- [Autowired]
- private readonly ILogger logger;
- [Autowired]
- private readonly UnitOfWork unitOfWork;
- public TaskInfo info;
- public List<SigInfo> listSigInfo = new List<SigInfo>();
- public List<SigInfo> listSigInfoSelected = new List<SigInfo>();
- public TaskEditorSignal()
- {
- InitializeComponent();
- this.Text = "任务信号选择";
- info = new TaskInfo();
- this.StartPosition = FormStartPosition.CenterParent;
- }
- public TaskEditorSignal(TaskInfo info, List<SigInfo> 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();
- var repsFixed= unitOfWork.Reps<FixedStation>();
- var fixedStations = await repsFixed.FindAsync(p => p.Enable);
- var repsSig = unitOfWork.Reps<SigInfo>();
- var items = await repsSig.GetAllAsync(p => p.FreqUp);
- 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)
- {
- var msg = "查询信号信息异常";
- logger.LogError(ex, msg);
- DxHelper.MsgBoxHelper.ShowError(msg);
- }
- }
- 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;
- }
- }
- }
|