using System; using System.Collections.Generic; using System.Text; using Shared.SimpleControl.Phone; using Shared; using Shared.SimpleControl.R; namespace Shared.SimpleControl.Phone.Music { class Songlist : Shared.FrameLayout { int sourceId; public void Show(List listmusic, MusicModel musicMode, int sourceId) { this.sourceId = sourceId; 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 back = new Button { Width = Application.GetMinRealAverage(82), Height = Application.GetMinRealAverage(89), X = Application.GetRealWidth(10), Gravity = Gravity.CenterVertical, UnSelectedImagePath = "MusicIcon/PlayBack.png", }; topFrameLayout.AddChidren(back); back.MouseDownEventHandler += Back_MouseDownEventHandler; var button = new Button { Width = Application.GetRealWidth(200), Height = Application.GetRealHeight(150), //Text = "播放列表", TextID = MyInternationalizationString.Musicplaylist, X = Application.GetRealWidth(200), Gravity = Gravity.Center, TextColor = SkinStyle.Current.MusicTextColor, }; topFrameLayout.AddChidren(button); var frameLayout = new FrameLayout { Width = LayoutParams.MatchParent, Height = Application.GetRealHeight (Application.DesignHeight - 136), BackgroundColor =SkinStyle.Current.MusicVerticalScrolViewLayout, Y = topFrameLayout.Bottom, }; this.AddChidren(frameLayout); var Musiclist = new VerticalScrolViewLayout (); frameLayout.AddChidren (Musiclist); if (listmusic == null) { return; } for (int i = 0; i < listmusic.Count; i++) { var rowsong = new RowLayout { Width = LayoutParams.MatchParent, Height = Application.GetRealHeight(100), LineColor = SkinStyle.Current.MusicRowLayoutLineColor, }; Musiclist.AddChidren(rowsong); var titleMusic = new Button { Width = Application.GetRealWidth(80), Height = Application.GetRealHeight(70), X = Application.GetRealWidth(10), Gravity = Gravity.CenterVertical, UnSelectedImagePath = "MusicIcon/PlayMusic.png", }; rowsong.AddChidren(titleMusic); var song = new Button { Width = LayoutParams.MatchParent, Height = LayoutParams.MatchParent, Text = listmusic[i].name, TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth(120), Tag = listmusic[i].number, TextColor = SkinStyle.Current.MusicTextColor, }; rowsong.AddChidren(song); song.MouseUpEventHandler += (sender, e) => { rowsong.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); //当前控件界面 this.RemoveFromParent(); PlayPage playPage = new PlayPage { }; MainPage.MainFrameLayout.AddChidren(playPage); playPage.Show(musicMode, listmusic); playPage.SourceId = sourceId; Control.ControlBytesSend(Command.ControlMusicModel2, musicMode.SubnetID, musicMode.DeviceID, MusicModel.MusiceBytes("*Z01" + sourceId + "SONG" + song.Tag + "2"),SendCount.Zero); }); }); }; } } private void Back_MouseDownEventHandler(object sender, MouseEventArgs e) { this.RemoveFromParent(); } } }