using System;
using System.Collections.Generic;
using System.Text;
using Shared;
using Shared.SimpleControl.R;
using System.Xml;
using Shared.SimpleControl.Phone;
using Shared.SimpleControl.Phone.Music;
using Shared.SimpleControl;
namespace SmartHome.UI.SimpleControl.Phone.Music
{
///
/// 电台播放列表
///
class A31CnList : FrameLayout
{
public void Show (A31MusicModel a31, string Name)
{
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 RadiolistName = new Button {
Text = Name,
TextColor = SkinStyle.Current.MusicTextColor,
};
topFrameLayout.AddChidren (RadiolistName);
var hdl = new Button {
Width = Application.GetRealWidth (154),
Height = Application.GetRealHeight (90),
X = Application.GetRealWidth (486),
Gravity = Gravity.CenterVertical,
UnSelectedImagePath = MainPage.LogoString,
};
topFrameLayout.AddChidren (hdl);
var back = new Button {
Width = Application.GetRealWidth (82),
Height = Application.GetRealHeight (89),
X = Application.GetRealWidth (10),
Gravity = Gravity.CenterVertical,
UnSelectedImagePath = "MusicIcon/HomepageBack.png",
};
topFrameLayout.AddChidren (back);
back.MouseDownEventHandler += (sender, e) => {
RemoveFromParent ();
};
var middle = new VerticalScrolViewLayout ();
middle.Y = topFrameLayout.Bottom;
middle.Height = Application.GetRealHeight (Application.DesignHeight - 136);
//middle.BackgroundColor = 0xff2F2F2F;
middle.BackgroundColor = SkinStyle.Current.MusicVerticalScrolViewLayout;
AddChidren (middle);
var cnlistMusicInfo = new List ();
foreach (var v in a31.CnRadioInfoList) {
#region Audio
if (v.Cntype == "audio") {
cnlistMusicInfo.Add (v);
var cnrow = new RowLayout {
Height = Application.GetRealHeight (100),
LineColor = SkinStyle.Current.MusicRowLayoutLineColor,
};
middle.AddChidren (cnrow);
var title = new Button {
Width = Application.GetRealWidth (61),
Height = Application.GetRealHeight (61),
X = Application.GetRealWidth (20),
Gravity = Gravity.CenterVertical,
Radius = (uint)Application.GetRealHeight (4),
UnSelectedImagePath = System.IO.File.Exists (v.Image) ? v.Image : "MusicIcon/musicplay1.png",
//UnSelectedImagePath = "MusicIcon/PlayMusic.png",
};
cnrow.AddChidren (title);
var cntext = new Button {
Text = v.Title,
X = Application.GetRealWidth (100),
Width = Application.GetRealWidth (400),
TextAlignment = TextAlignment.CenterLeft,
Gravity = Gravity.CenterVertical,
Tag = v,
TextColor=SkinStyle.Current.MusicTextColor,
};
cnrow.AddChidren (cntext);
EventHandler audiosources = (sen, e) => {
cnrow.BackgroundColor = 0xffFE5E00;
System.Threading.Tasks.Task.Run (() => {
System.Threading.Thread.Sleep (50);
Application.RunOnMainThread (() => {
for (int i = MainPage.MainFrameLayout.ChildrenCount - 1; 0 <= i; i--) {
var view = MainPage.MainFrameLayout.GetChildren (i);
if (view.GetType () == typeof (A31CnList)) {
view.RemoveFromParent ();
} else {
break;
}
}
MainPage.MainFrameLayout.RemoveAt (MainPage.MainFrameLayout.ChildrenCount - 1);
MainPage.MainFrameLayout.RemoveAt (MainPage.MainFrameLayout.ChildrenCount - 1);
MainPage.MainFrameLayout.RemoveAt (MainPage.MainFrameLayout.ChildrenCount - 1);
a31.CnRadioInfoList = cnlistMusicInfo;
A31PlayMusicPage a31PlayMusic = new A31PlayMusicPage ();
MainPage.MainFrameLayout.AddChidren (a31PlayMusic);
a31PlayMusic.Show (new List ());
//a31PlayMusic.Source = "RADIO-NETWORK";
a31.A31PlayStatus.Title = cntext.Text;
System.Threading.Tasks.Task.Run (() => {
pushList (a31, cntext.Tag as MusicInfo, Name);
//MyMusic.dateTime = System.DateTime.Now.AddSeconds (-5);
});
});
});
};
title.MouseUpEventHandler += audiosources;
cntext.MouseUpEventHandler += audiosources;
}
#endregion
#region Link
if (v.Cntype == "link") {
var cnrowlink = new RowLayout {
Height = Application.GetRealHeight (100),
LineColor = SkinStyle.Current.MusicRowLayoutLineColor,
};
middle.AddChidren (cnrowlink);
var radius = new Button {
Width = Application.GetRealWidth (36),
Height = Application.GetRealHeight (36),
TextAlignment = TextAlignment.CenterLeft,
X = Application.GetRealWidth (20),
UnSelectedImagePath = "MusicIcon/radius.png",
Gravity = Gravity.CenterVertical,
};
cnrowlink.AddChidren (radius);
var cntextlink = new Button {
Gravity = Gravity.CenterVertical,
Text = v.Title.Replace ("&", "/"),
X = Application.GetRealWidth (80),
TextAlignment = TextAlignment.CenterLeft,
Tag = v.URL,
TextColor = SkinStyle.Current.MusicTextColor,
};
cnrowlink.AddChidren (cntextlink);
var nextSD = new Button {
Width = Application.GetRealWidth (87),
Height = Application.GetRealHeight (100),
UnSelectedImagePath = "MusicIcon/Next.png",
SelectedImagePath = "MusicIcon/NextSelecte.png",
X = Application.GetRealWidth (550),
};
cnrowlink.AddChidren (nextSD);
EventHandler CNresources = (sender, e) => {
MainPage.Loading.Start (Language.StringByID (MyInternationalizationString.load));
System.Threading.Tasks.Task.Run (() => {
try {
var redString = readRadioList (cntextlink.Tag.ToString ());
if (redString == null) {
return;
}
int startIndex2 = redString.IndexOf ("");
int endIndex = redString.IndexOf ("") + "