using System;
using Shared;
namespace HDL_ON.UI.Music.View
{
public class SongView
{
///
/// 父控件
///
public RowLayout musicViewFl = new RowLayout
{
Width = Application.GetRealWidth(375),
Height = Application.GetRealHeight(44),
LineColor= MusicColor.WhiteColor,
};
///
/// 列表当前播放音乐图标
///
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",
};
///
/// 歌曲控件
///
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",
};
///
/// 歌手控件
///
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",
};
///
/// 添加喜爱音乐控件
///
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",
};
///
/// 添加到我的列表
///
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",
};
///
/// 点击控件
///
public Button clickBtn = new Button
{
Width = Application.GetRealWidth(250),
Height = Application.GetRealHeight(44),
};
///
/// 布局歌曲信息的View
///
///
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;
}
}
}
}