using System;
|
using Shared;
|
namespace HDL_ON.UI.Music.View
|
{
|
public class SongView
|
{
|
/// <summary>
|
/// 父控件
|
/// </summary>
|
public RowLayout musicViewFl = new RowLayout
|
{
|
Width = Application.GetRealWidth(375),
|
Height = Application.GetRealHeight(44),
|
LineColor= MusicColor.WhiteColor,
|
};
|
|
/// <summary>
|
/// 列表当前播放音乐图标
|
/// </summary>
|
public Button playIconBtn = new Button
|
{
|
X = Application.GetRealWidth(16),
|
Y = Application.GetRealHeight(10),
|
Width = Application.GetMinRealAverage(24),
|
Height = Application.GetMinRealAverage(24),
|
UnSelectedImagePath = "MusicIcon/playStatus.png",
|
Visible = false,
|
Name = "playStatus",
|
};
|
|
/// <summary>
|
/// 歌曲控件
|
/// </summary>
|
public Button songBtn = new Button
|
{
|
X = Application.GetRealWidth(16),
|
Y = Application.GetRealHeight(11),
|
// Width = wText + Application.GetRealWidth(5),
|
Height = Application.GetRealHeight(22),
|
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 = MusicColor.MusicNoTxetColor,
|
TextSize = TextSize.Text12,
|
TextAlignment = TextAlignment.CenterLeft,
|
//Text =("-" +songs.Artist).Trim(),
|
Name = "singer",
|
};
|
|
/// <summary>
|
/// 添加喜爱音乐控件
|
/// </summary>
|
public Button loveIcon = new Button
|
{
|
X = Application.GetRealWidth(291),
|
Y = Application.GetRealHeight(8),
|
Width = Application.GetMinRealAverage(28),
|
Height = Application.GetMinRealAverage(28),
|
UnSelectedImagePath = "MusicIcon/love.png",
|
SelectedImagePath = "MusicIcon/loveSelected.png",
|
};
|
|
/// <summary>
|
/// 添加到我的列表
|
/// </summary>
|
public Button addIcon = new Button
|
{
|
X = Application.GetRealWidth(335),
|
Y = Application.GetRealHeight(8),
|
Width = Application.GetMinRealAverage(28),
|
Height = Application.GetMinRealAverage(28),
|
UnSelectedImagePath = "MusicIcon/addMusic1.png",
|
};
|
/// <summary>
|
/// 点击控件
|
/// </summary>
|
public Button clickBtn = new Button
|
{
|
Width = Application.GetRealWidth(250),
|
Height = Application.GetRealHeight(44),
|
};
|
|
/// <summary>
|
/// 布局歌曲信息的View
|
/// </summary>
|
/// <returns></returns>
|
public void SongFrameLayout(VerticalRefreshLayout refreshLayout, MusicInfo songs)
|
{
|
musicViewFl.AddChidren(playIconBtn);
|
musicViewFl.AddChidren(songBtn);
|
musicViewFl.AddChidren(singerBtn);
|
musicViewFl.AddChidren(clickBtn);
|
musicViewFl.AddChidren(loveIcon);
|
musicViewFl.AddChidren(addIcon);
|
refreshLayout.AddChidren(musicViewFl);
|
|
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))
|
{
|
wText = Application.GetRealWidth(220);//(歌曲+歌手)宽度最大值时220
|
}
|
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)
|
{
|
loveIcon.IsSelected = true;
|
}
|
else
|
{
|
loveIcon.IsSelected = false;
|
}
|
|
}
|
|
}
|
}
|