HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2019-10-12 c6b35c3138b944830b5336bf610f918154dd47c7
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
using System;
using System.Collections.Generic;
using System.Text;
using ZigBee.Device;
 
namespace Shared.Phone.UserCenter.Safety
{
    /// <summary>
    /// 开关类的安防报警设置界面
    /// </summary>
    public class SwitchAlarmSettionForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 画面关闭事件
        /// </summary>
        public Action<string, List<Safeguard.TaskListInfo>> ActionFormClose = null;
        /// <summary>
        /// 动作信息  0关闭/ 1打开
        /// </summary>
        private Dictionary<int, Safeguard.TaskListInfo> dicTaskinfo = new Dictionary<int, Safeguard.TaskListInfo>();
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="device"></param>
        /// <param name="i_listTaskInfo"></param>
        public void ShowForm(CommonDevice device, List<Safeguard.TaskListInfo> i_listTaskInfo)
        {
            if (i_listTaskInfo != null)
            {
                foreach (var data in i_listTaskInfo)
                {
                    //以防万一,剔除不合法数据
                    if (data.TaskType == 1)
                    {
                        dicTaskinfo[data.Data1] = data;
                    }
                }
            }
 
            //设置头部信息
            base.SetTitleText(Common.LocalDevice.Current.GetDeviceEpointName(device));
 
            //初始化中部信息
            this.InitMiddleFrame();
        }
 
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private void InitMiddleFrame()
        {
            //清空bodyFrame
            this.ClearBodyFrame();
 
            var frameTemp = new FrameLayout();
            frameTemp.Height = Application.GetRealHeight(6);
            frameTemp.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(frameTemp);
 
            var listView = new VerticalListControl(29);
            listView.Y = frameTemp.Bottom;
            listView.BackgroundColor = UserCenterColor.Current.White;
            listView.Height = Application.GetRealHeight(341);
            bodyFrameLayout.AddChidren(listView);
 
            //开
            var btnOpenRow = new FrameRowControl(listView.rowSpace / 2);
            listView.AddChidren(btnOpenRow);
            //图标
            var btnOpenIcon = btnOpenRow.AddLeftIcon(81);
            btnOpenIcon.UnSelectedImagePath = "Item/OpenIcon.png";
            //文字
            var btnOpenView = btnOpenRow.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uSimpleOpen), 400);
            btnOpenView.TextSize = 15;
            //状态
            var btnOpenStatu = btnOpenRow.AddMostRightEmptyIcon(58, 58);
            if (dicTaskinfo.ContainsKey(1) == false)
            {
                btnOpenStatu.Visible = false;
            }
            btnOpenStatu.UnSelectedImagePath = "Item/ItemSelected.png";
            //底线
            btnOpenRow.AddBottomLine();
 
            //关
            var btnCloseRow = new FrameRowControl(listView.rowSpace / 2);
            listView.AddChidren(btnCloseRow);
            //图标
            var btnCloseIcon = btnCloseRow.AddLeftIcon(81);
            btnCloseIcon.UnSelectedImagePath = "Item/CloseIcon.png";
            //文字
            var btnCloseView = btnCloseRow.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uSimpleClose), 400);
            btnCloseView.TextSize = 15;
            //状态
            var btnCloseStatu = btnCloseRow.AddMostRightEmptyIcon(58, 58);
            if (dicTaskinfo.ContainsKey(0) == false)
            {
                btnCloseStatu.Visible = false;
            }
            btnCloseStatu.UnSelectedImagePath = "Item/ItemSelected.png";
 
            //开
            btnOpenRow.ButtonClickEvent += (sender, e) =>
            {
                if (btnOpenStatu.Visible == true)
                {
                    //取消
                    dicTaskinfo.Remove(1);
                    btnOpenStatu.Visible = false;
                }
                else
                {
                    //添加
                    btnOpenStatu.Visible = true;
                    btnCloseStatu.Visible = false;
                    //移除关闭
                    dicTaskinfo.Remove(0);
 
                    dicTaskinfo[1] = new Safeguard.TaskListInfo();
                    dicTaskinfo[1].TaskType = 1;
                    dicTaskinfo[1].Data1 = 1;
                }
            };
            //关
            btnCloseRow.ButtonClickEvent += (sender, e) =>
            {
                if (btnCloseStatu.Visible == true)
                {
                    //取消
                    dicTaskinfo.Remove(0);
                    btnCloseStatu.Visible = false;
                }
                else
                {
                    //添加
                    btnOpenStatu.Visible = false;
                    btnCloseStatu.Visible = true;
                    //移除打开
                    dicTaskinfo.Remove(1);
 
                    dicTaskinfo[0] = new Safeguard.TaskListInfo();
                    dicTaskinfo[0].TaskType = 1;
                    dicTaskinfo[0].Data1 = 0;
                }
            };
 
            //完成
            var btnFinish = new BottomClickButton();
            btnFinish.TextID = R.MyInternationalizationString.uFinish;
            bodyFrameLayout.AddChidren(btnFinish);
            btnFinish.ButtonClickEvent += (sender, e) =>
            {
                if (this.ActionFormClose != null)
                {
                    var listData = new List<Safeguard.TaskListInfo>();
                    foreach (var data in dicTaskinfo.Values)
                    {
                        listData.Add(data);
                    }
                    dicTaskinfo = null;
 
                    //获取状态的显示文本
                    string statuText = HdlSafeguardLogic.Current.GetLightAlarmStatuText(listData);
                    this.ActionFormClose(statuText, listData);
                }
                this.CloseForm();
            };
        }
 
        #endregion
 
        #region ■ 界面关闭___________________________
 
        /// <summary>
        /// 界面关闭
        /// </summary>
        public override void CloseForm()
        {
            ActionFormClose = null;
            base.CloseForm();
        }
 
        #endregion
    }
}