tx
2025-04-09 fa7510e1ed63df0366787fa4ed1b3db6426d2b46
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
using DevExpress.XtraEditors;
using System.Collections.Generic;
using TProduct.Model;
 
namespace TProduct.WinFrmUI.TPump
{
    public partial class FeatTestAutoParasCtrl : XtraUserControl
    {
        public FeatTestAutoParasCtrl()
        {
            InitializeComponent();
 
            this.gridViewMain.RowHeight = 32;
            this.gridViewMain.OptionsDetail.ShowDetailTabs = false;//不显示TAB名
            this.gridViewMain.OptionsView.ShowGroupPanel = false;//隐藏最上面的GroupPanel
            this.gridViewMain.OptionsSelection.MultiSelect = false;//单选
            this.gridViewMain.OptionsBehavior.Editable = false;//只读
            this.gridViewMain.BestFitColumns();
            this.gridViewMain.IndicatorWidth = 2;
 
            this.gridViewMain.CustomDrawCell += GridViewMain_CustomDrawCell;
            this.gridViewMain.OptionsView.EnableAppearanceEvenRow = true;
            this.gridViewMain.OptionsView.EnableAppearanceOddRow = true;
        }
 
 
 
        class CurrentViewModel
        {
            public CurrentViewModel(AutoTestSettingItem d)
            {
                this.Degree = d.TargetValue;
                this.Duration = d.Duration;
                this.CorrectPtQ = "还未到";
            }
            public double Degree { get; set; }
            public double Duration { get; set; }
            public string StatusName { get; set; }
            public string CorrectPtQ { get; set; }
            public string CorrectPtH { get; set; }
            public string CorrectPtE { get; set; }
            public string CorrectPtP { get; set; }
            public bool IsFinish { get; set; } = false;
            public bool IsOk { get; set; } = false;
        }
 
        //刷新数据源
        public bool RefreshData(List<TProduct.Model.PumpFeatTestRecordViewModel> allRecords)
        {
            return true;
        }
        public bool ClearData()
        {
            this.bindingSource1.DataSource = null;
            this.bindingSource1.ResetBindings(false);
            return true;
        }
 
        List<CurrentViewModel> allRecords = null;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="project"></param>
        /// <param name="item"></param>
        public bool IntialTestInfo(
            TProduct.Model.TestProjectItemView item)
        {
            if (item == null || item.AutoTestInfo == null) return false;
            if (!item.AutoTestInfo.IsHave)
                return false;
            allRecords = new List<CurrentViewModel>();
            foreach (var d in item.AutoTestInfo.Details)
            {
                allRecords.Add(new CurrentViewModel(d));
            }
 
            this.bindingSource1.DataSource = allRecords;
            this.bindingSource1.ResetBindings(false);
            return true;
        }
 
        //设置错误记录
        public void SetErrorRecord(double degree, string info)
        {
            var record = allRecords.Find(d => d.Degree == degree);
            if (record == null) return;
            record.CorrectPtQ = info;
            record.IsFinish = true;
            record.IsOk = false;
            this.bindingSource1.DataSource = allRecords;
            this.bindingSource1.ResetBindings(false);
            //this.gridControl1.Invoke
            //(
            //        /*表示一个委托,该委托可执行托管代码中声明为 void 且不接受任何参数的任何方法。
            //          * 在对控件的 Invoke    方法进行调用时或需要一个简单委托又不想自己定义时可以使用该委托。*/
            //        new MethodInvoker
            //            (
            //                delegate
            //                {
 
            //                }
            //            )
            // );
 
 
        }
 
        //设置正确记录
        public void SetNormalRecord(double degree, Model.PumpFeatTestRecordViewModel new_record)
        {
            var record = allRecords.Find(d => d.Degree == degree);
            if (record == null) return;
 
            record.CorrectPtQ = new_record.CorrectPtQ.ToString();
            record.CorrectPtH = new_record.CorrectPtH.ToString();
            record.CorrectPtE = new_record.CorrectPtE.ToString();
            record.CorrectPtP = new_record.CorrectPtP.ToString();
 
            record.IsFinish = true;
            record.IsOk = true;
            this.bindingSource1.DataSource = allRecords;
            this.bindingSource1.ResetBindings(false);
            //this.gridControl1.Invoke
            //(
            //        /*表示一个委托,该委托可执行托管代码中声明为 void 且不接受任何参数的任何方法。
            //          * 在对控件的 Invoke    方法进行调用时或需要一个简单委托又不想自己定义时可以使用该委托。*/
            //        new MethodInvoker
            //            (
            //                delegate
            //                {
 
            //                }
            //            )
            // );
        }
 
 
        private void GridViewMain_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            if (e.Column == this.colDegree)
            {
                var model =
         this.gridViewMain.GetRow(e.RowHandle) as CurrentViewModel;
 
                if (model.IsFinish)
                {
                    if (model.IsOk)
                    {
                        e.Appearance.BackColor = System.Drawing.Color.LightBlue;
                    }
                    else
                    {
                        e.Appearance.BackColor = System.Drawing.Color.MediumVioletRed;
                    }
                }
            }
        }
    }
}