陈嘉乐
2020-05-21 e67e42de58795da31b10f19775e5af46e3d14b44
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
using System;
using System.Collections.Generic;
using Shared;
namespace HDL_ON.UI.Music
{
    public class A31MyList : FrameLayout
    {
        public A31MyList()
        {
            Tag = "Music";
        }
        VerticalScrolViewLayout middViewLayout;
        public void Show()
        {
            this.BackgroundColor = Color.ViewColor;
            var topView = new TopView();
            this.AddChidren(topView.TopFLayoutView());
            topView.topNameBtn.TextID = StringId.myList;
            topView.clickBackBtn.MouseUpEventHandler += (sender, e) =>
            {
                this.RemoveFromParent();
            };
 
           
            Button addIconBtn = new Button
            {
                X = Application.GetRealWidth(336),
                Y = Application.GetRealHeight(30),
                Width = Application.GetMinRealAverage(28),
                Height = Application.GetMinRealAverage(28),
                UnSelectedImagePath = "MusicIcon/addMusic.png",
            };
            topView.TopFLayoutView().AddChidren(addIconBtn);
            addIconBtn.MouseUpEventHandler += (sender, e) =>
            {
                var fileNameList = new List<string>();
                fileNameList.Clear();
                foreach (var stringName in A31MusicModel.Current.FileLists)
                {
                    fileNameList.Add(stringName.ListName);
 
                }
                new View.TipView().InputBox(StringId.addNewList, "", StringId.listNameNull, StringId.listNamesSame, fileNameList, (name) =>
                {
 
                    A31MusicModel.Current.FileLists.Add(new FileListInfo { ListName = name, });
                    A31MusicModel.Save();
                    FileView();
                });
            };
 
            middViewLayout = new VerticalScrolViewLayout
            {
                BackgroundColor = Color.WhiteColor,
                Y = topView.fLayout.Bottom,
                Height = Application.GetRealHeight(H_W.H - H_W.T_Height),
            };
            this.AddChidren(middViewLayout);
            FileView();
 
 
 
        }
        /// <summary>
        ///
        /// </summary>
        void FileView()
        {
            middViewLayout.RemoveAll();
            for (int i = 0; i < A31MusicModel.Current.FileLists.Count; i++)
            {
                var list = A31MusicModel.Current.FileLists[i];
                RowLayout addFlieRow = new RowLayout
                {
                    Height = Application.GetRealHeight(122),
                    LineColor = Color.WhiteColor,
                    SubViewWidth = Application.GetRealWidth(90),//改变编辑控件宽度多少;
                };
                middViewLayout.AddChidren(addFlieRow);
                //文件图标
                Button fileIconBtn = new Button
                {
                    X = Application.GetRealWidth(16),
                    Y = Application.GetRealHeight(8),
                    Width = Application.GetMinRealAverage(106),
                    Height = Application.GetMinRealAverage(106),
                    UnSelectedImagePath = "MusicIcon/fileList.png",
                };
                addFlieRow.AddChidren(fileIconBtn);
                //播放/暂停图标
                Button playIconBtn = new Button
                {
                    X = Application.GetRealWidth(94),
                    Y = Application.GetRealHeight(86),
                    Width = Application.GetMinRealAverage(24),
                    Height = Application.GetMinRealAverage(24),
                    UnSelectedImagePath = "MusicIcon/filePause.png",
                    SelectedImagePath = "MusicIcon/filePlay.png",
                };
                addFlieRow.AddChidren(playIconBtn);
 
                playIconBtn.MouseUpEventHandler += (sender, e) =>
                {
                    //点击按钮随机播放音乐
                };
                //文件名控件
                Button fileNameBtn = new Button
                {
                    X = fileIconBtn.Right + Application.GetRealWidth(16),
                    Y = Application.GetRealHeight(51),
                    Width = Application.GetRealWidth(217),
                    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 View.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();
                    });
                };
 
 
                Button clickBtn = new Button
                {
                    X = fileIconBtn.Right + Application.GetRealWidth(16),
                    Width = Application.GetRealWidth(375 - 138),
                    Height = Application.GetRealHeight(122),
                };
                addFlieRow.AddChidren(clickBtn);
                clickBtn.MouseUpEventHandler += (sender, e) =>
                {
                    A31MyListMusic a31MyListMusic = new A31MyListMusic();
                    MainPage.BasePageView.AddChidren(a31MyListMusic);
                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                    a31MyListMusic.Show(list);
                    a31MyListMusic.UpdateSelectedMusic();
                };
 
            }
        }
 
    }
}