JLChen
2020-06-04 6d55af8792cf8fbef0055e677b900fc352dba9a2
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
using System;
using System.Collections.Generic;
using EZMonitor;
 
namespace Shared.SimpleControl.Phone
{
    public class MonitorAddSceneList : FrameLayout
    {
        public MonitorAddSceneList ()
        {
            BackgroundColor = SkinStyle.Current.MainColor;
        }
 
        public string SceneType;//场景类型
 
        public void showVideoMonitoring (Com.Hdl.ON.MonitorData data)
        {
            #region 标题
            var topView = new FrameLayout () {
                Height = Application.GetRealHeight (136),
            };
            AddChidren (topView);
 
            var title = new Button () {
                TextAlignment = TextAlignment.Center,
                Text = Language.StringByID (R.MyInternationalizationString.EZVIZ),
                TextSize = 19,
                TextColor = SkinStyle.Current.TextColor1,
                Y = Application.GetRealHeight (10),
            };
            topView.AddChidren (title);
 
            var back = new Button () {
                Height = Application.GetRealHeight (90),
                Width = Application.GetRealWidth (85),
                UnSelectedImagePath = "Item/Back.png",
                SelectedImagePath = "Item/BackSelected.png",
                Y = Application.GetRealHeight (30),
            };
            topView.AddChidren (back);
            back.MouseUpEventHandler += (sender, e) => {
                CommonList.Save ();
                CommonList.CameraList ();
                this.RemoveFromParent ();
            };
            #endregion
 
            #region middleVerticalScrolViewLayout
            var middleVerticalScrolViewLayout = new VerticalScrolViewLayout () {
                Height = Application.GetRealHeight (Application.DesignHeight - 126 - 98),
                Y = topView.Bottom,
                BackgroundColor = SkinStyle.Current.ViewColor,
            };
            AddChidren (middleVerticalScrolViewLayout);
 
            #region test
            //全部类型的场景列表
            var allSceneFilePaths = new List<string> ();
            //全局场景中所有的场景
            var sceneFileList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (Scene.GlobalSceneFilePath)));
            allSceneFilePaths.AddRange (sceneFileList);
 
            //房间的所有场景
            foreach (var room in Room.Lists) {
                if (room.Name == "") {
                    continue;
                }
                allSceneFilePaths.AddRange (room.SceneFilePathList);
            }
 
            foreach (var sceneFilePathsType in allSceneFilePaths) {
                var scene = Scene.GetSceneByFilePath (sceneFilePathsType);
                if (scene == null) {
                    continue;
                }
                var frameLayout = new RowLayout () {
                    Height = Application.GetRealHeight (93),
                };
                middleVerticalScrolViewLayout.AddChidren (frameLayout);
 
                var btnRemarkName = new Button () {
                    Width = Application.GetRealWidth (342),
                    Height = LayoutParams.MatchParent,
                    Text = scene.Name,
                    TextAlignment = TextAlignment.CenterLeft,
                    X = Application.GetRealWidth (40),
                };
                frameLayout.AddChidren (btnRemarkName);
 
                var Check = new Button () {
                    X = Application.GetRealWidth (540),
                    Gravity = Gravity.CenterVertical,
                    Width = Application.GetRealWidth (80),
                    Height = Application.GetRealHeight (80),
                    UnSelectedImagePath = "Item/Check.png",
                    SelectedImagePath = "Item/CheckSelected.png",
                    Tag = sceneFilePathsType
                };
                frameLayout.AddChidren (Check);
                if (CommonList.MonitorScenePathList.Count > 0) {
                    for (int i = 0; i < CommonList.MonitorScenePathList.Count; i++) {
                        var monitorData = CommonList.MonitorScenePathList [i];
                        if (monitorData.FileName == sceneFilePathsType && monitorData.Id == data.Id) {
                            Check.IsSelected = true;
                            break;
                        } else {
                            Check.IsSelected = false;
                        }
                    }
                }
                EventHandler<MouseEventArgs> hander = (sender, e) => {
                    int tempIndex = -1;
                    for (int i = 0; i < CommonList.MonitorScenePathList.Count; i++) {
                        var monitorData = CommonList.MonitorScenePathList [i];
                        if (monitorData.FileName == sceneFilePathsType && monitorData.Id == data.Id) {
                            Check.IsSelected = true;
                            tempIndex = i;
                            break;
                        }
                    }
                    if (Check.IsSelected) {
                        if (tempIndex != -1) {
                            CommonList.MonitorScenePathList.RemoveAt (tempIndex);
                        }
                        Check.IsSelected = false;
                    } else {
                        if (tempIndex == -1) {
                            if (sceneFilePathsType.Contains ("RoomLightScene")) {
                                SceneType = "房间灯光场景";
                            } else if (sceneFilePathsType.Contains ("GlobalScene")) {
                                SceneType = "全局场景";
                            } else {
                                SceneType = "房间场景";
                            }
                            CommonList.MonitorScenePathList.Add (new Com.Hdl.ON.MonitorData { Remark = scene.Name, ControlType = SceneType, FileName = sceneFilePathsType, Type = data.Type, Id = data.Id });
                        }
                        Check.IsSelected = true;
                    }
                };
                frameLayout.MouseDownEventHandler += hander;
                btnRemarkName.MouseUpEventHandler += hander;
                Check.MouseUpEventHandler += hander;
            }
            #endregion
            #endregion
 
            #region bottomFrameLayout
            var bottomFrameLayout = new FrameLayout () {
                Height = Application.GetRealHeight (98),
                Y = Application.GetRealHeight (Application.DesignHeight - 98),
            };
            AddChidren (bottomFrameLayout);
 
            var btnSave = new Button () {
                Height = Application.GetRealHeight (97),
                TextID = R.MyInternationalizationString.SAVE,
                TextSize = 15,
                BackgroundColor = SkinStyle.Current.TitileView,
            };
            bottomFrameLayout.AddChidren (btnSave);
            btnSave.MouseUpEventHandler += (sender, e) => {
                CommonList.Save ();
                CommonList.CameraList ();
                this.RemoveFromParent ();
            };
            #endregion
        }
    }
}