using DevExpress.XtraEditors.Repository; using DevExpress.XtraRichEdit.Design; using Yw.WinFrmUI.Hydro; namespace Yw.WinFrmUI { public partial class SetHydroMarkPureCtrl : DevExpress.XtraEditors.XtraUserControl { public SetHydroMarkPureCtrl() { InitializeComponent(); this.gridView1.SetNormalEditView(); this.colName.OptionsColumn.AllowEdit = false; this.gridView1.CustomRowCellEdit += GridView1_CustomRowCellEdit; } private Func _hydroInfoFunc; private BindingList _allBindingList = null; /// /// /// public void SetBindingData(Func hydroInfoFunc, List list) { _hydroInfoFunc = hydroInfoFunc; _allBindingList = new BindingList(); list?.ForEach(x => { _allBindingList.Add(x); }); this.hydroMarkSetViewModelBindingSource.DataSource = _allBindingList; this.hydroMarkSetViewModelBindingSource.ResetBindings(false); } /// /// 获取结果列表 /// /// public List GetResultList() { var hydroInfo = _hydroInfoFunc?.Invoke(); if (hydroInfo == null) { return default; } if (_allBindingList == null || _allBindingList.Count < 1) { return default; } var resultList = new List(); return resultList; } //自定义 private void GridView1_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e) { var row = this.gridView1.GetRow(e.RowHandle) as HydroMarkSetViewModel; if (row == null) { return; } if (e.Column == this.colMarkType) { var repositoryItem = new RepositoryItemImageComboBox(); switch (row.Code) { case Yw.Hydro.ParterCatalog.Waterbox: { repositoryItem.AddEnum(typeof(eWaterboxMarkType), true); } break; case Yw.Hydro.ParterCatalog.Pump: { repositoryItem.AddEnum(typeof(ePumpMarkType), true); } break; case Yw.Hydro.ParterCatalog.Valve: { repositoryItem.AddEnum(typeof(eValveMarkType), true); } break; case Yw.Hydro.ParterCatalog.Pipe: { repositoryItem.AddEnum(typeof(ePipeMarkType), true); } break; case Yw.Hydro.ParterCatalog.Nozzle: { repositoryItem.AddEnum(typeof(eNozzleMarkType), true); } break; default: break; } e.RepositoryItem = repositoryItem; } } } }