using DevExpress.XtraEditors;
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Linq;
|
|
namespace IStation.WinFrmUI.Monitor
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public partial class BoxSelectPointsDlg : XtraForm
|
{
|
public BoxSelectPointsDlg()
|
{
|
InitializeComponent();
|
this.gridView1.SetNormalView();
|
this.gridView1.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Default;
|
}
|
|
public event Func<DateTime, bool> RemovePointEvent;
|
public event Func<List<Model.CurveAnalyzePoint>, bool> ReloadDataEvent;
|
private BindingList<Model.CurveAnalyzePoint> _bindingList = null;
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void Set(List<Model.CurveAnalyzePoint> checkPoints)
|
{
|
if (checkPoints != null && checkPoints.Any())
|
{
|
checkPoints.ForEach(x => x.Round());
|
_bindingList = new BindingList<Model.CurveAnalyzePoint>(checkPoints);
|
}
|
else
|
{
|
_bindingList = new BindingList<Model.CurveAnalyzePoint>();
|
}
|
|
|
this.curveAnalyzePointBindingSource.DataSource = _bindingList;
|
this.curveAnalyzePointBindingSource.ResetBindings(false);
|
this.gridView1.BestFitColumns();
|
}
|
|
//验证
|
public bool Valid()
|
{
|
this.gridView1.CloseEditor();
|
this.gridView1.UpdateCurrentRow();
|
if (_bindingList.Count > 0)
|
{
|
for (int i = 0; i < _bindingList.Count; i++)
|
{
|
var vm = _bindingList[i];
|
if (string.IsNullOrEmpty(vm.HZ.ToString()))
|
{
|
this.gridView1.FocusedRowHandle = i;
|
this.gridView1.SetColumnError(this.colHz, "必填项");
|
return false;
|
}
|
|
if (string.IsNullOrEmpty(vm.Q.ToString()))
|
{
|
this.gridView1.FocusedRowHandle = i;
|
this.gridView1.SetColumnError(this.colHz, "必填项");
|
return false;
|
}
|
|
}
|
}
|
return true;
|
}
|
|
#region GridView
|
|
//删除
|
private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
|
{
|
if (_bindingList == null || _bindingList.Count < 1)
|
return;
|
if (e.Column == this.colDelete)
|
{
|
var row = this.gridView1.GetFocusedRow() as Model.CurveAnalyzePoint;
|
if (row == null)
|
return;
|
if (this.RemovePointEvent != null)
|
{
|
var bol = this.RemovePointEvent(row.Time);
|
if (bol)
|
{
|
_bindingList.Remove(row);
|
}
|
}
|
}
|
}
|
|
|
#endregion
|
|
|
}
|
}
|