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
using System;
using Shared;
namespace SmartHome
{
    class Homemusic : FrameLayout
    {
        public void show ()
        {
 
            AddChidren (new Button {
                Height = Application.GetRealHeight (30),
                BackgroundColor = SkinStyle.Current.MainColor,
            });
 
            var topFrameLayout = new FrameLayout {
                Height = Application.GetRealHeight (100),
                Y = Application.GetRealHeight (30),
                BackgroundColor = SkinStyle.Current.MainColor,
            };
 
            AddChidren (topFrameLayout);
 
            var btnTitle = new Button {
                Text = "选择主从播放器",
                //TextID = MyInternationalizationString.streamingmusic,
                //TextSize = 20,
            };
            topFrameLayout.AddChidren (btnTitle);
 
            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 hdl = new Button {
                Width = Application.GetRealWidth (104),
                Height = Application.GetRealHeight (32),
                X = Application.GetRealWidth (530),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "MusicIcon/HDL.png",
            };
            topFrameLayout.AddChidren (hdl);
 
            var middle = new VerticalScrolViewLayout () {
                Height = Application.GetRealHeight (Application.DesignHeight - 130),
                BackgroundColor = 0XFF2F2F2F,
                Y = Application.GetRealHeight (130),
            };
            AddChidren (middle);
 
            for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++) {
                var row = new RowLayout {
                    Height = Application.GetRealHeight (100),
                };
                middle.AddChidren (row);
 
                var playername = new Button {
                    Width = Application.GetRealWidth (150),
                    Height = Application.GetRealHeight (100),
                    X = Application.GetRealWidth (15),
                    Gravity = Gravity.CenterVertical,
                    Text = A31MusicModel.A31MusicModelList[i].Name,
                };
                row.AddChidren (playername);
 
                var zhu = new Button {
                    Width = Application.GetRealWidth (140),
                    Height = Application.GetRealHeight (100),
                    X = Application.GetRealWidth (300),
                    Gravity = Gravity.CenterVertical,
                    Text = "主播放器",
                };
                row.AddChidren (zhu);
 
 
                var cong = new Button {
                    Width = Application.GetRealWidth (140),
                    Height = Application.GetRealHeight (100),
                    X = Application.GetRealWidth (440),
                    Gravity = Gravity.CenterVertical,
                    Text = "从播放器",
                };
                row.AddChidren (cong);
 
                zhu.MouseUpEventHandler += (sender, e) => 
                {
                    zhu.TextColor = 0xff436922;
                    sendCommand ();
                    cong.Alpha = 0.5f;
                };
 
                cong.MouseUpEventHandler += (sender,e) => 
                {
                    cong.TextColor = 0x0ff982208;
                    command();
                };
            }
 
        }
 
 
        void sendCommand ()
        {
            System.Threading.Tasks.Task.Run (() => {
                System.Net.WebClient webClient = new System.Net.WebClient ();
                try {
                    byte [] recevieBytes1 = webClient.DownloadData (new Uri ("http://" + A31MusicModel.Current.IPAddress + "/httpapi.asp?command=wpsservermode"));
                } catch { }
            });
        }
 
        void command ()
        {
            System.Threading.Tasks.Task.Run (() => {
                System.Net.WebClient webClient = new System.Net.WebClient ();
                try {
                    byte [] recevieBytes1 = webClient.DownloadData (new Uri ("http://" + A31MusicModel.Current.IPAddress + "/httpapi.asp?command=wpsclientmode"));
                } catch { }
            });
        }
 
    }
 
}