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;
|
}
|
}
|
}
|
}
|
}
|
}
|