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
using System;
using SmartHome;
using Shared;
using Shared.SimpleControl.R;
using Shared.SimpleControl;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
 
namespace SuperGateWay
{
    public class DeviceStateTpye : FrameLayout
    {
        public DeviceStateTpye () {
            Tag = "Logic";
        }
 
        public void Show (List<DeviceType> deviceTypelist, string name, GateWay superGateWay)
        {
            this.BackgroundColor = 0xFF1F1F1F;
            this.AddChidren (new Button {
                Height = Application.GetRealHeight (30),
            });
 
            var topFrameLayout = new FrameLayout {
                Height = Application.GetRealHeight (100),
                Y = Application.GetRealHeight (30),
            };
            AddChidren (topFrameLayout);
 
            var titleName = new Button {
                //TextID = MyInternationalizationString.devicestate,
                TextSize = 17,
                Text = Language.StringByID (MyInternationalizationString.selects) + name,
            };
            topFrameLayout.AddChidren (titleName);
 
            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 ();
            };
 
            var tetleframeLayout = new FrameLayout {
                Y = topFrameLayout.Bottom,
                Height = Application.GetRealHeight (100),
            };
            //AddChidren (tetleframeLayout);
 
            var tetlebtn = new Button {
                //TextID = MyInternationalizationString.selects,
                Text = Language.StringByID (MyInternationalizationString.selects) + name,
                TextSize = 16,
                TextAlignment = TextAlignment.CenterLeft,
                X = Application.GetRealWidth (40),
            };
            tetleframeLayout.AddChidren (tetlebtn);
 
 
            var middle = new VerticalScrolViewLayout ();
            middle.Y = topFrameLayout.Bottom;
            middle.Height = Application.GetRealHeight (Application.DesignHeight - 130);
            middle.BackgroundColor = 0xff323232;
            this.AddChidren (middle);
 
 
            foreach (var common in superGateWay.Commons) {
                if (deviceTypelist.Count != 0 && !deviceTypelist.Contains (common.Type)) {
                    continue;
                }
 
                var row = new RowLayout {
                    Height = Application.GetRealHeight (100),
                    BackgroundColor = 0xff323232,
                };
                middle.AddChidren (row);
 
                var devicename = new Button {
                    Gravity = Gravity.CenterVertical,
                    TextAlignment = TextAlignment.CenterLeft,
                    X = Application.GetRealWidth (40),
                    Width = Application.GetRealWidth (300),
                    //SelectedBackgroundColor = 0xFFE9652D,
                    Text = common.Name,
                };
                row.AddChidren (devicename);
 
                var btndeviceback = new Button {
                    Width = Application.GetRealWidth (87),
                    Height = Application.GetRealHeight (100),
                    UnSelectedImagePath = "MusicIcon/Next.png",
                    SelectedImagePath = "MusicIcon/NextSelecte.png",
                    X = Application.GetRealWidth (550),
                };
                row.AddChidren (btndeviceback);
 
                EventHandler<MouseEventArgs> devicclick = (sen, e) => {
                    var selectedDeviceState = new SelectedDeviceState ();
                    MainPage.MainFrameLayout.AddChidren (selectedDeviceState);
                    selectedDeviceState.Show (common, superGateWay);
                };
                row.MouseUpEventHandler += devicclick;
                devicename.MouseUpEventHandler += devicclick;
                btndeviceback.MouseUpEventHandler += devicclick;
 
            }
 
        }
 
 
    }
}