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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
using System;
using System.Collections.Generic;
using System.Text;
using Shared;
using System.Xml;
using Shared.SimpleControl.R;
 
namespace Shared.SimpleControl.Phone.Music
{
    /// <summary>
    /// 网络流媒体音乐界面
    /// </summary>
    class A31EqualizerMode : FrameLayout
    {
 
        /// <summary>
        /// 古典模式
        /// </summary>
        Button classicalmodel;
 
        /// <summary>
        /// 流行模式  
        /// </summary>
        Button popularmodel;
 
        /// <summary>
        /// 爵士模式
        /// </summary>
        Button jazzymodel;
 
        /// <summary>
        /// 歌唱模式
        /// </summary>
        Button vocalmodel;
 
        /// <summary>
        /// 关闭均衡
        /// </summary>
        Button closemodel;
 
        //0 close关闭均衡 1 Classic古典模式  2 Popularliu流行模式 3 Jazzy爵士模式 4 Vocal模式
 
        A31MusicModel currentMusiceA31;
        public void Show(A31MusicModel a31)
        {
            currentMusiceA31 = a31;
 
            //BackgroundColor = 0XFF2F2F2F;
             
 
            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,
            };
            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);
 
            FrameLayout middle = new FrameLayout () {
                Height = Application.GetRealHeight (Application.DesignHeight - 130),
                BackgroundColor = 0XFF2F2F2F,
                Y = Application.GetRealHeight (130),
            };
            AddChidren(middle);
 
            //古典模式1
            classicalmodel = new Button {
                Width = Application.GetRealWidth (640 / 4),
                Height = Application.GetRealHeight (100),
                Text="古典模式",
                //TextID = MyInternationalizationString.Musicpopular,
                Y=Application.GetRealHeight(80),
                X=Application.GetRealWidth(30),
            };
            middle.AddChidren(classicalmodel);
            classicalmodel.MouseUpEventHandler += (sender, e) =>
            {
                classicalmodel.TextColor = 0xffFE5E00;
                popularmodel.TextColor = 0xFFFFFFFF;
                jazzymodel.TextColor = 0xFFFFFFFF;
                vocalmodel.TextColor = 0xFFFFFFFF;
                closemodel.TextColor = 0xFFFFFFFF;
                sendCommand (1);
            };
 
            //流行模式2
            popularmodel = new Button {
                Width = Application.GetRealWidth (640 / 4),
                Height = Application.GetRealHeight (100),
                Text="流行模式",
                //TextID = MyInternationalizationString.Musicballad,
                Y=Application.GetRealHeight(220),
                X=Application.GetRealWidth(30),
            };
            middle.AddChidren(popularmodel);
            popularmodel.MouseUpEventHandler += (sender, e) =>
            {
                classicalmodel.TextColor = 0xFFFFFFFF;
                popularmodel.TextColor = 0xffFE5E00;
                jazzymodel.TextColor = 0xFFFFFFFF;
                vocalmodel.TextColor = 0xFFFFFFFF;
                closemodel.TextColor = 0xFFFFFFFF;
                sendCommand (2);
            };
 
            //爵士模式3
            jazzymodel = new Button {
                Width = Application.GetRealWidth (640 / 4),
                Height = Application.GetRealHeight (100),
                Text="爵士模式",
                //TextID = MyInternationalizationString.Musicrock,
                Y=Application.GetRealHeight(360),
                X=Application.GetRealWidth(30),
            };
            middle.AddChidren(jazzymodel);
            jazzymodel.MouseUpEventHandler += (sender, e) =>
            {
                classicalmodel.TextColor = 0xFFFFFFFF;
                popularmodel.TextColor = 0xFFFFFFFF;
                jazzymodel.TextColor = 0xffFE5E00;
                vocalmodel.TextColor = 0xFFFFFFFF;
                closemodel.TextColor = 0xFFFFFFFF;
                sendCommand (3);
            };
 
            //歌唱模式4
            vocalmodel = new Button {
                Width = Application.GetRealWidth (640 / 4),
                Height = Application.GetRealHeight (100),
                //TextID = MyInternationalizationString.Musicclassical,
                Text="歌唱模式",
                Y=Application.GetRealHeight(500),
                X=Application.GetRealWidth(30),
            };
            middle.AddChidren(vocalmodel);
            vocalmodel.MouseUpEventHandler += (sender, e) =>
            {
                classicalmodel.TextColor = 0xFFFFFFFF;
                popularmodel.TextColor = 0xFFFFFFFF;
                jazzymodel.TextColor = 0xFFFFFFFF;
                vocalmodel.TextColor = 0xffFE5E00;
                closemodel.TextColor = 0xFFFFFFFF;
                sendCommand (4);
            };
 
             //关闭均衡0
            closemodel = new Button {
                Width = Application.GetRealWidth (640 / 4),
                Height = Application.GetRealHeight (100),
                //TextID = MyInternationalizationString.Musicclassical,
                Text="关闭均衡",
                Y=Application.GetRealHeight(640),
                X=Application.GetRealWidth(30),
            };
            middle.AddChidren(closemodel);
            closemodel.MouseUpEventHandler += (sender, e) =>
            {
                classicalmodel.TextColor = 0xFFFFFFFF;
                popularmodel.TextColor = 0xFFFFFFFF;
                jazzymodel.TextColor = 0xFFFFFFFF;
                vocalmodel.TextColor = 0xFFFFFFFF;
                closemodel.TextColor = 0xffFE5E00;
                sendCommand (0);
            };
 
           updateStatus (); 
        }
 
        void sendCommand (int mode)
        {
            System.Threading.Tasks.Task.Run (() => {
                Shared.Net.MyWebClient webClient = new Shared.Net.MyWebClient ();
                try 
                {
                    byte [] recevieBytes1 = webClient.DownloadData (new Uri ("http://" + currentMusiceA31.IPAddress + "/httpapi.asp?command=setPlayerCmd:equalizer:" + mode));
                } 
                catch { }
            });
        }
      
        void updateStatus ()
        {
            
            Shared.Net.MyWebClient webClient = new Shared.Net.MyWebClient ();
               try {
                   byte [] recevieBytes1 = webClient.DownloadData (new Uri ("http://" + currentMusiceA31.IPAddress + "/httpapi.asp?command=getEqualizer"));
                   var dd = System.Text.Encoding.UTF8.GetString (recevieBytes1, 0, recevieBytes1.Length);
                   if (dd == "1") {
                       classicalmodel.TextColor = 0xffFE5E00;
                   } else if (dd == "2") {
                       popularmodel.TextColor = 0xffFE5E00;
                   } else if (dd == "3") {
                       jazzymodel.TextColor = 0xffFE5E00;
                   } else if (dd == "4") {
                       vocalmodel.TextColor = 0xffFE5E00;
                   } else if (dd == "0") {
                       closemodel.TextColor = 0xffFE5E00;
                   }
               } 
                catch { }
 
        }
    }
}