using System; using System.Collections.Generic; using System.Text; using Shared; using Shared.SimpleControl.R; using Shared.SimpleControl.Pad; using SmartHome; namespace Shared.SimpleControl.Pad.Music { class A31MyList : FrameLayout { A31MusicModel currentA31; VerticalScrolViewLayout middle; public void Show (A31MusicModel a31, FrameLayout SettingView,FrameLayout PalyPage,MusicInfo musicInfo = null ) { currentA31 = a31; var topFrameLayout = new FrameLayout { Height = Application.GetRealHeight (100), BackgroundColor = SkinStyle.Current.MainColor, }; this.AddChidren (topFrameLayout); var btnTitle = new Button { TextID = MyInternationalizationString.MusicMylist, TextSize = 20, }; 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) => { this.RemoveFromParent (); }; var addfram = new FrameLayout { Height = Application.GetRealHeight (100), Y = topFrameLayout.Bottom, BackgroundColor = 0xff2f2f2f, }; this.AddChidren (addfram); var editorListName = new EditText { Width = Application.GetMinReal (400), Height = Application.GetRealHeight (60), TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth (50), BackgroundColor = 0xFF4D4D4D, PlaceholderText =Language.StringByID(MyInternationalizationString.newlist), PlaceholderTextColor = 0xcccccccc, Gravity=Gravity.CenterVertical, }; addfram.AddChidren (editorListName); var mylistback = new Button { Width = Application.GetRealWidth (72), Height = Application.GetRealHeight (58), UnSelectedImagePath = "MusicIcon/add.png", X = Application.GetRealWidth (480), Gravity = Gravity.CenterVertical, }; addfram.AddChidren (mylistback); var red = new Button { Y = addfram.Bottom, Height = Application.GetRealHeight (4), BackgroundColor = 0xff181818, }; this.AddChidren (red); middle = new VerticalScrolViewLayout (); middle.Y = red.Bottom; middle.Height = Application.GetRealHeight (Application.DesignHeight-150-100-100-4); middle.BackgroundColor = 0xff2f2f2f; this.AddChidren (middle); mylistback.MouseUpEventHandler += (sender, e) => { if (editorListName.Text == "") { //列表名为空 new Alert (Language.StringByID (MyInternationalizationString.Tip), Language.StringByID (MyInternationalizationString.listempty), Language.StringByID (MyInternationalizationString.Close)).Show (); return; } foreach (ListInfo listInfo in a31.ListInfos) { if (listInfo.ListName == editorListName.Text) { //列表名称相同 new Alert (Language.StringByID (MyInternationalizationString.Tip), Language.StringByID (MyInternationalizationString.listsame), Language.StringByID (MyInternationalizationString.Close)).Show (); return; } } a31.ListInfos.Add (new ListInfo { ListName = editorListName.Text }); A31MusicModel.Save (); showList (musicInfo,SettingView,PalyPage); }; showList (musicInfo,SettingView,PalyPage); } void showList (MusicInfo musicInfo, FrameLayout SettingView,FrameLayout PalyPage) { middle.RemoveAll (); foreach (var listInfo in currentA31.ListInfos) { RowLayout addlistrow = new RowLayout { Height = Application.GetRealHeight (100), }; middle.AddChidren (addlistrow); var radius = new Button { Width = Application.GetRealWidth (36), Height = Application.GetRealHeight (36), TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth (20), UnSelectedImagePath = "MusicIcon/radius.png", Gravity = Gravity.CenterVertical, }; addlistrow.AddChidren (radius); var listback = new Button { Width = Application.GetRealWidth (87), Height = Application.GetRealHeight (100), UnSelectedImagePath = "MusicIcon/Next.png", SelectedImagePath = "MusicIcon/NextSelecte.png", X = Application.GetRealWidth (480), Gravity = Gravity.CenterVertical, }; addlistrow.AddChidren (listback); var listnamet = new Button { Height = Application.GetRealHeight (100), TextAlignment = TextAlignment.CenterLeft, X = Application.GetRealWidth (120), Text = listInfo.ListName, }; addlistrow.AddChidren (listnamet); listnamet.MouseUpEventHandler += (sender1, e1) => { if (musicInfo == null) { var tempMusicInfo = currentA31.ListInfos.Find ((obj) => { return obj.ListName == listnamet.Text; }); if (tempMusicInfo == null) { return; } A31AddListMusic a31AddListMuisc = new A31AddListMusic (); SettingView.AddChidren (a31AddListMuisc); a31AddListMuisc.Show (listnamet.Text, tempMusicInfo.MusicInfoList); } else { var tempMusicInfo = currentA31.ListInfos.Find ((obj) => { return obj.ListName == listnamet.Text; }); if (tempMusicInfo == null) { return; } if (null == tempMusicInfo.MusicInfoList.Find ((music) => { return music.Title == musicInfo.Title; })) { tempMusicInfo.MusicInfoList.Add (musicInfo); A31MusicModel.Save (); } RemoveFromParent (); MainPage.AddTip (Language.StringByID(MyInternationalizationString.addsuccess), 1000); } }; var del = new Button { TextID = MyInternationalizationString.Musicdel, BackgroundColor = 0xFFFF0000, Tag = listInfo.ListName, }; del.MouseUpEventHandler += (sender1, e1) => { for (int j = 0; j < currentA31.ListInfos.Count; j++) { if (currentA31.ListInfos [j].ListName == del.Tag.ToString ()) { currentA31.ListInfos.RemoveAt (j); break; } } addlistrow.RemoveFromParent (); A31MusicModel.Save (); }; addlistrow.AddRightView (del); } } } }