using System;
|
using System.Collections.Generic;
|
using Shared;
|
namespace HDL_ON.UI.Music.View
|
{
|
public class DialogView
|
{
|
public DialogView()
|
{
|
}
|
public void FieListView()
|
{
|
//主控件
|
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(verticalScrolViewLayout);
|
});
|
};
|
FileView(verticalScrolViewLayout);
|
|
}
|
|
void FileView(VerticalScrolViewLayout verticalScrolViewLayout)
|
{
|
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();
|
});
|
};
|
|
}
|
|
|
}
|
}
|
}
|