using DevExpress.Utils.About; using DevExpress.XtraEditors; using DevExpress.XtraEditors.Controls; 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.Text; using System.Threading.Tasks; using System.Windows.Documents; using System.Windows.Forms; using XdCxRhDW.Repostory.EFContext; using XdCxRhDW.Repostory.Model; namespace XdCxRhDW.App.EditForms { public partial class TaskEditor : DevExpress.XtraEditors.XtraForm { public TaskInfo info; public TaskEditor() { InitializeComponent(); this.Text = "添加任务"; info = new TaskInfo(); this.StartPosition = FormStartPosition.CenterParent; //加载DW类型 List radioGroups = new List(); var values = Enum.GetValues(typeof(EnumPosType)); foreach (var item in values) { radioGroups.Add(new RadioGroupItem(Convert.ToInt32(item), ((EnumPosType)item).GetEnumDisplayName())); } this.txtPosType.Properties.Items.AddRange(radioGroups.ToArray()); } public TaskEditor(TaskInfo info) : this() { this.Text = "编辑任务"; this.info = info; } private async void TaskEditor_Load(object sender, EventArgs e) { using (RHDWContext db = new RHDWContext()) { var sats = await db.SatInfos.ToListAsync(); this.txtMainSat.UseDefault().SetData(sats, nameof(SatInfo.Sat)).UseDoubleClickToSelectAll(); this.txtAdja1Sat.UseDefault().SetData(sats, nameof(SatInfo.Sat)).UseDoubleClickToSelectAll(); this.txtAdja2Sat.UseDefault().SetData(sats, nameof(SatInfo.Sat)).UseDoubleClickToSelectAll(); } if (this.Text == "编辑任务" && info != null) { this.txtTaskName.Text = info.TaskName; this.txtPosType.SelectedIndex = (int)info.PosType; } } private void btnSave_Click(object sender, EventArgs e) { try { info.TaskState = EnumTaskState.Stopped; info.TaskName = txtTaskName.Text; info.PosType = (EnumPosType)txtPosType.SelectedIndex; info.MainSat = ((SatInfo)txtMainSat.EditValue).SatCode; info.Adja1Sat = ((SatInfo)txtAdja1Sat.EditValue).SatCode; info.Adja2Sat = ((SatInfo)txtAdja2Sat.EditValue).SatCode; info.Freq = (long)((double)txtFreq.EditValue * 1e6); info.Band = (int)((double)txtBand.EditValue * 1e6); this.DialogResult = DialogResult.OK; } catch (Exception ex) { Serilog.Log.Error(ex, "编辑任务信息出错"); DxHelper.MsgBoxHelper.ShowError("编辑任务信息出错"); } } private void txtPosType_SelectedIndexChanged(object sender, EventArgs e) { switch (txtPosType.SelectedIndex) { case 0: break; case 1: break; default: break; } } private void txtPosType_EditValueChanged(object sender, EventArgs e) { } } }