HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2019-11-04 c7698e163e43cea9e7f8ee45f8e3f91c9265cca4
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using Shared;
using Shared.Common;
using Shared.Phone;
using Shared.R;
using ZigBee.Device;
 
 
namespace Shared.Phone.Device.Logic
{
    public class LogicListPage : FrameLayout
    {
        public LogicListPage ()
        {
            Tag = "Logic";
        }
        Button beforeClickButton = new Button ();
        Common.Logic logicIfon = null;
        public void Show ()
        {
 
            this.BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor;
            this.AddChidren (new Button {
                Height = Application.GetRealHeight (80),
            });
 
            var topFrameLayout = new FrameLayout {
                Height = Application.GetRealHeight (180),
                Y = Application.GetRealHeight (80),
            };
            AddChidren (topFrameLayout);
 
            var titleName = new Button {
                TextID = MyInternationalizationString.automation,
                TextSize = 16,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
            };
            topFrameLayout.AddChidren (titleName);
 
            var back = new Button {
                Width = Application.GetRealWidth (110),
                Height = Application.GetRealHeight (110),
                X = Application.GetRealWidth (20),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "ZigeeLogic/Back.png",
            };
            topFrameLayout.AddChidren (back);
            back.MouseDownEventHandler += (sender, e) => {
                RemoveFromParent ();
            };
 
            var searchdevice = new Button {
                Width = Application.GetMinRealAverage (100),
                Height = Application.GetMinRealAverage (100),
                X = Application.GetRealWidth (1080-140),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "ZigeeLogic/seekdevice.png",
            };
            topFrameLayout.AddChidren (searchdevice);
           
            var middle = new VerticalScrolViewLayout ();
            middle.Y = topFrameLayout.Bottom;
            middle.Height = Application.GetRealHeight (1920 - 220 - 174);
            middle.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
            this.AddChidren (middle);
 
            var btncomplete = new Button {
                Y = middle.Bottom,
                Height = Application.GetRealHeight (174),
                TextID = MyInternationalizationString.complete,
                TextSize=16,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
            };
            AddChidren (btncomplete);
 
            ///加载逻辑界面的方法
            refreshlogicView(middle);
 
            ///逻辑刷新图标的点击事件
            searchdevice.MouseUpEventHandler += (sender, e) => {
                middle.RemoveAll();
                logicIfon = null;
                ///读取逻辑
                //refreshlogiclist(() => {
                //    ///加载逻辑界面的方法
                //    refreshlogicView(middle);
                //});
 
            };
 
            ///保存控件的点击事件
            btncomplete.MouseUpEventHandler += (sedder, e) => {
                if (Shared.Common.Logic.LogicList.Count == 0||logicIfon==null) {
                    var alert = new Alert (Language.StringByID (MyInternationalizationString.Prompt),
                    Language.StringByID (MyInternationalizationString.selectlogic),
                                           Language.StringByID (MyInternationalizationString.complete));
                    alert.Show ();
                    return;
                }
 
                var selectedLogicState = new SelectedLogicState ();
                UserView.HomePage.Instance.AddChidren (selectedLogicState);
                UserView.HomePage.Instance.PageIndex += 1;
                selectedLogicState.Show (logicIfon);
            };
 
        }
      
        /// <summary>
        /// 加载逻辑界面的方法
        /// </summary>
        /// <param name="middle">Middle.</param>
        /// <param name="logicIfon">Logic ifon.</param>
        void refreshlogicView (VerticalScrolViewLayout middle ) 
        {
            foreach (var logic in Shared.Common.Logic.LogicList) {
                var deviceRowLayout = new RowLayout {
                    Height = Application.GetRealHeight (180),
                };
                middle.AddChidren (deviceRowLayout);
 
                var btn = new Button {
                    Height = Application.GetRealHeight (180),
                    Width = LayoutParams.MatchParent,
                    SelectedBackgroundColor = 0xfffe5e00,
                };
                deviceRowLayout.AddChidren (btn);
 
                var btnlogic = new Button {
                    Width = Application.GetRealWidth (600),
                    Text = logic.LogicName,
                    TextAlignment = TextAlignment.CenterLeft,
                    X = Application.GetRealWidth (40),
                    TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                };
                deviceRowLayout.AddChidren (btnlogic);
 
                var btnlogicback = new Button {
                    Width = Application.GetRealWidth (110),
                    Height = Application.GetRealHeight (110),
                    UnSelectedImagePath = "ZigeeLogic/next.png",
                    SelectedImagePath = "ZigeeLogic/NextSelecte.png",
                    X = Application.GetRealWidth (1080-140),
                    Gravity=Gravity.CenterVertical,
                };
                deviceRowLayout.AddChidren (btnlogicback);
 
                EventHandler<MouseEventArgs> logicclick = (sender, e) => {
                    logicIfon = logic;
                    beforeClickButton.IsSelected = false;
                    beforeClickButton = btn;
                    btn.IsSelected = true;
                };
                btnlogic.MouseUpEventHandler += logicclick;
                deviceRowLayout.MouseUpEventHandler += logicclick;
                btnlogicback.MouseUpEventHandler += logicclick;
                btn.MouseUpEventHandler += logicclick;
            }
 
        }
    }
}