using System; using System.Collections.Generic; using System.Text; using Shared; using Shared.SimpleControl.R; using Shared.SimpleControl.Pad.Music; using Shared.SimpleControl; namespace SmartHome.UI.SimpleControl.Pad.Music { class A31PandoraList : FrameLayout { A31MusicModel currentMusiceA31; public void show (A31MusicModel a31, string TextUserName, string TextPasswrod, FrameLayout SettingView, FrameLayout PalyPage) { currentMusiceA31 = a31; var topFrameLayout = new FrameLayout { Height = Application.GetRealHeight (100), BackgroundColor = SkinStyle.Current.MainColor, }; AddChidren (topFrameLayout); var PandoralistName = new Button { TextID = MyInternationalizationString.PANDORA, }; topFrameLayout.AddChidren (PandoralistName); var textname = new Button { Width = Application.GetRealWidth (260), Height = Application.GetRealHeight (50), X = Application.GetRealWidth (380), Gravity = Gravity.CenterVertical, Text = TextUserName.Split ('@') [0], }; topFrameLayout.AddChidren (textname); textname.MouseDownEventHandler += (sender, e) => { A31UserLogin userLogin = new A31UserLogin (); SettingView.AddChidren (userLogin); userLogin.show (a31, TextUserName, TextPasswrod, SettingView, PalyPage); }; 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 - 100-150); middle.BackgroundColor = 0xff2F2F2F; AddChidren (middle); for (int i = 0; i < currentMusiceA31.PanRadioInfoList.Count; i++) { var panLayout = new RowLayout { Height = Application.GetRealHeight (100), }; 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 (120), }; 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 - 2); RemoveFromParent (); 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 (""); playString.AppendLine (""); playString.AppendLine (""); playString.AppendLine (""); playString.AppendLine ("" + listName + ""); playString.AppendLine ("1"); playString.AppendLine (""); playString.AppendLine (""); playString.AppendLine (""); play (a31.IPAddress, a31.Port, playString.ToString ()); } void play (string ip, int port, string info) { System.Net.WebClient webClient = new System.Net.WebClient (); 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 { } } } }