using System; using System.Collections.Generic; using System.Text; using Shared; using Shared.SimpleControl.R; namespace Shared.SimpleControl.Pad.Music { class Usbmusic:FrameLayout { public void show(A31MusicModel a31,List infolist,FrameLayout SettingView,FrameLayout PalyPage) { FrameLayout topFrameLayout = new FrameLayout(); topFrameLayout.Width = LayoutParams.MatchParent; topFrameLayout.Height = Application.GetRealHeight(130); topFrameLayout.BackgroundImagePath = "MusicIcon/Backgroun2.png"; this.AddChidren(topFrameLayout); Button 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 += Back_MouseDownEventHandler; ; Button musiclist = new Button { Width = Application.GetRealWidth(200), Height = Application.GetRealHeight(150), TextID = MyInternationalizationString.SDcard, TextSize = 15, X = Application.GetRealWidth(200), Gravity = Gravity.CenterVertical, //Y = Application.GetRealHeight(10), }; topFrameLayout.AddChidren(musiclist); VerticalScrolViewLayout middle = new VerticalScrolViewLayout(); middle.Y = topFrameLayout.Bottom; middle.Height = Application.GetRealHeight(1136 - 130); middle.BackgroundColor = 0xff2F2F2F; //middle.BackgroundImagePath = "MusicIcon/HomepageBackgroun.png"; this.AddChidren(middle); int number = 0; foreach(var musicInfo in infolist) { // musicInfo.filename = "http://" + "192.168.1.107"+ ":" + "/httpapi.asp?command=setPlayerCmd:playLocalList/media/sda1/music" + musicInfo.Title; number++; var usbrowL = new RowLayout { LineColor = 0x62818181, Height = Application.GetRealHeight(100), }; middle.AddChidren(usbrowL); var usbtitle = new Button { Width = Application.GetRealWidth(80), Height = Application.GetRealHeight(70), X = Application.GetRealWidth(10), Gravity=Gravity.CenterVertical, UnSelectedImagePath="MusicIcon/PlayMusic.png", }; usbrowL.AddChidren(usbtitle); var usbmusic = new Button { Width = LayoutParams.MatchParent, Height = Application.GetRealHeight(100), Text = musicInfo.Title, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(120), Tag = number, }; usbrowL.AddChidren(usbmusic); usbmusic.MouseUpEventHandler += (sender,e) =>{ serarchSong(a31.IPAddress, usbmusic.Tag); this.RemoveFromParent(); }; } } /// /// 播放歌曲 /// /// /// /// string serarchSong(string id ,object Tag) { System.Net.WebClient webClient = new System.Net.WebClient(); try { byte[] recevieBytes = webClient.DownloadData(new Uri("http://"+id +"/httpapi.asp?command=setPlayerCmd:playLocalList"+":"+Tag)); return System.Text.Encoding.UTF8.GetString(recevieBytes, 0, recevieBytes.Length); } catch { return ""; } } private void Back_MouseDownEventHandler(object sender, MouseEventArgs e) { this.RemoveFromParent(); } } }