陈嘉乐
2020-05-18 e29de9af8f507d288a61d9459fb3d1f72976876f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
using System;
using System.Collections.Generic;
using Shared;
namespace HDL_ON.UI.Music.View
{
    public class DialogView
    {
 
        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;
            }
 
 
        }
    }
}