duheng
2024-07-16 30ce6c4563df5e628c8e8891d666d852bd2203d5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using HStation.Dto;
 
namespace HStation.WinFrmUI.Xhs.Core
{
    public partial class XhsProjectTreeList : DevExpress.XtraEditors.XtraUserControl
    {
        public XhsProjectTreeList()
        {
            InitializeComponent();
        }
 
        private List<XhsProjectDto> _allBindingList = null;
 
        private BLL.XhsProject _bll;
 
        public async void SetBindingData()
        {
            _bll = new BLL.XhsProject();
            var alllist = await _bll.GetAll();
            _allBindingList = alllist;
            this.treeList1.DataSource = _allBindingList;
            this.treeList1.RefreshDataSource();
        }
 
        public event Action<string> SelectProject;
 
        //双击进入项目详情事件
        private void treeList1_DoubleClick(object sender, EventArgs e)
        {
        }
 
        //聚焦切换
        private void treeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            var vm = this.treeList1.GetCurrentViewModel(_allBindingList);
            if (vm != null)
            {
                SelectProject.Invoke(vm.ID.ToString());
            }
        }
 
        //导入项目
        private void BtnImportProject_Click(object sender, EventArgs e)
        {
            var dlg = new AddXhsProjectDlg();
            dlg.ReloadEvent += async (project, item, model, map) =>
            {
                var id = await _bll.InsertEx(project, item, model, map);
                if (id > 0)
                {
                    var vmmodel = await _bll.GetByID(id);
                    _allBindingList.Add(vmmodel);
                    this.treeList1.RefreshDataSource();
                    return true;
                }
                return false;
            };
            dlg.ShowDialog();
        }
    }
}