using System;
|
using System.Collections.Generic;
|
using Shared;
|
namespace HDL_ON.UI.Music.View
|
{
|
public class DialogView
|
{
|
/// <summary>
|
///弹窗文件夹列表界面
|
/// </summary>
|
/// <param name="musicInfo"></param>
|
public void FieListView(MusicInfo musicInfo)
|
{
|
//主控件
|
Dialog dialog = new Dialog()
|
{
|
BackgroundColor = Color.PopupBackgroundColor,
|
};
|
dialog.Show();
|
//父控件
|
FrameLayout frame = new FrameLayout { };
|
dialog.AddChidren(frame);
|
frame.MouseUpEventHandler += (sen, e) =>
|
{
|
dialog.Close();
|
};
|
//白色快父控件
|
FrameLayout dialogFra = new FrameLayout()
|
{
|
X = Application.GetRealWidth(16),
|
Y = Application.GetRealHeight(187),
|
Width = Application.GetRealWidth(344),
|
Height = Application.GetRealHeight(460),
|
BackgroundColor = Color.WhiteColor,
|
Radius = (uint)Application.GetRealHeight(12),
|
};
|
frame.AddChidren(dialogFra);
|
//显示头部信息父控件
|
FrameLayout topFra = new FrameLayout()
|
{
|
Width = Application.GetRealWidth(344),
|
Height = Application.GetRealHeight(70),
|
};
|
dialogFra.AddChidren(topFra);
|
//取消控件
|
Button cancelnBtn = new Button
|
{
|
X = Application.GetRealWidth(16),
|
Y = Application.GetRealHeight(24),
|
Width = Application.GetRealWidth(60),
|
Height = Application.GetRealHeight(20),
|
TextID = StringId.cancelMusic,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = Color.MusicNoTxetColor,
|
TextSize = TextSize.Text14,
|
};
|
topFra.AddChidren(cancelnBtn);
|
cancelnBtn.MouseUpEventHandler += (sen, e) =>
|
{
|
dialog.Close();
|
};
|
//标题控件
|
Button txetBtn = new Button
|
{
|
X = cancelnBtn.Right + Application.GetRealWidth(20),
|
Y = Application.GetRealHeight(23),
|
Width = Application.GetRealWidth(152),
|
Height = Application.GetRealHeight(22),
|
TextColor = Color.TextColor,
|
TextSize = TextSize.Text16,
|
TextAlignment = TextAlignment.Center,
|
TextID = StringId.myList,
|
IsBold = true,
|
};
|
topFra.AddChidren(txetBtn);
|
|
//添加图标控件
|
Button addIconBtn = new Button
|
{
|
X = Application.GetRealWidth(304),
|
Y = Application.GetRealHeight(20),
|
Width = Application.GetMinRealAverage(28),
|
Height = Application.GetMinRealAverage(28),
|
UnSelectedImagePath = "MusicIcon/addMusic.png",
|
};
|
topFra.AddChidren(addIconBtn);
|
|
|
VerticalScrolViewLayout verticalScrolViewLayout = new VerticalScrolViewLayout
|
{
|
Y = Application.GetRealHeight(70),
|
Height = dialogFra.Height - Application.GetRealHeight(70),
|
Width = Application.GetRealWidth(344),
|
};
|
dialogFra.AddChidren(verticalScrolViewLayout);
|
addIconBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
var fileNameList = new List<string>();
|
fileNameList.Clear();
|
foreach (var stringName in A31MusicModel.Current.FileLists)
|
{
|
fileNameList.Add(stringName.ListName);
|
|
}
|
new TipView().InputBox(StringId.addNewList, "", StringId.listNameNull, StringId.listNamesSame, fileNameList, (name) =>
|
{
|
|
A31MusicModel.Current.FileLists.Add(new FileListInfo { ListName = name, });
|
A31MusicModel.Save();
|
FileView(dialog, verticalScrolViewLayout, musicInfo);
|
});
|
};
|
FileView(dialog, verticalScrolViewLayout, musicInfo);
|
|
}
|
|
void FileView(Dialog dialog, VerticalScrolViewLayout verticalScrolViewLayout, MusicInfo musicInfo)
|
{
|
verticalScrolViewLayout.RemoveAll();
|
for (int i = 0; i < A31MusicModel.Current.FileLists.Count; i++)
|
{
|
var list = A31MusicModel.Current.FileLists[i];
|
RowLayout addFlieRow = new RowLayout
|
{
|
Height = Application.GetRealHeight(78),
|
LineColor = Color.WhiteColor,
|
SubViewWidth = Application.GetRealWidth(80),//改变编辑控件宽度多少;
|
};
|
verticalScrolViewLayout.AddChidren(addFlieRow);
|
//文件图标
|
Button fileIconBtn = new Button
|
{
|
X = Application.GetRealWidth(12),
|
Y = Application.GetRealHeight(8),
|
Width = Application.GetMinRealAverage(62),
|
Height = Application.GetMinRealAverage(62),
|
UnSelectedImagePath = "MusicIcon/file.png",
|
};
|
addFlieRow.AddChidren(fileIconBtn);
|
|
//文件名控件
|
Button fileNameBtn = new Button
|
{
|
X = fileIconBtn.Right + Application.GetRealWidth(12),
|
Y = Application.GetRealHeight(29),
|
Width = Application.GetRealWidth(189),
|
Height = Application.GetRealHeight(20),
|
TextColor = Color.TextColor,
|
TextSize = TextSize.Text14,
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = list.ListName,
|
};
|
addFlieRow.AddChidren(fileNameBtn);
|
|
///编辑控件
|
var editBtn = new Button
|
{
|
BackgroundColor = Color.MusicEditColor,
|
Text = Language.StringByID(StringId.editMusic),
|
TextColor = Color.WhiteColor,
|
TextSize = TextSize.Text16,
|
};
|
addFlieRow.AddRightView(editBtn);
|
|
editBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
|
var fileNameList = new List<string>();
|
fileNameList.Clear();
|
foreach (var stringName in A31MusicModel.Current.FileLists)
|
{
|
fileNameList.Add(stringName.ListName);
|
|
}
|
new TipView().InputBox(StringId.modifyName, list.ListName, StringId.listNameNull, StringId.listNamesSame, fileNameList, (name) =>
|
{
|
|
if (list.ListName != name)
|
{ ///修改名称不一样更新保存
|
list.ListName = name;
|
fileNameBtn.Text = name;
|
A31MusicModel.Save();
|
}
|
});
|
|
};
|
|
///删除控件
|
var delBtn = new Button
|
{
|
BackgroundColor = Color.MusicDelColor,
|
Text = Language.StringByID(StringId.delMusic),
|
TextColor = Color.WhiteColor,
|
TextSize = TextSize.Text16,
|
};
|
addFlieRow.AddRightView(delBtn);
|
delBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
new View.TipView().TipBox(StringId.tip, StringId.delMusicFile, () =>
|
{
|
addFlieRow.RemoveFromParent();
|
A31MusicModel.Current.FileLists.Remove(list);
|
A31MusicModel.Save();
|
});
|
};
|
|
EventHandler<MouseEventArgs> click = (sender, e) =>
|
{
|
|
if (null == list.MusicInfoList.Find((music) => music.URL == musicInfo.URL))
|
{
|
list.MusicInfoList.Add(musicInfo);
|
A31MusicModel.Save();
|
}
|
dialog.Close();
|
string msg = Language.StringByID(StringId.addMusicList) + list.ListName;
|
new PublicAssmebly().TipMsgAutoClose(msg, false);
|
};
|
fileNameBtn.MouseUpEventHandler += click;
|
addFlieRow.MouseUpEventHandler += click;
|
}
|
|
|
}
|
/// <summary>
|
/// 选中组合的播放器的界面
|
/// </summary>
|
public void PlayMergence()
|
{
|
//主控件
|
Dialog dialog = new Dialog()
|
{
|
BackgroundColor = Color.PopupBackgroundColor,
|
};
|
dialog.Show();
|
//父控件
|
FrameLayout frame = new FrameLayout { };
|
dialog.AddChidren(frame);
|
frame.MouseUpEventHandler += (sen, e) =>
|
{
|
dialog.Close();
|
};
|
//白色快父控件
|
FrameLayout dialogFra = new FrameLayout()
|
{
|
X = Application.GetRealWidth(16),
|
Y = Application.GetRealHeight(397),
|
Width = Application.GetRealWidth(344),
|
Height = Application.GetRealHeight(250),
|
BackgroundColor = Color.WhiteColor,
|
Radius = (uint)Application.GetRealHeight(12),
|
};
|
frame.AddChidren(dialogFra);
|
//显示头部信息父控件
|
FrameLayout topFra = new FrameLayout()
|
{
|
Width = Application.GetRealWidth(344),
|
Height = Application.GetRealHeight(50),
|
};
|
dialogFra.AddChidren(topFra);
|
//取消控件
|
Button cancelnBtn = new Button
|
{
|
X = Application.GetRealWidth(20),
|
Y = Application.GetRealHeight(15),
|
Width = Application.GetRealWidth(60),
|
Height = Application.GetRealHeight(20),
|
TextID = StringId.cancelMusic,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = Color.MusicNoTxetColor,
|
TextSize = TextSize.Text14,
|
};
|
topFra.AddChidren(cancelnBtn);
|
cancelnBtn.MouseUpEventHandler += (sen, e) =>
|
{
|
dialog.Close();
|
};
|
//标题控件
|
Button txetBtn = new Button
|
{
|
X = cancelnBtn.Right + Application.GetRealWidth(20),
|
Y = Application.GetRealHeight(14),
|
Width = Application.GetRealWidth(152),
|
Height = Application.GetRealHeight(22),
|
TextColor = Color.TextColor,
|
TextSize = TextSize.Text16,
|
TextAlignment = TextAlignment.Center,
|
TextID = StringId.selectedMergence,
|
IsBold = true,
|
};
|
topFra.AddChidren(txetBtn);
|
|
//确认控件
|
Button confirmBtn = new Button
|
{
|
X = Application.GetRealWidth(344 - 60 - 20),
|
Y = Application.GetRealHeight(15),
|
Width = Application.GetRealWidth(60),
|
Height = Application.GetRealHeight(20),
|
TextID = StringId.confirmMusic,
|
TextAlignment = TextAlignment.CenterRight,
|
TextColor = Color.SelectedColor,
|
TextSize = TextSize.Text14,
|
};
|
topFra.AddChidren(confirmBtn);
|
|
VerticalScrolViewLayout verticalScrolViewLayout = new VerticalScrolViewLayout
|
{
|
Y = Application.GetRealHeight(50),
|
Height = dialogFra.Height - Application.GetRealHeight(50),
|
Width = Application.GetRealWidth(344),
|
};
|
dialogFra.AddChidren(verticalScrolViewLayout);
|
var playList1 = new List<A31MusicModel>();
|
for (int i = 0; i < A31MusicModel.A31MusicModelList.Count; i++)
|
{
|
var player = A31MusicModel.A31MusicModelList[i];
|
if (!player.IsOnLine)
|
{
|
//不在线不显示;
|
continue;
|
}
|
RowLayout PlayRow = new RowLayout
|
{
|
Height = Application.GetRealHeight(50),
|
LineColor = Color.WhiteColor,
|
SubViewWidth = Application.GetRealWidth(80),//改变编辑控件宽度多少;
|
};
|
verticalScrolViewLayout.AddChidren(PlayRow);
|
|
|
//播放器名称控件
|
Button PlayNameBtn = new Button
|
{
|
X = Application.GetRealWidth(20),
|
Y = Application.GetRealHeight(15),
|
Width = Application.GetRealWidth(150),
|
Height = Application.GetRealHeight(20),
|
TextColor = Color.TextColor,
|
TextSize = TextSize.Text14,
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = player.Name,
|
};
|
PlayRow.AddChidren(PlayNameBtn);
|
|
|
//选中图标控件
|
Button selectedIconBtn = new Button
|
{
|
X = Application.GetRealWidth(303),
|
Y = Application.GetRealHeight(11),
|
Width = Application.GetMinRealAverage(28),
|
Height = Application.GetMinRealAverage(28),
|
UnSelectedImagePath = "MusicIcon/noSelectedIcon.png",
|
SelectedImagePath = "MusicIcon/selectedIcon.png",
|
};
|
PlayRow.AddChidren(selectedIconBtn);
|
|
///加大几点范围
|
Button clickBtn = new Button
|
{
|
Height = Application.GetRealHeight(50),
|
};
|
PlayRow.AddChidren(clickBtn);
|
|
clickBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
clickBtn.IsSelected = !clickBtn.IsSelected;
|
selectedIconBtn.IsSelected = clickBtn.IsSelected;
|
var musicPlayer = playList1.Find((c) => c.UniqueDeviceName == player.UniqueDeviceName);
|
if (selectedIconBtn.IsSelected)
|
{
|
if (musicPlayer == null)
|
{
|
playList1.Add(player);
|
}
|
}
|
else
|
{
|
if (musicPlayer != null)
|
{
|
playList1.Remove(player);
|
}
|
}
|
};
|
//线
|
Button lineBtn = new Button
|
{
|
Y = PlayRow.Height - 1,
|
X = Application.GetRealWidth(20),
|
Width = Application.GetRealWidth(304),
|
Height = 1,
|
BackgroundColor = Color.LineColor,
|
};
|
PlayRow.AddChidren(lineBtn);
|
}
|
confirmBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
|
|
if (playList1.Count <= 1)
|
{
|
new PublicAssmebly().TipMsgAutoClose("至少选中两个以上播放器", false);
|
return;
|
}
|
|
var playList2 = new List<A31MusicModel>();
|
for (int i = 0; i < playList1.Count; i++)
|
{
|
var musics = playList1[i];
|
if (musics.A31PlayStatus.playSource == "play")
|
{
|
playList2.Add(musics);
|
}
|
|
}
|
|
if (playList2.Count == 0)
|
{
|
SelectedPlayerView(dialog, playList1, playList1);
|
}
|
else if (playList2.Count == 1)
|
{
|
dialog.Close();
|
var player = playList2[0];
|
Threading(player, playList1);
|
}
|
else
|
{
|
SelectedPlayerView(dialog, playList1, playList2);
|
}
|
};
|
}
|
/// <summary>
|
/// 选中主播放器的界面
|
/// </summary>
|
/// <param name="musicList1">显示将要组合的播放器列表</param>
|
/// /// <param name="musicList2">显示在播放音乐播放器列表</param>
|
void SelectedPlayerView(Dialog dialogF, List<A31MusicModel> musicList1, List<A31MusicModel> musicList2)
|
{
|
|
//主控件
|
Dialog dialog = new Dialog()
|
{
|
//BackgroundColor = Color.PopupBackgroundColor,
|
};
|
dialog.Show();
|
//父控件
|
FrameLayout frame = new FrameLayout { };
|
dialog.AddChidren(frame);
|
frame.MouseUpEventHandler += (sen, e) =>
|
{
|
dialog.Close();
|
};
|
//白色快父控件
|
FrameLayout dialogFra = new FrameLayout()
|
{
|
X = Application.GetRealWidth(16),
|
Y = Application.GetRealHeight(397),
|
Width = Application.GetRealWidth(344),
|
Height = Application.GetRealHeight(250),
|
BackgroundColor = Color.WhiteColor,
|
Radius = (uint)Application.GetRealHeight(12),
|
};
|
frame.AddChidren(dialogFra);
|
//显示头部信息父控件
|
FrameLayout topFra = new FrameLayout()
|
{
|
Width = Application.GetRealWidth(344),
|
Height = Application.GetRealHeight(50),
|
};
|
dialogFra.AddChidren(topFra);
|
//取消控件
|
Button cancelnBtn = new Button
|
{
|
X = Application.GetRealWidth(20),
|
Y = Application.GetRealHeight(15),
|
Width = Application.GetRealWidth(60),
|
Height = Application.GetRealHeight(20),
|
TextID = StringId.cancelMusic,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = Color.MusicNoTxetColor,
|
TextSize = TextSize.Text14,
|
};
|
topFra.AddChidren(cancelnBtn);
|
cancelnBtn.MouseUpEventHandler += (sen, e) =>
|
{
|
dialog.Close();
|
};
|
//标题控件
|
Button txetBtn = new Button
|
{
|
X = cancelnBtn.Right + Application.GetRealWidth(20),
|
Y = Application.GetRealHeight(14),
|
Width = Application.GetRealWidth(152),
|
Height = Application.GetRealHeight(22),
|
TextColor = Color.TextColor,
|
TextSize = TextSize.Text16,
|
TextAlignment = TextAlignment.Center,
|
TextID = StringId.readyPlay,
|
IsBold = true,
|
};
|
topFra.AddChidren(txetBtn);
|
//确认控件
|
Button confirmBtn = new Button
|
{
|
X = Application.GetRealWidth(344 - 60 - 20),
|
Y = Application.GetRealHeight(15),
|
Width = Application.GetRealWidth(60),
|
Height = Application.GetRealHeight(20),
|
TextID = StringId.confirmMusic,
|
TextAlignment = TextAlignment.CenterRight,
|
TextColor = Color.SelectedColor,
|
TextSize = TextSize.Text14,
|
};
|
topFra.AddChidren(confirmBtn);
|
|
VerticalScrolViewLayout verticalScrolViewLayout = new VerticalScrolViewLayout
|
{
|
Y = Application.GetRealHeight(50),
|
Height = dialogFra.Height - Application.GetRealHeight(50),
|
Width = Application.GetRealWidth(344),
|
};
|
dialogFra.AddChidren(verticalScrolViewLayout);
|
//记录选中状态
|
Button selectedBtn = new Button() { Name = "No" };
|
for (int i = 0; i < musicList2.Count; i++)
|
{
|
var player = musicList2[i];
|
RowLayout addFlieRow = new RowLayout
|
{
|
Height = Application.GetRealHeight(50),
|
LineColor = Color.WhiteColor,
|
};
|
verticalScrolViewLayout.AddChidren(addFlieRow);
|
|
//播放器名称控件
|
Button PlayNameBtn = new Button
|
{
|
X = Application.GetRealWidth(20),
|
Y = Application.GetRealHeight(15),
|
Width = Application.GetRealWidth(150),
|
Height = Application.GetRealHeight(20),
|
TextColor = Color.TextColor,
|
TextSize = TextSize.Text14,
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = player.Name,
|
};
|
addFlieRow.AddChidren(PlayNameBtn);
|
|
//选中图标控件
|
Button selectedIconBtn = new Button
|
{
|
X = Application.GetRealWidth(303),
|
Y = Application.GetRealHeight(11),
|
Width = Application.GetMinRealAverage(28),
|
Height = Application.GetMinRealAverage(28),
|
UnSelectedImagePath = "MusicIcon/noSelectedIcon.png",
|
SelectedImagePath = "MusicIcon/selectedIcon.png",
|
Tag = player,
|
};
|
addFlieRow.AddChidren(selectedIconBtn);
|
///加大几点范围
|
Button clickBtn = new Button
|
{
|
Height = Application.GetRealHeight(50),
|
};
|
addFlieRow.AddChidren(clickBtn);
|
clickBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
selectedBtn.IsSelected = false;
|
selectedBtn = selectedIconBtn;
|
selectedBtn.Name = "Yes";
|
selectedBtn.IsSelected = true;
|
};
|
//线
|
Button lineBtn = new Button
|
{
|
Y = addFlieRow.Height - 1,
|
X = Application.GetRealWidth(20),
|
Width = Application.GetRealWidth(304),
|
Height = 1,
|
BackgroundColor = Color.LineColor,
|
};
|
addFlieRow.AddChidren(lineBtn);
|
}
|
|
confirmBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
if (selectedBtn.Name.ToString() == "No")
|
{
|
new PublicAssmebly().TipMsgAutoClose("还没选中播放器", false);
|
return;
|
}
|
dialogF.Close();
|
dialog.Close();
|
|
var serverMusic = selectedBtn.Tag as A31MusicModel;
|
Threading(serverMusic, musicList1);
|
};
|
|
}
|
|
/// <summary>
|
/// 发送组合命令逻辑处理的方法
|
/// </summary>
|
/// <param name="serverMusic">主播放器</param>
|
/// <param name="musicList1"></param>
|
void Threading(A31MusicModel serverMusic, List<A31MusicModel> musicList1)
|
{
|
MusicMain.loading.Start("配置中...");
|
bool _if = false;
|
System.Threading.Tasks.Task.Run(() =>
|
{
|
try
|
{
|
var statusEx = SendMethod.OpenWeb("http://" + serverMusic.IPAddress + "/httpapi.asp?command=getStatusEx");
|
if (statusEx == null)
|
{
|
statusEx = SendMethod.OpenWeb("http://" + serverMusic.IPAddress + "/httpapi.asp?command=getStatusEx");
|
}
|
if (statusEx == null)
|
{
|
return;
|
}
|
var serverIfon = Newtonsoft.Json.JsonConvert.DeserializeObject<A31Wifi>(statusEx);
|
if (serverIfon == null)
|
{
|
return;
|
}
|
string ssid = "";
|
foreach (var b in serverIfon.ssid)
|
{
|
ssid += System.Convert.ToString(b, 16).ToUpper().Length < 2 ? "0" + System.Convert.ToString(b, 16).ToUpper() : System.Convert.ToString(b, 16).ToUpper();
|
}
|
System.Threading.Thread.Sleep(1000);
|
for (int i = 0; i < musicList1.Count; i++)
|
{
|
var clientMusic = musicList1[i];
|
if (clientMusic.UniqueDeviceName == serverMusic.UniqueDeviceName)
|
{
|
//过滤掉主播放器;
|
continue;
|
}
|
System.Threading.Thread.Sleep(1000);//等待一秒再发数据
|
if (null == SendMethod.OpenWeb("http://" + clientMusic.IPAddress + "/httpapi.asp?command=ConnectMasterAp:ssid=" + ssid + ":ch=" + serverIfon.WifiChannel + ":auth=OPEN:encry=NONE:pwd=:chext=0:JoinGroupMaster:eth" + serverIfon.eth2 + ":wifi" + serverIfon.ra0 + ":uuid" + serverIfon.uuid))
|
{
|
if (null == SendMethod.OpenWeb("http://" + clientMusic.IPAddress + "/httpapi.asp?command=ConnectMasterAp:ssid=" + ssid + ":ch=" + serverIfon.WifiChannel + ":auth=OPEN:encry=NONE:pwd=:chext=0:JoinGroupMaster:eth" + serverIfon.eth2 + ":wifi" + serverIfon.ra0 + ":uuid" + serverIfon.uuid))
|
{
|
|
}
|
}
|
}
|
DateTime dateTime = DateTime.Now;
|
while ((DateTime.Now - dateTime).TotalMilliseconds < 12 * 1000)
|
{
|
System.Threading.Thread.Sleep(1000);
|
try
|
{
|
var result = SendMethod.OpenWeb("http://" + serverMusic.IPAddress + "/httpapi.asp?command=multiroom:getSlaveList");
|
if (result != null && result != "Failed")
|
{
|
var tmepSlaves = Newtonsoft.Json.JsonConvert.DeserializeObject<Slaves>(result);
|
if (tmepSlaves != null && tmepSlaves.slave_list != null && tmepSlaves.slave_list.Count != 0)
|
{
|
string str = serverMusic.Name;
|
for (int j = 0; j < A31MusicModel.A31MusicModelList.Count; j++)
|
{
|
var music = A31MusicModel.A31MusicModelList[j];
|
if (music.UniqueDeviceName == serverMusic.UniqueDeviceName)
|
{
|
|
music.ServerClientType = 1;
|
music.Slave = tmepSlaves;
|
//过滤掉主播放器;
|
continue;
|
}
|
var slave_Ifon = tmepSlaves.slave_list.Find((obj) => obj.uuid.Replace("uuid:", "") == music.UniqueDeviceName);
|
if (null != slave_Ifon)
|
{
|
str = str + "+" + slave_Ifon.name;
|
//已经添加成功
|
music.ServerClientType = -1;
|
music.IsCanShow = false;
|
music.IsOnLine = false;
|
music.IPAddress = slave_Ifon.ip;
|
music.MainPlayIP = serverMusic.IPAddress;
|
_if = true;
|
}
|
}
|
serverMusic.MainPlayName = str;
|
A31MusicModel.Save();
|
break;
|
}
|
}
|
|
|
}
|
catch { }
|
}
|
}
|
catch { }
|
finally
|
{
|
Application.RunOnMainThread(() =>
|
{
|
MusicMain.loading.Hide();
|
///可以提示配置失败;
|
if (_if)
|
{
|
//配置成功才可以刷新界面
|
MainPage.BasePageView.RemoveViewByTag("MusicMain");
|
var musicMain = new MusicMain();
|
MainPage.BasePageView.AddChidren(musicMain);
|
musicMain.Show();
|
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
}
|
});
|
}
|
});
|
|
}
|
/// <summary>
|
/// 分开组合的播放器的界面
|
/// </summary>
|
public void DetachPlayMergence(A31MusicModel a31player)
|
{
|
//主控件
|
Dialog dialog = new Dialog()
|
{
|
BackgroundColor = Color.PopupBackgroundColor,
|
};
|
dialog.Show();
|
//父控件
|
FrameLayout frame = new FrameLayout { };
|
dialog.AddChidren(frame);
|
frame.MouseUpEventHandler += (sen, e) =>
|
{
|
dialog.Close();
|
};
|
//白色快父控件
|
FrameLayout dialogFra = new FrameLayout()
|
{
|
X = Application.GetRealWidth(16),
|
Y = Application.GetRealHeight(397),
|
Width = Application.GetRealWidth(344),
|
Height = Application.GetRealHeight(250),
|
BackgroundColor = Color.WhiteColor,
|
Radius = (uint)Application.GetRealHeight(12),
|
};
|
frame.AddChidren(dialogFra);
|
//显示头部信息父控件
|
FrameLayout topFra = new FrameLayout()
|
{
|
Width = Application.GetRealWidth(344),
|
Height = Application.GetRealHeight(50),
|
};
|
dialogFra.AddChidren(topFra);
|
//取消控件
|
Button cancelnBtn = new Button
|
{
|
X = Application.GetRealWidth(20),
|
Y = Application.GetRealHeight(15),
|
Width = Application.GetRealWidth(60),
|
Height = Application.GetRealHeight(20),
|
TextID = StringId.cancelMusic,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = Color.MusicNoTxetColor,
|
TextSize = TextSize.Text14,
|
};
|
topFra.AddChidren(cancelnBtn);
|
cancelnBtn.MouseUpEventHandler += (sen, e) =>
|
{
|
dialog.Close();
|
};
|
//标题控件
|
Button txetBtn = new Button
|
{
|
X = cancelnBtn.Right + Application.GetRealWidth(20),
|
Y = Application.GetRealHeight(14),
|
Width = Application.GetRealWidth(152),
|
Height = Application.GetRealHeight(22),
|
TextColor = Color.TextColor,
|
TextSize = TextSize.Text16,
|
TextAlignment = TextAlignment.Center,
|
//TextID = StringId.selectedMergence,
|
IsBold = true,
|
Text= a31player.Name,
|
};
|
topFra.AddChidren(txetBtn);
|
|
//确认控件
|
Button confirmBtn = new Button
|
{
|
X = Application.GetRealWidth(344 - 60 - 20),
|
Y = Application.GetRealHeight(15),
|
Width = Application.GetRealWidth(60),
|
Height = Application.GetRealHeight(20),
|
TextID = StringId.confirmMusic,
|
TextAlignment = TextAlignment.CenterRight,
|
TextColor = Color.SelectedColor,
|
TextSize = TextSize.Text14,
|
};
|
topFra.AddChidren(confirmBtn);
|
|
VerticalScrolViewLayout verticalScrolViewLayout = new VerticalScrolViewLayout
|
{
|
Y = Application.GetRealHeight(50),
|
Height = dialogFra.Height - Application.GetRealHeight(50),
|
Width = Application.GetRealWidth(344),
|
};
|
dialogFra.AddChidren(verticalScrolViewLayout);
|
var slaveList= new List<Slave>();
|
for (int i = 0; i < a31player.Slave.slave_list.Count; i++)
|
{
|
var slave = a31player.Slave.slave_list[i];
|
RowLayout PlayRow = new RowLayout
|
{
|
Height = Application.GetRealHeight(50),
|
LineColor = Color.WhiteColor,
|
SubViewWidth = Application.GetRealWidth(80),//改变编辑控件宽度多少;
|
};
|
verticalScrolViewLayout.AddChidren(PlayRow);
|
|
|
//播放器名称控件
|
Button PlayNameBtn = new Button
|
{
|
X = Application.GetRealWidth(20),
|
Y = Application.GetRealHeight(15),
|
Width = Application.GetRealWidth(150),
|
Height = Application.GetRealHeight(20),
|
TextColor = Color.TextColor,
|
TextSize = TextSize.Text14,
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = slave.name,
|
};
|
PlayRow.AddChidren(PlayNameBtn);
|
|
|
//选中图标控件
|
Button selectedIconBtn = new Button
|
{
|
X = Application.GetRealWidth(303),
|
Y = Application.GetRealHeight(11),
|
Width = Application.GetMinRealAverage(28),
|
Height = Application.GetMinRealAverage(28),
|
UnSelectedImagePath = "MusicIcon/noSelectedIcon.png",
|
SelectedImagePath = "MusicIcon/selectedIcon.png",
|
};
|
PlayRow.AddChidren(selectedIconBtn);
|
|
///加大几点范围
|
Button clickBtn = new Button
|
{
|
Height = Application.GetRealHeight(50),
|
Tag = slave.uuid.Replace("uuid:", ""),
|
};
|
PlayRow.AddChidren(clickBtn);
|
|
clickBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
clickBtn.IsSelected = !clickBtn.IsSelected;
|
selectedIconBtn.IsSelected = clickBtn.IsSelected;
|
var uuid = slaveList.Find((obj) => obj.uuid.Replace("uuid:", "") == clickBtn.Tag.ToString());
|
if (selectedIconBtn.IsSelected)
|
{
|
if (uuid == null)
|
{
|
slaveList.Add(slave);
|
}
|
}
|
else
|
{
|
if (uuid != null)
|
{
|
slaveList.Remove(slave);
|
}
|
}
|
};
|
//线
|
Button lineBtn = new Button
|
{
|
Y = PlayRow.Height - 1,
|
X = Application.GetRealWidth(20),
|
Width = Application.GetRealWidth(304),
|
Height = 1,
|
BackgroundColor = Color.LineColor,
|
};
|
PlayRow.AddChidren(lineBtn);
|
}
|
confirmBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
if (slaveList.Count == 0)
|
{
|
new PublicAssmebly().TipMsgAutoClose("还没有选择解除组播放器", false);
|
return;
|
}
|
dialog.Close();
|
|
MusicMain.loading.Start("解除中...");
|
bool _if = false;
|
System.Threading.Tasks.Task.Run(() =>
|
{
|
try
|
{
|
for (int i = 0; i < slaveList.Count; i++)
|
{
|
var clientMusic = slaveList[i];
|
if (null == SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:SlaveKickout:" + clientMusic.ip))
|
{
|
if (null == SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:SlaveKickout:" + clientMusic.ip))
|
{
|
|
}
|
}
|
System.Threading.Thread.Sleep(2000);//等待2秒再发数据
|
|
}
|
DateTime dateTime = DateTime.Now;
|
while ((DateTime.Now - dateTime).TotalMilliseconds < 10 * 1000)
|
{
|
System.Threading.Thread.Sleep(1000);
|
try
|
{
|
var result = SendMethod.OpenWeb("http://" + a31player.IPAddress + "/httpapi.asp?command=multiroom:getSlaveList");
|
if (result != null && result != "Failed")
|
{
|
var tmepSlaves = Newtonsoft.Json.JsonConvert.DeserializeObject<Slaves>(result);
|
if (tmepSlaves != null && tmepSlaves.slave_list.Count == 0)
|
{
|
_if = true;//解除成功
|
A31MusicModel.Save();
|
break;
|
}
|
}
|
|
|
}
|
catch { }
|
}
|
}
|
catch { }
|
finally
|
{
|
Application.RunOnMainThread(() =>
|
{
|
MusicMain.loading.Hide();
|
///可以提示解除失败;
|
if (_if)
|
{
|
//解除成功才可以刷新界面
|
MainPage.BasePageView.RemoveViewByTag("MusicMain");
|
var musicMain = new MusicMain();
|
MainPage.BasePageView.AddChidren(musicMain);
|
musicMain.Show();
|
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
}
|
});
|
}
|
});
|
|
};
|
}
|
}
|
[System.Serializable]
|
public class A31Wifi
{
|
public string ssid;
public string WifiChannel;
public string uuid;
public string eth2;
public string ra0;
public string upnp_uuid;
|
public string firmware;
|
public string language;
|
public string MAC;
|
public string Release;
|
public string psk;
|
public string SSIDStrategy;
|
public string netstat;
|
public string apcli0;
|
}
|
|
|
}
|