using DevExpress.XtraEditors; using ExtensionsDev; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.Entity; using System.Drawing; using System.Linq; using System.Runtime.Remoting.Metadata.W3cXsd2001; using System.Text; using System.Threading.Tasks; using System.Windows.Documents; using System.Windows.Forms; using XdCxRhDW.Entity; using XdCxRhDW.Repostory; namespace XdCxRhDW.App.EditForms { public partial class SigEditor : DevExpress.XtraEditors.XtraForm { public SigInfo info; public SigEditor() { InitializeComponent(); this.layoutControl1.UseDefault(); this.Text = "添加信号"; info = new SigInfo(); this.StartPosition = FormStartPosition.CenterParent; } public SigEditor(SigInfo info) : this() { this.Text = "编辑信号"; this.info = info; } private void SatEditor_Load(object sender, EventArgs e) { txtSigType.AddEnum(); if (this.Text == "编辑信号" && info != null) { this.txtFreqUp.EditValue = info.FreqUp; this.txtFreqDown.EditValue = info.FreqDown; this.txtSnr.EditValue = info.Snr; //List deWay = new List(); //if (info.SigType.HasFlag(EnumSigCheckType.DAMA)) //{ // deWay.Add(EnumSigCheckType.DAMA); //} //if (info.SigType.HasFlag(EnumSigCheckType.IBS)) //{ // deWay.Add(EnumSigCheckType.IBS); //} //if (info.SigType.HasFlag(EnumSigCheckType.Ky5758)) //{ // deWay.Add(EnumSigCheckType.Ky5758); //} //this.txtSigType.EditValue = string.Join(",", deWay); //this.txtSigType.EditValue = info.SigType.ToString(); } } private void btnCancel_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; } private void btnOk_Click(object sender, EventArgs e) { try { dxErrorProvider.ClearErrors(); if (txtFreqUp.EditValue == null) { dxErrorProvider.SetError(txtFreqUp, "请输入上行频点"); return; } if (txtFreqDown.EditValue == null) { dxErrorProvider.SetError(txtFreqDown, "请输入下行频点"); return; } if (!txtSigType.Items.Any(p => p.CheckState == CheckState.Checked)) { dxErrorProvider.SetError(txtSigType, "请选择信号类型"); return; } if (txtSnr.EditValue == null) { dxErrorProvider.SetError(txtSnr, "请输入门限"); return; } info.FreqUp = Convert.ToDouble(txtFreqUp.EditValue); info.FreqDown = Convert.ToDouble(txtFreqDown.EditValue); info.Snr = Convert.ToDouble(txtSnr.EditValue); var res = txtSigType.Items.Where(p => p.CheckState == CheckState.Checked).Select(t => (EnumSigCheckType)t.Value).ToList(); EnumSigCheckType sigType = res.First(); for (int i = 1; i < res.Count; i++) { sigType |= res[i]; } info.SigType = sigType; this.DialogResult = DialogResult.OK; } catch (Exception ex) { Serilog.Log.Error(ex, "编辑信号信息出错"); DxHelper.MsgBoxHelper.ShowError("编辑信号信息出错"); } } private void txtSigType_SelectedIndexChanged(object sender, EventArgs e) { var idx = txtSigType.SelectedIndex; txtSigType.Items[idx].InvertCheckState(); } private void txtSigType_ItemCheck_1(object sender, DevExpress.XtraEditors.Controls.ItemCheckEventArgs e) { if (e.State == CheckState.Checked) { if (e.Index < 3) { txtSigType.Items[EnumSigCheckType.Normal].CheckState = CheckState.Unchecked; } else { txtSigType.Items[EnumSigCheckType.DAMA].CheckState = CheckState.Unchecked; txtSigType.Items[EnumSigCheckType.IBS].CheckState = CheckState.Unchecked; txtSigType.Items[EnumSigCheckType.Ky5758].CheckState = CheckState.Unchecked; } } } } }