duheng
2024-08-14 71ff3ccde064c104db61fa28300b039456c0ba06
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
using DevExpress.Utils.Svg;
 
namespace HStation.WinFrmUI
{
    public partial class HomeXhsProjectPage : DocumentPage
    {
        public HomeXhsProjectPage()
        {
            InitializeComponent();
            this.PageTitle.Caption = "首页";
            this.PageTitle.HeaderSvgImage = this.svgImg32[0];
            this.PageTitle.SvgImageSize = new Size(24, 24);
            this.PageTitle.AllowClose = false;
 
            this.repPicEdit.SizeMode = DevExpress.XtraEditors.Controls.PictureSizeMode.Zoom;
        }
 
        //页面类
        private class CurrentViewModel
        {
            public string Name { get; set; }
            public int Count { get; set; }
            public SvgImage Image { get; set; }
        }
 
 
        private Lazy<BLL.XhsProjectStd> _bllProjectStd = new(() => new BLL.XhsProjectStd());
        private List<XhsProjectStdDto> _allProjectList = null;
 
        /// <summary>
        /// 初始化数据源
        /// </summary>
        public override async void InitialDataSource()
        {
            _allProjectList = await _bllProjectStd.Value.GetAll();
 
            var vm = new CurrentViewModel()
            {
                Name = "项目数量",
                Count = _allProjectList?.Count ?? 0,
                Image =  ImageLib.Project
            };
        
 
            var vm2 = new CurrentViewModel()
            {
                Name = "水泵型号数量",
                Count = 999,
                Image = ImageLib.PumpMain
 
            };
             
            var vm3 = new CurrentViewModel()
            {
                Name = "阀门型号数量",
                Count = 666,
                Image = ImageLib.Valve
            };
 
            var list = new List<CurrentViewModel>() { vm, vm2, vm3 };
            this.gridControl1.DataSource = list;
            this.gridControl1.RefreshDataSource();
 
 
            this.mapViewProjectListContainer1.LoadCompletedEvent += MapViewProjectListContainer1_LoadCompletedEvent;
            await this.mapViewProjectListContainer1.InitialContainer();
        }
 
        /// <summary>
        /// 刷新数据
        /// </summary>
        public override async void RefreshData()
        {
            base.RefreshData();
            _allProjectList = await _bllProjectStd.Value.GetAll();
            await this.mapViewProjectListContainer1.SetProjectList(_allProjectList);
            this.homeXhsProjectTreeListCtrl1.SetBindingData(_allProjectList);
        }
 
        //地图加载完成
        private async void MapViewProjectListContainer1_LoadCompletedEvent()
        {
            await this.mapViewProjectListContainer1.SetProjectList(_allProjectList);
            this.homeXhsProjectTreeListCtrl1.SetBindingData(_allProjectList);
        }
 
        //选择项目事件
        private async void homeXhsProjectTreeListCtrl1_SelectProjectEvent(XhsProjectStdDto obj)
        {
            await this.mapViewProjectListContainer1.SelectProject(obj.ID);
            var vm = new HomeXhsProjectPropertyViewModel(obj);
            this.homeXhsProjectPropertyCtrl1.SelectedObject = vm;
        }
 
        //导入完成事件
        private void homeXhsProjectTreeListCtrl1_ImportProjectCompletedEvent(ImportXhsProjectViewModel obj)
        {
            RefreshData();
        }
 
        //跳转事件
        private async void homeXhsProjectPropertyCtrl1_JumpDirectEvent(XhsProjectStdDto obj)
        {
            var guid = new PageGuid()
            {
                Modular = Yw.WinFrmUI.PageModular.Bimface,
                MoudingType = Yw.WinFrmUI.Page.eMoudingType.Tab,
                Function = Yw.WinFrmUI.PageFunction.ViewBimface3d,
                TagName = $"{obj.ID}"
            };
 
            if (!IsExistPage(guid, true))
            {
                var page = new XhsSchemeMultiMgrPage();
                await page.SetBindingData(obj.ID);
                //var page = new XhsProjectSimulationMgrPage();
                CreatePage(page, guid);
            }
 
 
        }
 
        //刷新数据事件
        private void homeXhsProjectTreeListCtrl1_RefreshDataEvent()
        {
            RefreshData();
        }
         
    }
}