wjc
2023-03-30 cae4d4b5b508a666fbd0dff3c2a981fdff841bc8
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
using System;
using System.Collections.Generic;
using HDL_ON.DAL.Server;
using HDL_ON.Entity;
using HDL_ON.UI.CSS;
using Shared;
 
namespace HDL_ON.UI
{
    public class CombinedDimmingListPage : FrameLayout
    {
        FrameLayout bodyView;
        VerticalScrolViewLayout contentView;
 
        public CombinedDimmingListPage()
        {
            bodyView = this;
        }
 
        public void LoadPage()
        {
 
            new TopViewDiv(bodyView, Language.StringByID(StringId.CombinedDimming)).LoadTopView_AddIcon("CombinedDimming",
                (s,c)=>{
                    try
                    {
                        var page = new AddGroupControlPage(new System.Collections.Generic.List<Function>(),new GroupControl(),
                            ()=> {
 
                            });
                        MainPage.BasePageView.AddChidren(page);
                        page.LoadPage();
                        MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                    }
                    catch { }
                });
 
            contentView = new VerticalScrolViewLayout()
            {
                Y = Application.GetRealHeight(64),
                Height = Application.GetRealHeight(550),
                BackgroundColor = CSS_Color.MainBackgroundColor,
            };
            bodyView.AddChidren(contentView);
 
 
            new System.Threading.Thread(() => {
                var http = new HttpServerRequest();
                var pack = http.GetGroupControlList();
                if(pack != null)
                {
                    if(pack.Code == StateCode.SUCCESS  )
                    {
                        try
                        {
                            var groupControlList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<GroupControl>>(pack.Data.ToString());
                            LoadGroupControlView(groupControlList);
                        }
                        catch (Exception ex)
                        {
                            MainPage.Log($"读取组控列表失败:{ex.Message}");
                        }
                    }
                    else
                    {
                        IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
                    }
                }
 
            }) { IsBackground = true }.Start();
 
            #region 
            contentView.AddChidren(new Button() { Height = Application.GetRealHeight(8) });
 
            
 
            #endregion
 
        }
 
 
        private void LoadGroupControlView(List<GroupControl> list)
        {
            if(list.Count == 0)
            {
 
            }
            else
            {
                contentView.RemoveAll();
 
                foreach (var function in list)
                {
                    var functionRow = new FrameLayout()
                    {
                        Height = Application.GetRealHeight(65),
                        BackgroundColor = CSS_Color.MainBackgroundColor,
                    };
                    contentView.AddChidren(functionRow);
 
                    var btnFunctionName = new Button()
                    {
                        X = Application.GetRealWidth(16),
                        Y = Application.GetRealHeight(10),
                        Width = Application.GetRealWidth(308),
                        Height = Application.GetRealHeight(24),
                        TextAlignment = TextAlignment.CenterLeft,
                        TextSize = CSS_FontSize.SubheadingFontSize,
                        TextColor = CSS_Color.FirstLevelTitleColor,
                        Text = function.name,
                    };
                    functionRow.AddChidren(btnFunctionName);
 
                    var btnFunctionLocationInfo = new Button()
                    {
                        X = Application.GetRealWidth(16),
                        Y = btnFunctionName.Bottom,
                        Width = Application.GetRealWidth(308),
                        Height = Application.GetRealHeight(21),
                        TextAlignment = TextAlignment.CenterLeft,
                        TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                        TextColor = CSS_Color.PromptingColor1,
                        Text = function.GetRoomListName(),
                    };
                    functionRow.AddChidren(btnFunctionLocationInfo);
 
 
 
                    functionRow.AddChidren(
                        new Button()
                        {
                            Gravity = Gravity.CenterHorizontal,
                            Y = Application.GetRealHeight(64),
                            Height = Application.GetRealHeight(1),
                            Width = Application.GetRealWidth(343),
                            BackgroundColor = CSS_Color.DividingLineColor,
                        });
 
                }
 
            }
        }
 
 
    }
}