lixiaojun
2024-11-07 31cca463443f7bc8b6b1bd02889844b864d93e11
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
namespace HStation.WinFrmUI
{
    public partial class XhsProjectSimulationAnalysisCtrl : DevExpress.XtraEditors.XtraUserControl
    {
        public XhsProjectSimulationAnalysisCtrl()
        {
            InitializeComponent();
            this.gridView1.SetNormalView(30);
            this.gridView1.RegistCustomDrawRowIndicator(40);
        }
 
        private List<XhsProjectSimulationAnalysisViewModel> _allBindingList;
 
        public void SetBindingData(Model.RevitModel revitModel)
        {
            if (revitModel == null)
                return;
            _allBindingList = new List<XhsProjectSimulationAnalysisViewModel>();
            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;
                }
            };
        }
    }
}