using System;
using System.Collections.Generic;
using Shared;
namespace HDL_ON.UI.Music.View
{
public class DialogView
{
///
///弹窗文件夹列表界面
///
///
public void FieListView(SongInfo musicInfo)
{
#region
//主控件
Dialog dialog = new Dialog()
{
BackgroundColor = MusicColor.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 = MusicColor.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 = MusicColor.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 = MusicColor.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.GetRealWidth(28),
Height = Application.GetRealWidth(28),
UnSelectedImagePath = "MusicIcon/addMusic.png",
};
topFra.AddChidren(addIconBtn);
#endregion
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();
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, SongInfo 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 = MusicColor.WhiteColor,
SubViewWidth = Application.GetRealWidth(80),//改变编辑控件宽度多少;
};
verticalScrolViewLayout.AddChidren(addFlieRow);
//文件图标
Button fileIconBtn = new Button
{
X = Application.GetRealWidth(12),
Y = Application.GetRealHeight(8),
Width = Application.GetRealWidth(62),
Height = Application.GetRealWidth(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 = MusicColor.TextColor,
TextSize = TextSize.Text14,
TextAlignment = TextAlignment.CenterLeft,
Text = list.ListName,
};
addFlieRow.AddChidren(fileNameBtn);
///编辑控件
var editBtn = new Button
{
BackgroundColor = MusicColor.MusicEditColor,
Text = Language.StringByID(StringId.editMusic),
TextColor = MusicColor.WhiteColor,
TextSize = TextSize.Text16,
};
addFlieRow.AddRightView(editBtn);
editBtn.MouseUpEventHandler += (sender, e) =>
{
var fileNameList = new List();
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 = MusicColor.MusicDelColor,
Text = Language.StringByID(StringId.delMusic),
TextColor = MusicColor.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 click = (sender, e) =>
{
if (null == list.MusicInfoList.Find((music) => music.name == musicInfo.name))
{
list.MusicInfoList.Add(musicInfo);
A31MusicModel.Save();
}
dialog.Close();
string msg = Language.StringByID(StringId.addMusicList) + list.ListName;
new PublicAssmebly().TipMsgAutoClose(msg, false);
};
fileIconBtn.MouseUpEventHandler += click;
fileNameBtn.MouseUpEventHandler += click;
addFlieRow.MouseUpEventHandler += click;
}
}
}
[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;
}
}