using System; using System.Collections.Generic; using System.Windows.Forms; namespace TProduct.WinFrmUI.TestBench { public partial class MgrWorkBenchMonitorPointPanel : DevExpress.XtraEditors.XtraUserControl { public MgrWorkBenchMonitorPointPanel() { InitializeComponent(); this.gridView1.SetNormalView(); this.gridView1.SetGridMianViewColor(); this.gridView1.CustomUnboundColumnData += GridView1_CustomUnboundColumnData; } private void GridView1_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e) { if (e.Column == this.colSourceType) { var pt = e.Row as Model.WorkBenchMonitorPoint; if (pt != null) { if (pt.SourceType == Model.eMonitorPointSourceType.未知) { e.Value = "还未设置,请尽快确认"; } if (pt.SourceType == Model.eMonitorPointSourceType.模拟量) { e.Value = "模拟量"; } if (pt.SourceType == Model.eMonitorPointSourceType.数字量) { e.Value = "数字量"; } if (pt.SourceType == Model.eMonitorPointSourceType.额定参数) { e.Value = "额定参数"; } } } if (e.Column == this.colDataParasInfo) { var pt = e.Row as Model.WorkBenchMonitorPoint; if (pt != null) { //if (pt.SourceType == Model.eMonitorPointSourceType.模拟量) //{ // e.Value = "模拟量"; //} //else { e.Value = pt.DataParasInfo4Disp; } } } } private Model.WorkBenchBase _paras; private List _bindList = null; public List GetMonitorList() { return _bindList; } /// /// 初始化 /// /// public void SetBindingData(Model.WorkBenchBase paras) { _paras = paras; if (_paras == null) return; _bindList = new BLL.WorkBenchMonitorPoint().GetByBenchID(_paras.ID); if (_bindList == null) _bindList = new List(); this.bindingSource1.DataSource = _bindList; this.bindingSource1.ResetBindings(false); } private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) { if (e.Column == colEdit) { if (_bindList == null) return; var row = this.gridView1.GetRow(e.RowHandle) as Model.WorkBenchMonitorPoint; if (row == null) { return; } double? dia = null; int pressMonitor = 0;//0 其他 1进口压力 2 出口压力 if (row.MonitorType == Model.eMonitorType.压力) { if(row.Property == TProduct.Model.MonitorTypeProperty.进口) { dia = row.PipeDia; pressMonitor = 1; } if (row.Property == TProduct.Model.MonitorTypeProperty.出口) { dia = row.PipeDia; pressMonitor = 2; } } var dlg = new SetSingleBenchMonitorPointInfoDlg(); dlg.SetBindingData(row); dlg.ReloadDataEvent += rhs => { if(pressMonitor == 1) { //1:来源泵口径 if (TProduct.UserSetting.Setting.PumpTest.InletPressMonitorDiaStatus == 1) { if(dia != row.PipeDia) { MessageBox.Show("已设置为压力测点口径来源泵口径, 所以此处设置测点口径,并不会生效!"); } } } if (pressMonitor == 2) { //1:来源泵口径 if (TProduct.UserSetting.Setting.PumpTest.OutletPressMonitorDiaStatus == 1) { if (dia != row.PipeDia) { MessageBox.Show("已设置为压力测点口径来源泵口径, 所以此处设置测点口径,并不会生效!"); } } } row.Reset(rhs); this.gridView1.RefreshData(); }; dlg.ShowDialog(); } } private void MenuItem添加测点_Click(object sender, EventArgs e) { var dlg = new SetSingleBenchMonitorPointInfoDlg(); dlg.SetBindingData(_paras.ID); dlg.ReloadDataEvent += rhs => { _bindList.Add(rhs); this.bindingSource1.ResetBindings(false); }; dlg.ShowDialog(); } } }