using System;
using Shared;
namespace HDL_ON.UI.Music.View
{
public class SongView
{
///
/// 父控件
///
public FrameLayout musicViewFl = new FrameLayout
{
Width = Application.GetRealWidth(375),
Height = Application.GetRealHeight(44),
};
///
/// 列表当前播放音乐图标
///
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 = Application.GetRealWidth(100),
Height = Application.GetRealHeight(22),
TextColor = Color.MusicTxet14Color,
TextSize = TextSize.Text16,
TextAlignment = TextAlignment.CenterLeft,
Name = "song",
};
///
/// 歌手控件
///
public Button singerBtn = new Button
{
Y = Application.GetRealHeight(11),
Height = Application.GetRealHeight(22),
TextColor = Color.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/addMusic.png",
};
///
/// 点击控件
///
public Button clickBtn = new Button
{
Width = Application.GetRealWidth(280),
Height = Application.GetRealHeight(44),
};
///
/// 布局歌曲信息的View
///
///
public FrameLayout SongFrameLayout()
{
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)
{
songView.songBtn.Width = Application.GetRealWidth(280);
}
else
{
songView.songBtn.Width = wText + 5;
}
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();
};
var music = A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.URL == songs.URL);
if (music != null)
{
songView.loveIcon.IsSelected = true;
}
else
{
songView.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);
});
});
});
};
*/
}
}
}