JLChen
2020-05-28 04bd96cbf5d12a4e4b116d2b05fd0d05ea81ee23
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
using System;
using System.Collections.Generic;
 
namespace Shared.SimpleControl.Phone
{
    /// <summary>
    /// 用户干接点状态界面,干接点不能控制,先显示状态
    /// </summary>
    public class UserDryContact
    {
        public static UserDryContact curDC;
        VerticalScrolViewLayout scenesBodyView;
        public UserDryContact ()
        {
            curDC = this;
        }
        /// <summary>
        /// 更新界面
        /// </summary>
        /// <returns>The view.</returns>
        /// <param name="subnetID">Subnet identifier.</param>
        /// <param name="deviceID">Device identifier.</param>
        /// <param name="loopID">Loop identifier.</param>
        /// <param name="status">Status.</param>
        public static void UpdataView (byte subnetID,byte deviceID,byte loopID,byte status)
        {
            if (curDC == null) {
                return;
            }
 
            for (int i = 0; i < curDC.scenesBodyView.ChildrenCount; i++) {
                if (curDC.scenesBodyView.GetChildren (i).GetType () == typeof (FrameLayout)) {
                    FrameLayout frameLayout = (FrameLayout)curDC.scenesBodyView.GetChildren (i);
                    for (int j = 0; j < frameLayout.ChildrenCount; j++) {
                        if (frameLayout.GetChildren (j).GetType () == typeof (FrameLayout)) {
                            FrameLayout frameLayout2 = (FrameLayout)frameLayout.GetChildren (j);
                            for (int k = 0; k < frameLayout2.ChildrenCount; k++) {
                                if (frameLayout2.GetChildren (k).GetType () == typeof (Button)) {
 
                                    Button btn = (Button)frameLayout2.GetChildren (k);
                                    var o = btn.GetTagByKey ("UpdataKey");
                                    if (o != null && o.ToString () == subnetID.ToString () + deviceID.ToString () + loopID.ToString ()) {
                                        Application.RunOnMainThread (() => {
                                            if (status ==0) {
                                                btn.IsSelected = true;
                                            } else {
                                                btn.IsSelected = false;
                                            }
                                        });
                                    }
                                }
                            }
 
                        }
                    }
                }
            }
        }
 
        public void ShowUserDryContact (Room roomUI = null)
        {
            //UserMiddle.VerticalScrolView_InUserMiddleView.RemoveAll ();
 
            //UserHomePage.FrameLayoutMain.Remove (UserTop.UserTopFrameLayout);
 
            //FrameLayout bodyView = new FrameLayout () {
            //    Width = LayoutParams.MatchParent,
            //    Height = LayoutParams.MatchParent,
            //};
            //UserMiddle.VerticalScrolView_InUserMiddleView.AddChidren (bodyView);
            //// topView
            //new EquipmentPublicClass ().InitUserTopView (Language.StringByID (R.MyInternationalizationString.DryContactPanel));
 
            //var listdcpUI = FindAllScenesRoom (roomUI);
            //#region bodyView
 
            //FrameLayout scenesRowView = new FrameLayout () {
            //    Width = LayoutParams.MatchParent,
            //    Height = Application.GetRealHeight (220),
            //};
 
            //VerticalScrolViewLayout scrolView = new VerticalScrolViewLayout () {
            //    Width = LayoutParams.MatchParent,
            //    Height = Application.GetRealHeight (776 + 88),
            //};
            //bodyView.AddChidren (scrolView);
 
            // scenesBodyView = new VerticalScrolViewLayout () {
            //    Width = LayoutParams.MatchParent,
            //    Height = LayoutParams.MatchParent,
            //};
            //scrolView.AddChidren (scenesBodyView);
 
            //int number = -1;
 
            //for (int i = listdcpUI.Count; i < 8; i = listdcpUI.Count) {
            //    listdcpUI.Add (new DryContact ());
            //}
            //foreach (var dcUI in listdcpUI) {
            //    number++;
            //    if (number % 2 == 0) {
            //        scenesRowView = new FrameLayout () {
            //            Width = LayoutParams.MatchParent,
            //            Height = Application.GetRealHeight (220),
            //        };
            //        scenesBodyView.AddChidren (scenesRowView);
            //    }
            //    FrameLayout sceneView = new FrameLayout () {
            //        Width = Application.GetRealWidth (322),
            //        Height = Application.GetRealHeight (220),
            //        BackgroundImagePath = "Item/ArticulatingFrameLeft1.png",
            //    };
            //    scenesRowView.AddChidren (sceneView);
            //    if (number % 2 == 1) {
            //        sceneView.Width = Application.GetRealWidth (318);
            //        sceneView.Height = Application.GetRealHeight (220);
            //        sceneView.X = Application.GetRealWidth (322);
            //        sceneView.BackgroundImagePath = "Item/ArticulatingFrameRight1.png";
            //    }
 
            //    if (null != dcUI.Name) {
            //        Button btnSceneIcon = new Button () {
            //            Width = Application.GetRealWidth (85),
            //            Height = Application.GetRealHeight (75),
            //            Gravity = Gravity.CenterHorizontal,
            //            Y = Application.GetRealHeight (70),
            //            UnSelectedImagePath = "Item/DryContact.png",
            //            SelectedImagePath = "Item/DryContactSelected.png",
            //        };
            //        sceneView.AddChidren (btnSceneIcon);
            //        btnSceneIcon.AddTag("UpdataKey", dcUI.SubnetID.ToString () + dcUI.DeviceID.ToString () + dcUI.LoopID.ToString ());
            //        Button btnSceneName = new Button () {
            //            Width = Application.GetRealWidth (300),
            //            Height = Application.GetRealHeight (45),
            //            Gravity = Gravity.CenterHorizontal,
            //            Y = Application.GetRealHeight (90) + btnSceneIcon.Height,
            //            Text = dcUI.Name,
            //        };
            //        sceneView.AddChidren (btnSceneName);
 
            //        System.Threading.Tasks.Task.Run (() => {
            //            byte [] bbb = Control.ControlBytesSendHasReturn (Command.ReadDryContactStatus, dcUI.SubnetID,
            //                                                             dcUI.DeviceID, new byte [] { 1, dcUI.LoopID });
            //            if (bbb != null) {
            //                Application.RunOnMainThread (() => {
            //                    if (bbb [2] == 0) {
            //                        btnSceneIcon.IsSelected = true;
            //                        //dcp.Status = ONorOFF.ON;
            //                    } else {
            //                        btnSceneIcon.IsSelected = false;
            //                        //dcp.Status = ONorOFF.OFF;
            //                    }
            //                });
            //            }
            //        });
            //    }
            //}
            //#endregion
 
       }
 
        List<DryContact> FindAllScenesRoom (Room roomUI)
        {
            List<DryContact> list = new List<DryContact> ();
            if (roomUI == null) {
                foreach (var tempRoomUI in Room.Lists) {
                    for (int i = 0; i < tempRoomUI.DeviceList.Count; i++) {
                        var common = tempRoomUI.DeviceList [i];
                        if (common.Type != DeviceType.DryContact) {
                            continue;
                        }
                        list.Add (common as DryContact);
                    }
                }
            } else {
                for (int i = 0; i < roomUI.DeviceList.Count; i++) {
                    var common = roomUI.DeviceList [i];
                    if (common.Type != DeviceType.DryContact) {
                        continue;
                    }
                    list.Add (common as DryContact);
                }
            }
            return list;
        }
    }
}