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
using System;
using System.Collections.Generic;
using System.Text;
using Shared;
using Shared.SimpleControl.R;
using Shared.SimpleControl.Phone.Music;
using Shared.SimpleControl.Phone;
using Shared.SimpleControl;
 
namespace SmartHome.UI.SimpleControl.Phone.Music
{
    class A31PandoraList : FrameLayout
    {
        A31MusicModel currentMusiceA31;
        public void show (A31MusicModel a31, string TextUserName, string TextPasswrod)
        {
            currentMusiceA31 = a31;
            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 PandoralistName = new Button {
                TextID = MyInternationalizationString.PANDORA,
                TextColor = SkinStyle.Current.MusicTextColor,
            };
            topFrameLayout.AddChidren (PandoralistName);
 
            var textname = new Button {
                Width = Application.GetRealWidth (260),
                Height = Application.GetRealHeight (50),
                X = Application.GetRealWidth (440),
                Gravity = Gravity.CenterVertical,
                Text = TextUserName.Split ('@') [0],
                TextColor = SkinStyle.Current.MusicTextColor,
            };
            topFrameLayout.AddChidren (textname);
            textname.MouseDownEventHandler += (sender, e) => {
                A31UserLogin userLogin = new A31UserLogin ();
                MainPage.MainFrameLayout.AddChidren (userLogin);
                userLogin.show (a31, TextUserName, TextPasswrod);
            };
 
            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 middle = new VerticalScrolViewLayout ();
            middle.Y = topFrameLayout.Bottom;
            middle.Height = Application.GetRealHeight (Application.DesignHeight - 136);
            //middle.BackgroundColor = 0xff2F2F2F;
            middle.BackgroundColor = SkinStyle.Current.MusicVerticalScrolViewLayout;
            AddChidren (middle);
 
            for (int i = 0; i < currentMusiceA31.PanRadioInfoList.Count; i++) {
                var panLayout = new RowLayout {
                    Height = Application.GetRealHeight (100),
                    LineColor = SkinStyle.Current.MusicRowLayoutLineColor,
                };
                middle.AddChidren (panLayout);
 
                var title = new Button {
                    Width = Application.GetRealWidth (61),
                    Height = Application.GetRealHeight (61),
                    X = Application.GetRealWidth (20),
                    Gravity = Gravity.CenterVertical,
                    Radius = (uint)Application.GetRealHeight (6),
                    UnSelectedImagePath = System.IO.File.Exists (currentMusiceA31.PanRadioInfoList [i].Image) ? currentMusiceA31.PanRadioInfoList [i].Image : "MusicIcon/musicplay1.png",
                };
                panLayout.AddChidren (title);
 
                var pansong = new Button {
                    Text = currentMusiceA31.PanRadioInfoList [i].Title,
                    TextAlignment = TextAlignment.CenterLeft,
                    X = Application.GetRealWidth (100),
                    TextColor = SkinStyle.Current.MusicTextColor,
                };
                panLayout.AddChidren (pansong);
                pansong.MouseUpEventHandler += (sender, e) => {
                    panLayout.BackgroundColor = 0xffFE5E00;
                    System.Threading.Tasks.Task.Run (() => {
                        System.Threading.Thread.Sleep (50);
                        Application.RunOnMainThread (() => {
                            this.Parent.RemoveAt (this.Parent.ChildrenCount - 3);
                            this.Parent.RemoveAt (this.Parent.ChildrenCount - 2);
                            RemoveFromParent ();
 
                            A31PlayMusicPage a31PlayMusic = new A31PlayMusicPage ();
                            MainPage.MainFrameLayout.AddChidren (a31PlayMusic);
                            a31PlayMusic.Show (new List<MusicInfo> ());
                            //a31PlayMusic.Source = "STATION-NETWORK";
                            a31.A31PlayStatus.Title = pansong.Text;
                            var text = pansong.Text;
                            System.Threading.Tasks.Task.Run (() => {
                                pushList (a31, text);
                            });
                        });
                    });
                };
            }
        }
 
        public void pushList (A31MusicModel a31, string listName)
        {
            StringBuilder playString = new StringBuilder ();
            playString.AppendLine ("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>");
            playString.AppendLine ("<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">");
            playString.AppendLine ("<s:Body>");
            playString.AppendLine ("<u:PlayQueueWithIndex xmlns:u=\"urn:schemas-wiimu-com:service:PlayQueue:1\">");
            playString.AppendLine ("<QueueName>" + listName + "</QueueName>");
            playString.AppendLine ("<Index>1</Index>");
            playString.AppendLine ("</u:PlayQueueWithIndex>");
            playString.AppendLine ("</s:Body>");
            playString.AppendLine ("</s:Envelope>");
            play (a31.IPAddress, a31.Port, playString.ToString ());
        }
 
 
        void play (string ip, int port, string info)
        {
            Shared.Net.MyWebClient webClient = new Shared.Net.MyWebClient ();
            webClient.Headers.Add ("SOAPACTION", "\"urn:schemas-wiimu-com:service:PlayQueue:1#PlayQueueWithIndex\"");
            webClient.Headers.Add ("CONTENT-TYPE", "text/xml; charset=\"utf-8\"");
            try {
                byte [] recevieBytes = webClient.UploadData (new Uri ("http://" + ip + ":" + port + "/upnp/control/PlayQueue1"), "POST", System.Text.Encoding.UTF8.GetBytes (info));
                var s = System.Text.Encoding.UTF8.GetString (recevieBytes, 0, recevieBytes.Length);
            } catch { }
        }
    }
}