using System; using System.Collections.Generic; using Shared; namespace HDL_ON.UI.Music { public class A31MyList : FrameLayout { public A31MyList() { Tag = "Music"; } VerticalScrolViewLayout middViewLayout; public void Show() { this.BackgroundColor = Color.ViewColor; var topView = new TopView(); this.AddChidren(topView.TopFLayoutView()); topView.topNameBtn.TextID = StringId.myList; topView.clickBackBtn.MouseUpEventHandler += (sender, e) => { this.RemoveFromParent(); }; Button addIconBtn = new Button { X = Application.GetRealWidth(336), Y = Application.GetRealHeight(30), Width = Application.GetMinRealAverage(28), Height = Application.GetMinRealAverage(28), UnSelectedImagePath = "MusicIcon/addMusic.png", }; topView.TopFLayoutView().AddChidren(addIconBtn); addIconBtn.MouseUpEventHandler += (sender, e) => { var fileNameList = new List(); fileNameList.Clear(); foreach (var stringName in A31MusicModel.Current.FileLists) { fileNameList.Add(stringName.ListName); } new View.TipView().InputBox(StringId.addNewList, "", StringId.listNameNull, StringId.listNamesSame, fileNameList, (name) => { A31MusicModel.Current.FileLists.Add(new FileListInfo { ListName = name, }); A31MusicModel.Save(); FileView(); }); }; middViewLayout = new VerticalScrolViewLayout { BackgroundColor = Color.WhiteColor, Y = topView.fLayout.Bottom, Height = Application.GetRealHeight(H_W.H - H_W.T_Height), }; this.AddChidren(middViewLayout); FileView(); } /// /// /// void FileView() { middViewLayout.RemoveAll(); for (int i = 0; i < A31MusicModel.Current.FileLists.Count; i++) { var list = A31MusicModel.Current.FileLists[i]; RowLayout addFlieRow = new RowLayout { Height = Application.GetRealHeight(104), LineColor = Color.WhiteColor, SubViewWidth = Application.GetRealWidth(90),//改变编辑控件宽度多少; }; middViewLayout.AddChidren(addFlieRow); //文件图标 Button fileIconBtn = new Button { X = Application.GetRealWidth(16), Y = Application.GetRealHeight(8), Width = Application.GetMinRealAverage(88), Height = Application.GetMinRealAverage(88), UnSelectedImagePath = "MusicIcon/fileList.png", }; addFlieRow.AddChidren(fileIconBtn); //播放/暂停图标 Button playIconBtn = new Button { X = Application.GetRealWidth(78), Y = Application.GetRealHeight(70), Width = Application.GetMinRealAverage(24), Height = Application.GetMinRealAverage(24), UnSelectedImagePath = "MusicIcon/filePause.png", SelectedImagePath = "MusicIcon/filePlay.png", }; addFlieRow.AddChidren(playIconBtn); playIconBtn.MouseUpEventHandler += (sender, e) => { //点击按钮随机播放音乐 }; //文件名控件 Button fileNameBtn = new Button { X = fileIconBtn.Right + Application.GetRealWidth(16), Y = Application.GetRealHeight(42), Width = Application.GetRealWidth(217), Height = Application.GetRealHeight(20), TextColor = Color.TextColor, TextSize = TextSize.Text14, TextAlignment = TextAlignment.CenterLeft, Text= list.ListName, }; addFlieRow.AddChidren(fileNameBtn); ///编辑控件 var editBtn = new Button { BackgroundColor = Color.MusicEditColor, Text = Language.StringByID(StringId.editMusic), TextColor = Color.WhiteColor, TextSize = TextSize.Text16, }; addFlieRow.AddRightView(editBtn); editBtn.MouseUpEventHandler += (sender, e) => { var fileNameList = new List(); fileNameList.Clear(); foreach (var stringName in A31MusicModel.Current.FileLists) { fileNameList.Add(stringName.ListName); } new View.TipView().InputBox(StringId.modifyName, list.ListName, StringId.listNameNull, StringId.listNamesSame, fileNameList, (name) => { if (list.ListName != name) { ///修改名称不一样更新保存 list.ListName = name; fileNameBtn.Text = name; A31MusicModel.Save(); } }); }; ///删除控件 var delBtn = new Button { BackgroundColor = Color.MusicDelColor, Text = Language.StringByID(StringId.delMusic), TextColor = Color.WhiteColor, TextSize = TextSize.Text16, }; addFlieRow.AddRightView(delBtn); delBtn.MouseUpEventHandler += (sender, e) => { new View.TipView().TipBox(StringId.tip, StringId.delMusicFile, () => { A31MusicModel.Current.FileLists.Remove(list); A31MusicModel.Save(); addFlieRow.RemoveFromParent(); }); }; Button clickBtn = new Button { X = fileIconBtn.Right + Application.GetRealWidth(16), Width = Application.GetRealWidth(375 - 138), Height = Application.GetRealHeight(104), }; addFlieRow.AddChidren(clickBtn); clickBtn.MouseUpEventHandler += (sender, e) => { A31MyListMusic a31MyListMusic = new A31MyListMusic(); MainPage.BasePageView.AddChidren(a31MyListMusic); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; a31MyListMusic.Show(list); a31MyListMusic.UpdateSelectedMusic(); }; } } } }