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;
}
///
/// 选择属性改变事件
///
public event Action SelectedPropChangedEvent;
//所有绑定列表
private List _allBindingList = null;
///
/// 初始化数据
///
public void InitialData()
{
_allBindingList = new List();
var dictCatalogList = HydroParterCatalogHelper.GetSimpleDict();
dictCatalogList.ForEach(x =>
{
_allBindingList.Add(new HydroGradingPropTreeViewModel(x.Key, x.Value));
var dictPropList = HydroParterPropHelper.GetDict(x.Key);
dictPropList.ForEach(t =>
{
_allBindingList.Add(new HydroGradingPropTreeViewModel(x.Key, t.Key, t.Value));
});
});
var allTreeList = new List();
_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);
}
}
}