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
using System;
using Shared;
using Shared.SimpleControl.R;
using Shared.SimpleControl;
using System.Collections.Generic;
 
namespace SmartHome.UI.SimpleControl.Phone
{
    public class LocalSceneListPage : FrameLayout
    {
        public void Show (Action action, List<YiPanelScene> localscenelist,YIPanel yipanel)
        {
            AddChidren (new Button {
                Height = Application.GetRealHeight (36),
                BackgroundColor = SkinStyle.Current.MusicTopFrameLayout,
            });
 
            var topFrameLayout = new FrameLayout {
                Height = Application.GetRealHeight (100),
                Y = Application.GetRealHeight (36),
                BackgroundColor = SkinStyle.Current.MusicTopFrameLayout,
            };
            AddChidren (topFrameLayout);
 
            var LocallistName = new Button {
                //Text = "本地场景",
                TextID=MyInternationalizationString.SceneList,
                TextSize = 17,
                TextColor = SkinStyle.Current.MusicTextColor,
            };
            topFrameLayout.AddChidren (LocallistName);
 
            var hdl = new Button {
                Width = Application.GetRealWidth (154),
                Height = Application.GetRealHeight (90),
                X = Application.GetRealWidth (486),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = MainPage.LogoString,
            };
            //topFrameLayout.AddChidren (hdl);
 
            var back = new Button {
                Width = Application.GetRealWidth (82),
                Height = Application.GetRealHeight (89),
                X = Application.GetRealWidth (10),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "MusicIcon/HomepageBack.png",
            };
            topFrameLayout.AddChidren (back);
            back.MouseDownEventHandler += (sender, e) => {
                RemoveFromParent ();
                scenechannelnumber (yipanel);
                action ();
            };
 
            var middle = new VerticalScrolViewLayout ();
            middle.Y = topFrameLayout.Bottom;
            middle.Height = Application.GetRealHeight (1136 - 136);
            middle.BackgroundColor = SkinStyle.Current.MusicVerticalScrolViewLayout;
            AddChidren (middle);
 
            foreach (var scene in localscenelist) {
                var sceneRowLayout = new RowLayout {
                    Height = Application.GetRealHeight (100),
                    BackgroundColor = 0xff323232,
                };
                middle.AddChidren (sceneRowLayout);
 
                var btnscene = new Button {
                    Width = Application.GetRealWidth (200),
                    Text = scene.Name,
                    TextAlignment = TextAlignment.CenterLeft,
                    X = Application.GetRealWidth (40),
                };
                sceneRowLayout.AddChidren (btnscene);
 
                var btnCheck = new Button {
                    Width = Application.GetRealWidth (60),
                    Height = Application.GetRealHeight (59),
                    Gravity = Gravity.CenterVertical,
                    X = Application.GetRealWidth (550),
                    SelectedImagePath = "Light/CheckOn.png",
                    UnSelectedImagePath = "Light/Check.png",
                };
                sceneRowLayout.AddChidren (btnCheck);
 
                if (yipanel.yIPanelSceneList.Find ((s) =>scene.Name==s.Name) != null) {
                    btnCheck.IsSelected = true;
                }
 
                EventHandler<MouseEventArgs> deviicetypeclick = (sender, e) => {
                    btnCheck.IsSelected = !btnCheck.IsSelected;
                    if (btnCheck.IsSelected) {
                        if (null == yipanel.yIPanelSceneList.Find ((s) =>scene.Name == s.Name)) {
                            yipanel.yIPanelSceneList.Add (scene);
                        }
                    } else {
                        yipanel.yIPanelSceneList.RemoveAll ((s) => scene.Name == s.Name);
                    }
                };
                sceneRowLayout.MouseUpEventHandler += deviicetypeclick;
                btnscene.MouseUpEventHandler += deviicetypeclick;
                btnCheck.MouseUpEventHandler += deviicetypeclick;
 
            }
 
 
        }
 
        void scenechannelnumber (YIPanel yipanel)
        {
 
            foreach (var scene in yipanel.yIPanelSceneList) {
                if (scene.Channelnumber == 0) {
                    for (int i = 1; i < 32; i++) {
                        var number =yipanel.yIPanelSceneList.Find ((s) => { return (s.Channelnumber != 0 && s.Channelnumber == (byte)i); });
                        if (number == null) {
                            scene.Channelnumber = (byte)i;
                            scene.LargeClass = 4;
                            break;
                        }
                    }
                }
            }
        }
    }
}