using DevExpress.XtraEditors; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace HStation.WinFrmUI { public partial class XhsSchemeFlowmeterChangeListCtrl : DevExpress.XtraEditors.XtraUserControl { public XhsSchemeFlowmeterChangeListCtrl() { InitializeComponent(); this.layoutView1.SetDefuaulView(); this.layoutView1.SetFindPanel(); } /// /// 水力查看事件 /// public event Action HydroViewEvent; /// /// 水力改变事件 /// public event Action HydroChangeEvent; private BindingList _allBindingList = null;//所有绑定列表 /// /// 绑定数据 /// public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo) { _allBindingList = new BindingList(); if (hydroInfo != null) { if (hydroInfo.Flowmeters != null && hydroInfo.Flowmeters.Count > 0) { foreach (var blunthead in hydroInfo.Flowmeters) { var vm = new HydroFlowmeterViewModel(blunthead, hydroInfo); var viewModel = new XhsSchemeFlowmeterChangeViewModel(vm); viewModel.ViewImage = this.svgImg32[0]; _allBindingList.Add(viewModel); } } } this.xhsSchemeFlowmeterChangeViewModelBindingSource.DataSource = _allBindingList; this.xhsSchemeFlowmeterChangeViewModelBindingSource.ResetBindings(false); } /// /// 绑定数据 /// public void SetBindingData(List allVisualViewModelList) { _allBindingList = new BindingList(); if (allVisualViewModelList != null && allVisualViewModelList.Count > 0) { foreach (var visualViewModel in allVisualViewModelList) { if (visualViewModel.Vmo.Catalog == Yw.Hydro.ParterCatalog.Flowmeter) { var vm = visualViewModel as HydroFlowmeterViewModel; if (vm != null) { var viewModel = new XhsSchemeFlowmeterChangeViewModel(vm); viewModel.ViewImage = this.svgImg32[0]; _allBindingList.Add(viewModel); } } } } this.xhsSchemeFlowmeterChangeViewModelBindingSource.DataSource = _allBindingList; this.xhsSchemeFlowmeterChangeViewModelBindingSource.ResetBindings(false); } /// /// 绑定数据 /// public void SetBindingData(List allFlowmeterViewModelList) { _allBindingList = new BindingList(); if (allFlowmeterViewModelList != null && allFlowmeterViewModelList.Count > 0) { foreach (var fourlinkViewModel in allFlowmeterViewModelList) { var viewModel = new XhsSchemeFlowmeterChangeViewModel(fourlinkViewModel); viewModel.ViewImage = this.svgImg32[0]; _allBindingList.Add(viewModel); } } this.xhsSchemeFlowmeterChangeViewModelBindingSource.DataSource = _allBindingList; this.xhsSchemeFlowmeterChangeViewModelBindingSource.ResetBindings(false); } /// /// 设置聚焦行 /// public void SetFocusedRow(int rowHandle) { this.layoutView1.FocusedRowHandle = rowHandle; } //字段点击 private void layoutView1_FieldValueClick(object sender, DevExpress.XtraGrid.Views.Layout.Events.FieldValueClickEventArgs e) { var row = this.layoutView1.GetRow(e.RowHandle) as XhsSchemeFlowmeterChangeViewModel; if (row == null) { return; } if (e.Column == this.colSvgImage) { var input = Yw.WinFrmUI.HydroMatchingHelper.Create(row.ViewModel.Vmo, row.ViewModel.HydroInfo); var dlg = new AssetsFlowmeterSingleMatchingDlg(); dlg.ReloadDataEvent += (output) => { if (Yw.WinFrmUI.HydroMatchingHelper.Apply(row.ViewModel, output)) { this.layoutView1.RefreshRow(e.RowHandle); this.HydroChangeEvent?.Invoke(row.ViewModel); } }; dlg.SetBindingData(input); dlg.ShowDialog(); } else if (e.Column == this.colViewImage) { this.HydroViewEvent?.Invoke(row.ViewModel.Vmo.Code); } } //卡片点击 private void layoutView1_CardClick(object sender, DevExpress.XtraGrid.Views.Layout.Events.CardClickEventArgs e) { var row = this.layoutView1.GetRow(e.RowHandle) as XhsSchemeFlowmeterChangeViewModel; if (row == null) { return; } } //选中列变换 private void layoutView1_FocusedColumnChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedColumnChangedEventArgs e) { } //单元格值变换 private void layoutView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { var row = this.layoutView1.GetRow(e.RowHandle) as XhsSchemeFlowmeterChangeViewModel; if (row == null) { return; } row.ViewModel.UpdateVmoProperty(); this.HydroChangeEvent?.Invoke(row.ViewModel); } private void toolTipController1_GetActiveObjectInfo(object sender, DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventArgs e) { // 获取当前鼠标所在的单元格信息 //var hitInfo = this.layoutView1.CalcHitInfo(e.ControlMousePosition); //if (hitInfo != null && hitInfo.RowHandle >= 0 && hitInfo.Column != null) //{ // if (hitInfo.Column == this.colSvgImage) // { // e.Info = new DevExpress.Utils.ToolTipControlInfo(this.gridControl1, "从产品中选择"); // } // else if (hitInfo.Column == this.colName) // { // e.Info = new DevExpress.Utils.ToolTipControlInfo(this.gridControl1, "名称"); // } // else if (hitInfo.Column == this.colViewImage) // { // e.Info = new DevExpress.Utils.ToolTipControlInfo(this.gridControl1, "模型定位"); // } // else if (hitInfo.Column == this.colMaterial) // { // e.Info = new DevExpress.Utils.ToolTipControlInfo(this.gridControl1, "材质"); // } // else if (hitInfo.Column == this.colCaliber) // { // e.Info = new DevExpress.Utils.ToolTipControlInfo(this.gridControl1, "口径(mm)"); // } // else if (hitInfo.Column == this.colRunningThroughLoss) // { // e.Info = new DevExpress.Utils.ToolTipControlInfo(this.gridControl1, "主管通过损失系数"); // } // else if (hitInfo.Column == this.colBranchThroughLoss) // { // e.Info = new DevExpress.Utils.ToolTipControlInfo(this.gridControl1, "支管通过损失系数"); // } // else // { // //e.Info = null; // } // return; //} //else //{ // //e.Info = null; //} } } }