using DevExpress.Utils.Extensions;
|
|
namespace Yw.WinFrmUI
|
{
|
public partial class SelectHydroGradingPropTreeCtrl : DevExpress.XtraEditors.XtraUserControl
|
{
|
public SelectHydroGradingPropTreeCtrl()
|
{
|
InitializeComponent();
|
this.simpleTreeViewCtrl1.ToolBarVisible = false;
|
this.simpleTreeViewCtrl1.CloseSearchControl();
|
this.simpleTreeViewCtrl1.ShowTreeLines = true;
|
this.simpleTreeViewCtrl1.FocusedChangedEvent += SimpleTreeViewCtrl1_FocusedChangedEvent;
|
}
|
|
|
/// <summary>
|
/// 选择属性改变事件
|
/// </summary>
|
public event Action<HydroGradingPropTreeViewModel> SelectedPropChangedEvent;
|
|
private Yw.Model.HydroModelInfo _hydro = null;//水力信息
|
private List<HydroGradingPropTreeViewModel> _allBindingList = null;//所有绑定列表
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(Yw.Model.HydroModelInfo hydro)
|
{
|
if (hydro == null)
|
{
|
return;
|
}
|
_hydro = hydro;
|
_allBindingList = new List<HydroGradingPropTreeViewModel>();
|
var catalogDict = HydroGradingCatalogHelper.GetDict(hydro);
|
catalogDict?.ForEach(x =>
|
{
|
_allBindingList.Add(new HydroGradingPropTreeViewModel(x.Key, x.Value));
|
var propDict = HydroGradingPropHelper.GetNameDict(x.Key);
|
propDict?.ForEach(t =>
|
{
|
_allBindingList.Add(new HydroGradingPropTreeViewModel(x.Key, t.Key, t.Value));
|
});
|
});
|
|
var allTreeList = new List<SimpleTreeViewModel>();
|
_allBindingList.ForEach(x =>
|
{
|
var treeModel = new SimpleTreeViewModel()
|
{
|
Id = x.Id,
|
ParentId = x.ParentId,
|
Name = x.Name,
|
Tag = x
|
};
|
allTreeList.Add(treeModel);
|
});
|
|
this.simpleTreeViewCtrl1.SetBindingData(allTreeList);
|
this.simpleTreeViewCtrl1.ExpandAll();
|
}
|
|
//聚焦节点改变
|
private void SimpleTreeViewCtrl1_FocusedChangedEvent(SimpleTreeViewModel obj)
|
{
|
var vm = obj?.Tag as HydroGradingPropTreeViewModel;
|
this.SelectedPropChangedEvent?.Invoke(vm);
|
}
|
|
|
|
}
|
}
|