namespace HStation.WinFrmUI { public partial class XhsProjectSimulationAnalysisCtrl : DevExpress.XtraEditors.XtraUserControl { public XhsProjectSimulationAnalysisCtrl() { InitializeComponent(); this.gridView1.SetNormalView(30); this.gridView1.RegistCustomDrawRowIndicator(40); } private List _allBindingList; public void SetBindingData(Model.RevitModel revitModel) { if (revitModel == null) return; _allBindingList = new List(); this.xhsProjectSimulationAnalysisViewModelBindingSource.DataSource = _allBindingList; var allRevitParterList = revitModel.GetAllParters(); foreach (var revitParter in allRevitParterList) { if (revitParter.PropStatusList != null && revitParter.PropStatusList.Count > 0) { foreach (var revitParterPropStatus in revitParter.PropStatusList) { if (revitParterPropStatus.PropStatus == HStation.Revit.ePropStatus.Error) { // hasRevitPropError = true; } switch (revitParterPropStatus.PropStatus) { case Revit.ePropStatus.Error: { _allBindingList.Add(new XhsProjectSimulationAnalysisViewModel { Type = revitParter.Catalog, Code = revitParter.Id, Name = revitParter.Name, Description = revitParterPropStatus.StatusInfo, ErrorLevel = "Error", PropStatus = "错误" }); } break; case Revit.ePropStatus.Lack: { _allBindingList.Add(new XhsProjectSimulationAnalysisViewModel { Type = revitParter.Catalog, Code = revitParter.Id, Name = revitParterPropStatus.PropName, Description = revitParterPropStatus.StatusInfo, ErrorLevel = "Lack", PropStatus = "缺省" }); } break; case Revit.ePropStatus.Abnormal: { _allBindingList.Add(new XhsProjectSimulationAnalysisViewModel { Type = revitParter.Catalog, Code = revitParter.Id, Name = revitParterPropStatus.PropName, Description = revitParterPropStatus.StatusInfo, ErrorLevel = "Abnormal", PropStatus = "异常" }); } break; default: break; } } } } this.xhsProjectSimulationAnalysisViewModelBindingSource.ResetBindings(false); } //自定义单元格颜色 private void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e) { var row = this.gridView1.GetRow(e.RowHandle) as XhsProjectSimulationAnalysisViewModel; if (row == null) { return; } if (e.RowHandle != this.gridView1.FocusedRowHandle) { switch (row.ErrorLevel) { case "Error": e.Appearance.BackColor = Color.Red; e.Appearance.ForeColor = Color.White; break; case "Lack": e.Appearance.BackColor = Color.Gray; e.Appearance.ForeColor = Color.White; break; case "Abnormal": e.Appearance.BackColor = Color.Orange; e.Appearance.ForeColor = Color.White; break; } }; } } }