123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- 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<EnumSigCheckType>();
- if (this.Text == "编辑信号" && info != null)
- {
- this.txtFreqUp.EditValue = info.FreqUp;
- this.txtFreqDown.EditValue = info.FreqDown;
- this.txtSnr.EditValue = info.Snr;
- //List<EnumSigCheckType> deWay = new List<EnumSigCheckType>();
- //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;
- }
- }
- }
- }
- }
|