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.Properties.Items.Clear(); txtSigType.Properties.Items.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 { if (txtFreqUp.EditValue == null) { dxErrorProvider.SetError(txtFreqUp, "请输入上行频点"); return; } if (txtFreqDown.EditValue == null) { dxErrorProvider.SetError(txtFreqDown, "请输入下行频点"); return; } if (string.IsNullOrEmpty(txtSigType.EditValue.ToString())) { 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.EditValue.ToString().Split(new string[] { "," }, System.StringSplitOptions.RemoveEmptyEntries).ToList(); if (res.Count() == 2) { info.SigType = (EnumSigCheckType)Enum.Parse(typeof(EnumSigCheckType), res[0]) | (EnumSigCheckType)Enum.Parse(typeof(EnumSigCheckType), res[1]); } else if (res.Count() == 3) { info.SigType = (EnumSigCheckType)Enum.Parse(typeof(EnumSigCheckType), res[0]) | (EnumSigCheckType)Enum.Parse(typeof(EnumSigCheckType), res[1]) | (EnumSigCheckType)Enum.Parse(typeof(EnumSigCheckType), res[2]); } else { info.SigType = (EnumSigCheckType)Enum.Parse(typeof(EnumSigCheckType), res[0]); } this.DialogResult = DialogResult.OK; } catch (Exception ex) { Serilog.Log.Error(ex, "编辑信号信息出错"); DxHelper.MsgBoxHelper.ShowError("编辑信号信息出错"); } } } }