using DevExpress.XtraBars.Docking2010.DragEngine; using DevExpress.XtraEditors; using HStation.WinFrmUI.Xhs.Project; using ISupply.WinFrmUI; using Yw.Basic; namespace HStation.WinFrmUI.Xhs { /// /// /// public partial class TypeTreeListCtrl : XtraUserControl { public TypeTreeListCtrl() { InitializeComponent(); this.treeList1.InitialDefaultSettings(); } /// /// 聚焦改变事件 /// public event Action FocusedChangedEvent; private List _allBindingList = null; private Yw.BLL.SysTypeStd _bll = null; private Yw.BLL.SysModule _Modulebll = null; /// /// 绑定数据 /// public void Clear() { this.FocusedChangedEvent?.Invoke(default); } /// /// 绑定数据 /// public async void SetBindingData() { _allBindingList = new List(); _bll = new Yw.BLL.SysTypeStd(); var alllist = await _bll.GetLogicalTreeListByExtendType(eExtendType.Catalog); foreach (var item in alllist) { var module = new TypeTreeListViewModel(item); _allBindingList.Add(module); foreach (var child in item.Children) { var children = new TypeTreeListViewModel(child); _allBindingList.Add(children); } } this.moduleViewModelBindingSource.DataSource = _allBindingList; this.moduleViewModelBindingSource.ResetBindings(false); } //聚焦改变 private void treeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) { var currentVm = this.treeList1.GetCurrentViewModel(_allBindingList); if (currentVm == null) { MessageBoxHelper.ShowWarning("请选择数据行!"); return; } FocusedChangedEvent.Invoke(currentVm.ID); } #region 菜单事件 //检索 private void barCkSearch_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (this.barCkSearch.Checked) this.treeList1.ShowFindPanel(); else this.treeList1.HideFindPanel(); } #endregion 菜单事件 //获取当前选中id public long GetCurrentID() { var currentVm = this.treeList1.GetCurrentViewModel(_allBindingList); if (currentVm == null) { MessageBoxHelper.ShowWarning("请选择数据行!"); return default; } return currentVm.ID; } //全部折叠 private void barBtnCollapseAll_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { this.treeList1.CollapseAll(); } //全部展开 private void barBtnExpandAll_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { this.treeList1.ExpandAll(); } } }