using DevExpress.XtraEditors;
using System;
using System.ComponentModel;
using System.Linq;
namespace IStation.WinFrmUI.Basic
{
///
///
///
public partial class PumpMgrListCtrl : XtraUserControl
{
public PumpMgrListCtrl()
{
InitializeComponent();
this.treeList1.InitialMultiColSettings();
this.treeList1.SelectImageList = ImageLib.Lib;
this.layoutControl1.SetupLayoutControl();
}
public class CurrentViewModel : Model.Product
{
public CurrentViewModel() { }
public CurrentViewModel(Model.Product rhs) : base(rhs)
{
if (rhs.RatedParas != null)
{
this.Qr = rhs.RatedParas.Qr;
this.Hr = rhs.RatedParas.Hr;
this.Nr = rhs.RatedParas.Nr;
this.Pr = rhs.RatedParas.Pr;
this.Er = rhs.RatedParas.Er;
this.NPSHr = rhs.RatedParas.NPSHr;
this.StNumr = rhs.RatedParas.StNumr;
this.Ic = rhs.RatedParas.Ic;
this.Oc = rhs.RatedParas.Oc;
this.IOd = rhs.RatedParas.IOd;
this.IsBp = rhs.RatedParas.IsBp ? "是" : "否";
this.IsSxp = rhs.RatedParas.IsSxp ? "是" : "否";
}
}
public double Qr { get; set; }
public double Hr { get; set; }
public double Nr { get; set; }
public double Pr { get; set; }
public double Er { get; set; }
public double NPSHr { get; set; }
public int StNumr { get; set; }
public double? Ic { get; set; }
public double? Oc { get; set; }
public double? IOd { get; set; }
public string IsBp { get; set; }
public string IsSxp { get; set; }
public int ImageIndex { get; set; } = ImageLib.Pump;
}
///
/// 聚焦改变事件
///
public event Action> FocusedChangedEvent;
private BindingList _allBindingList = null;//所有绑定列表
///
/// 绑定数据
///
public void Clear()
{
_allBindingList = new BindingList();
this.currentViewModelBindingSource.DataSource = _allBindingList;
this.FocusedChangedEvent?.Invoke(null);
}
///
/// 绑定数据
///
public void SetBindingData()
{
WaitFrmHelper.ShowWaitForm("正在加载数据...");
_allBindingList = new BindingList();
var pumps = new BLL.Product().GetAllPump();
if (pumps != null && pumps.Any())
{
foreach (var pump in pumps)
{
var vm = new CurrentViewModel(pump);
_allBindingList.Add(vm);
}
}
this.currentViewModelBindingSource.DataSource = _allBindingList;
this.treeList1.BestFitColumns();
this.treeList1.FocusedNode = this.treeList1.Nodes.FirstOrDefault();
WaitFrmHelper.HideWaitForm();
}
//聚焦改变
private void treeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
{
var vm = this.treeList1.GetCurrentViewModel(_allBindingList);
if (vm == null)
return;
this.FocusedChangedEvent?.Invoke(vm);
}
}
}