using DevExpress.XtraEditors;
|
using IStation.Untity;
|
using System;
|
using System.ComponentModel;
|
using System.Linq;
|
|
namespace IStation.WinFrmUI.Basic
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public partial class MonitorPointListMgrCtrl : XtraUserControl
|
{
|
public MonitorPointListMgrCtrl()
|
{
|
InitializeComponent();
|
this.treeList1.InitialMultiColSettings();
|
this.treeList1.SelectImageList = ImageLib.Lib;
|
this.layoutControl1.SetupLayoutControl();
|
}
|
|
public class CurrentViewModel : Model.MonitorPointExSignalExSignalType
|
{
|
public CurrentViewModel() { }
|
|
public CurrentViewModel(Model.MonitorPointExSignalExSignalType rhs) : base(rhs)
|
{
|
this.FlagsList = FlagsHelper.ToString(rhs.Flags);
|
this.ImageIndex = ImageLib.MonitorPoint;
|
}
|
public string FlagsList { get; set; }
|
public int ImageIndex { get; set; }
|
}
|
|
/// <summary>
|
/// 聚焦改变事件
|
/// </summary>
|
public event Action<Model.MonitorPointExSignalExSignalType> FocusedChangedEvent;
|
|
private BindingList<CurrentViewModel> _allBindingList = null;//所有绑定列表
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void Clear()
|
{
|
_allBindingList = new BindingList<CurrentViewModel>();
|
this.currentViewModelBindingSource.DataSource = _allBindingList;
|
this.FocusedChangedEvent?.Invoke(null);
|
}
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData()
|
{
|
WaitFrmHelper.ShowWaitForm("正在加载数据...");
|
_allBindingList = new BindingList<CurrentViewModel>();
|
|
var monitorPointExSignalExSignalTypes = new BLL.MonitorPoint().GetAllExSignalExSignalType();
|
|
|
if (monitorPointExSignalExSignalTypes != null && monitorPointExSignalExSignalTypes.Any())
|
{
|
foreach (var item in monitorPointExSignalExSignalTypes)
|
{
|
var vm = new CurrentViewModel(item);
|
_allBindingList.Add(vm);
|
}
|
}
|
|
this.currentViewModelBindingSource.DataSource = _allBindingList;
|
this.treeList1.BestFitColumns();
|
this.treeList1.FocusedNode = this.treeList1.Nodes.FirstOrDefault();
|
WaitFrmHelper.HideWaitForm();
|
}
|
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(string mappingType, long mappingId)
|
{
|
WaitFrmHelper.ShowWaitForm("正在加载数据...");
|
_allBindingList = new BindingList<CurrentViewModel>();
|
|
var monitorPointExSignalExSignalTypes = new BLL.MonitorPoint().GetExSignalExSignalTypeByMappingTypeAndMappingID(mappingType, mappingId);
|
if (monitorPointExSignalExSignalTypes != null && monitorPointExSignalExSignalTypes.Any())
|
{
|
foreach (var item in monitorPointExSignalExSignalTypes)
|
{
|
var vm = new CurrentViewModel(item);
|
_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);
|
}
|
|
|
}
|
|
}
|