| | |
| | | /// <summary> |
| | | /// 父控件 |
| | | /// </summary> |
| | | public FrameLayout musicViewFl = new FrameLayout |
| | | public RowLayout musicViewFl = new RowLayout |
| | | { |
| | | Width = Application.GetRealWidth(375), |
| | | Height = Application.GetRealHeight(44), |
| | | LineColor= MusicColor.WhiteColor, |
| | | }; |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | X = Application.GetRealWidth(16), |
| | | Y = Application.GetRealHeight(11), |
| | | Width = Application.GetRealWidth(100), |
| | | // Width = wText + Application.GetRealWidth(5), |
| | | Height = Application.GetRealHeight(22), |
| | | TextColor = Color.MusicTxet14Color, |
| | | TextColor = MusicColor.MusicTxet14Color, |
| | | TextSize = TextSize.Text16, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | Name = "song", |
| | | }; |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 歌手控件 |
| | | /// </summary> |
| | | public Button singerBtn = new Button |
| | | { |
| | | Y = Application.GetRealHeight(11), |
| | | //Width = Application.GetRealWidth(220) - wText,//歌名长度小于220才可以显示歌手出来 |
| | | Height = Application.GetRealHeight(22), |
| | | TextColor = Color.MusicNoTxetColor, |
| | | TextColor = MusicColor.MusicNoTxetColor, |
| | | TextSize = TextSize.Text12, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | //Text =("-" +songs.Artist).Trim(), |
| | |
| | | Y = Application.GetRealHeight(8), |
| | | Width = Application.GetMinRealAverage(28), |
| | | Height = Application.GetMinRealAverage(28), |
| | | UnSelectedImagePath = "MusicIcon/addMusic.png", |
| | | UnSelectedImagePath = "MusicIcon/addMusic1.png", |
| | | }; |
| | | /// <summary> |
| | | /// 点击控件 |
| | | /// </summary> |
| | | public Button clickBtn = new Button |
| | | { |
| | | Width = Application.GetRealWidth(280), |
| | | Width = Application.GetRealWidth(250), |
| | | Height = Application.GetRealHeight(44), |
| | | }; |
| | | |
| | |
| | | /// 布局歌曲信息的View |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public FrameLayout SongFrameLayout() |
| | | public void SongFrameLayout(VerticalRefreshLayout refreshLayout, MusicInfo songs) |
| | | { |
| | | musicViewFl.AddChidren(playIconBtn); |
| | | musicViewFl.AddChidren(songBtn); |
| | | singerBtn.X = songBtn.Right; |
| | | musicViewFl.AddChidren(singerBtn); |
| | | musicViewFl.AddChidren(clickBtn); |
| | | musicViewFl.AddChidren(loveIcon); |
| | | musicViewFl.AddChidren(addIcon); |
| | | return musicViewFl; |
| | | /* |
| | | View.SongView songView = new View.SongView(); |
| | | middViewLayout.AddChidren(songView.SongFrameLayout()); |
| | | songView.songBtn.Tag = songs.URL; |
| | | if (string.IsNullOrEmpty(songs.Title)) |
| | | { |
| | | //防止歌曲名字为空抛异常 |
| | | songs.Title = " "; |
| | | } |
| | | songView.songBtn.Text = songs.Title.Trim(); |
| | | var wText = songView.songBtn.GetTextWidth();//获取文本宽度 |
| | | ///(歌曲+歌手)宽度最大值时280 |
| | | if (wText > 280) |
| | | { |
| | | refreshLayout.AddChidren(musicViewFl); |
| | | |
| | | songView.songBtn.Width = Application.GetRealWidth(280); |
| | | } |
| | | else |
| | | playIconBtn.Tag = songs.URL; |
| | | songBtn.Tag = songs.URL; |
| | | singerBtn.Tag = songs.URL; |
| | | clickBtn.Tag = songs;//标记播放哪一首歌曲 |
| | | songBtn.Text = string.IsNullOrEmpty(songs.Title) ? "Unkonw" : songs.Title.Trim(); |
| | | var wText = songBtn.GetTextWidth() + Application.GetRealWidth(15); |
| | | if (wText > Application.GetRealWidth(220)) |
| | | { |
| | | songView.songBtn.Width = wText + 5; |
| | | wText = Application.GetRealWidth(220);//(歌曲+歌手)宽度最大值时220 |
| | | } |
| | | songView.singerBtn.X = songView.songBtn.Right; |
| | | if (string.IsNullOrEmpty(songs.Artist)) |
| | | { |
| | | //防止歌手名字为空抛异常 |
| | | songs.Artist = " "; |
| | | } |
| | | songView.singerBtn.Text = "-" + songs.Artist.Trim(); |
| | | |
| | | songView.singerBtn.Width = Application.GetRealWidth(280 - songView.songBtn.Width); |
| | | if (wText > 280) |
| | | { |
| | | ///歌名长度小于280才可以显示歌手出来 |
| | | songView.singerBtn.Width = Application.GetRealWidth(0); |
| | | } |
| | | |
| | | songView.loveIcon.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | songView.loveIcon.IsSelected = !songView.loveIcon.IsSelected; |
| | | if (songView.loveIcon.IsSelected) |
| | | { |
| | | ///查找音乐是否存在在列表 |
| | | var music1 = A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.URL == songs.URL); |
| | | if (music1 == null) |
| | | { |
| | | ///没有存在就添加 |
| | | A31MusicModel.Current.LoveMusicInfoList.Add(songs); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | ///查找音乐是否存在在列表 |
| | | var music1 = A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.URL == songs.URL); |
| | | if (music1 != null) |
| | | { |
| | | ///存在就删除 |
| | | A31MusicModel.Current.LoveMusicInfoList.Remove(songs); |
| | | } |
| | | |
| | | } |
| | | // A31MusicModel.Save(); |
| | | }; |
| | | songBtn.Width = wText; |
| | | singerBtn.X = songBtn.Right; |
| | | singerBtn.Width = Application.GetRealWidth(220) - wText;//歌名长度小于220才可以显示歌手出来 |
| | | singerBtn.Text = string.IsNullOrEmpty(songs.Artist) ? "-Unkonw" : "-" + songs.Artist.Trim(); |
| | | var music = A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.URL == songs.URL); |
| | | if (music != null) |
| | | { |
| | | songView.loveIcon.IsSelected = true; |
| | | loveIcon.IsSelected = true; |
| | | } |
| | | else |
| | | { |
| | | songView.loveIcon.IsSelected = false; |
| | | loveIcon.IsSelected = false; |
| | | } |
| | | songView.clickBtn.Tag = number;//标记播放哪一首歌曲 |
| | | songView.clickBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | | System.Threading.Thread.Sleep(50); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | //移除界面 |
| | | A31MusicModel.Current.A31PlayStatus.Title = songView.songBtn.Text; |
| | | MainPage.BasePageView.RemoveViewByTag("Music"); |
| | | //A31PlayMusicPage a31PlayMusicPage = new A31PlayMusicPage(); |
| | | //MainPage.BasePageView.AddChidren(a31PlayMusicPage); |
| | | //a31PlayMusicPage.Show(); |
| | | //MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | System.Threading.Tasks.Task.Run(() => |
| | | { |
| | | PlayStrinfg(songView.clickBtn.Tag); |
| | | }); |
| | | }); |
| | | }); |
| | | |
| | | }; |
| | | */ |
| | | |
| | | |
| | | } |
| | | |