using System;
using System.Collections.Generic;
using Shared.SimpleControl.Phone;
using Shared.SimpleControl;
using System.Text;
using Shared;
namespace Shared.SimpleControl.Phone.Music
{
///
/// 音乐播放列表界面
///
class ListPage : Shared.FrameLayout
{
public void Musiclist(MusicModel musicModel, List playListmusic, string Listname, int sourceID)
{
AddChidren(new Button()
{
Height = Application.GetRealHeight(36),
BackgroundColor = SkinStyle.Current.MusicTopFrameLayout,
});
var topFrameLayout = new FrameLayout()
{
Height = Application.GetRealHeight(100),
Y = Application.GetRealHeight(36),
BackgroundColor = SkinStyle.Current.MusicTopFrameLayout,
};
AddChidren(topFrameLayout);
var back = new Button
{
Width = Application.GetMinRealAverage(72),
Height = Application.GetMinRealAverage(89),
X = Application.GetRealWidth(10),
Gravity = Gravity.CenterVertical,
UnSelectedImagePath = "MusicIcon/PlayBack.png",
};
topFrameLayout.AddChidren(back);
back.MouseDownEventHandler += (sender, o) =>
{
RemoveFromParent();
};
var titleBtn = new Button
{
Width = Application.GetRealWidth(200),
Height = Application.GetRealHeight(200),
Gravity = Gravity.Center,
Text = Listname,
TextColor = SkinStyle.Current.MusicTextColor
};
topFrameLayout.AddChidren(titleBtn);
var verticalScrolViewLayout = new VerticalScrolViewLayout
{
Height = Application.GetRealHeight(1000),
Y = Application.GetRealHeight(130),
BackgroundColor =SkinStyle.Current.MusicVerticalScrolViewLayout,
};
AddChidren(verticalScrolViewLayout);
for (int i = 0; i < playListmusic.Count; i++)
{
var rowsong = new RowLayout
{
Height = Application.GetRealHeight(100),
LineColor = SkinStyle.Current.MusicRowLayoutLineColor,
};
verticalScrolViewLayout.AddChidren(rowsong);
var titleMusic = new Button
{
Width = Application.GetRealWidth(80),
Height = Application.GetRealHeight(70),
X = Application.GetRealWidth(10),
Gravity = Gravity.CenterVertical,
UnSelectedImagePath = "MusicIcon/PlayMusic.png",
};
rowsong.AddChidren(titleMusic);
var song = new Button
{
Text = playListmusic[i].name,
TextAlignment = TextAlignment.CenterLeft,
X = Application.GetRealWidth(120),
Tag = playListmusic[i].number,
TextColor = SkinStyle.Current.MusicTextColor
};
rowsong.AddChidren(song);
song.MouseUpEventHandler += (sender, e) =>
{
rowsong.BackgroundColor = 0xffFE5E00;
System.Threading.Tasks.Task.Run(() =>
{
System.Threading.Thread.Sleep(200);
Application.RunOnMainThread(() =>
{
RemoveFromParent();
Control.ControlBytesSend(Command.ControlMusicModel2, musicModel.SubnetID, musicModel.DeviceID, MusicModel.MusiceBytes("*Z01" + sourceID + "SONG" + song.Tag + "2"),SendCount.Zero);
});
});
};
var del = new Button
{
Text = "删除",
BackgroundColor = 0xFFFF0000,
Tag = playListmusic[i].number,
};
rowsong.AddRightView(del);
del.MouseUpEventHandler += (sender, e) =>
{
if (sourceID == 1)
{
for (int j = 0; j < musicModel.SDCardSongList.Count; j++)
{
if (musicModel.SDCardSongList[j].number == del.Tag.ToString())
{
musicModel.SDCardSongList.RemoveAt(j);
break;
}
}
}
else if (sourceID == 2)
{
for (int j = 0; j < musicModel.NasSongList.Count; j++)
{
if (musicModel.NasSongList[j].number == del.Tag.ToString())
{
musicModel.NasSongList.RemoveAt(j);
break;
}
}
}
rowsong.RemoveFromParent();
};
}
}
}
}