JLChen
2020-06-04 6d55af8792cf8fbef0055e677b900fc352dba9a2
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
using System;
using System.Collections.Generic;
using System.Text;
using Shared;
using Shared.SimpleControl.R;
using SmartHome;
 
namespace Shared.SimpleControl.Phone.Music
{
    class A31MyList : FrameLayout
    {
        VerticalScrolViewLayout middle;
 
        public void Show (MusicInfo musicInfo = null)
        {
            this.AddChidren (new Button {
                Height = Application.GetRealHeight (36),
                BackgroundColor = SkinStyle.Current.MusicTopFrameLayout,
            });
 
            var topFrameLayout = new FrameLayout {
                Height = Application.GetRealHeight (90),
                Y = Application.GetRealHeight (36),
                BackgroundColor = SkinStyle.Current.MusicTopFrameLayout,
            };
            this.AddChidren (topFrameLayout);
 
            var btnTitle = new Button {
                TextID = MyInternationalizationString.MusicMylist,
                //TextSize = 20,
                TextColor=SkinStyle.Current.MusicTextColor,
            };
            topFrameLayout.AddChidren (btnTitle);
 
            var hdl = new Button {
                Width = Application.GetRealWidth (154),
                Height = Application.GetRealHeight (90),
                X = Application.GetRealWidth (486),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = MainPage.LogoString,
            };
            topFrameLayout.AddChidren (hdl);
 
            var back = new Button {
                Width = Application.GetRealWidth (82),
                Height = Application.GetRealHeight (89),
                X = Application.GetRealWidth (10),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "MusicIcon/HomepageBack.png",
            };
            topFrameLayout.AddChidren (back);
            back.MouseDownEventHandler += (sender, e) => {
                this.RemoveFromParent ();
            };
 
            var addfram = new FrameLayout {
                Height = Application.GetRealHeight (100),
                Y = topFrameLayout.Bottom,
                //BackgroundColor = 0xff2f2f2f,
                BackgroundColor=SkinStyle.Current.MusicMiddleBackgroundColor,
            };
            this.AddChidren (addfram);
 
            var editorListName = new EditText {
                Width = Application.GetMinReal (450),
                Height = Application.GetRealHeight (60),
                TextAlignment = TextAlignment.CenterLeft,
                X = Application.GetRealWidth (50),
                BackgroundColor =SkinStyle.Current.MusicEditTextBackgroundColor,//0xFF4D4D4D,
                PlaceholderText = Language.StringByID (MyInternationalizationString.newlist),
                PlaceholderTextColor =SkinStyle.Current.MusicEditTextPlaceholderTextColor,// 0xcccccccc,
                Gravity = Gravity.CenterVertical,
                TextColor=SkinStyle.Current.MusicTextColor,
                BorderWidth=1,
                BorderColor=SkinStyle.Current.MusicEditBorderColor,
                Radius = 1,
              
            };
            addfram.AddChidren (editorListName);
           
            var mylistadd = new Button {
                Width = Application.GetRealWidth (72),
                Height = Application.GetRealHeight (58),
                UnSelectedImagePath = "MusicIcon/add.png",
                X = Application.GetRealWidth (550),
                Gravity = Gravity.CenterVertical,
            };
            addfram.AddChidren (mylistadd);
 
            var red = new Button {
                Y = addfram.Bottom,
                Height = Application.GetRealHeight (4),
                BackgroundColor =SkinStyle.Current.MusicLineColor,// 0xff181818,
            };
            this.AddChidren (red);
 
            middle = new VerticalScrolViewLayout ();
            middle.Y = red.Bottom;
            middle.Height = Application.GetRealHeight (Application.DesignHeight - 126 - 100 - 4);
            middle.BackgroundColor = SkinStyle.Current.MusicVerticalScrolViewLayout;
            this.AddChidren (middle);
 
            mylistadd.MouseUpEventHandler += (sender, e) => {
                if (editorListName.Text == "") {
                    //列表名为空
                    new Alert (Language.StringByID (MyInternationalizationString.Tip), Language.StringByID (MyInternationalizationString.listempty),
                               Language.StringByID (MyInternationalizationString.Close)).Show ();
                    return;
                }
                foreach (ListInfo listInfo in A31MusicModel.Current.ListInfos) {
                    if (listInfo.ListName == editorListName.Text) {
                        //列表名称相同
                        new Alert (Language.StringByID (MyInternationalizationString.Tip), Language.StringByID (MyInternationalizationString.listsame),
                                   Language.StringByID (MyInternationalizationString.Close)).Show ();
                        return;
                    }
                }
 
                A31MusicModel.Current.ListInfos.Add (new ListInfo { ListName = editorListName.Text });
                A31MusicModel.Save ();
                showList (musicInfo);
            };
            showList (musicInfo);
        }
 
        void showList (MusicInfo musicInfo)
        {
            middle.RemoveAll ();
            foreach (var listInfo in A31MusicModel.Current.ListInfos) {
                RowLayout addlistrow = new RowLayout {
                    Height = Application.GetRealHeight (100),
                    LineColor = SkinStyle.Current.MusicRowLayoutLineColor,
                };
                middle.AddChidren (addlistrow);
 
                var radius = new Button {
                    Width = Application.GetRealWidth (36),
                    Height = Application.GetRealHeight (36),
                    TextAlignment = TextAlignment.CenterLeft,
                    X = Application.GetRealWidth (20),
                    UnSelectedImagePath = "MusicIcon/radius.png",
                    Gravity = Gravity.CenterVertical,
                };
                addlistrow.AddChidren (radius);
 
                var listback = new Button {
                    Width = Application.GetRealWidth (87),
                    Height = Application.GetRealHeight (100),
                    UnSelectedImagePath = "MusicIcon/Next.png",
                    SelectedImagePath = "MusicIcon/NextSelecte.png",
                    X = Application.GetRealWidth (550),
                    Gravity = Gravity.CenterVertical,
                };
                addlistrow.AddChidren (listback);
 
                var listnamet = new Button {
                    Height = Application.GetRealHeight (100),
                    TextAlignment = TextAlignment.CenterLeft,
                    X = Application.GetRealWidth (120),
                    Text = listInfo.ListName,
                    TextColor=SkinStyle.Current.MusicTextColor,
                };
                addlistrow.AddChidren (listnamet);
 
                EventHandler<MouseEventArgs> lists = (sender1, e1) => {
                    if (musicInfo == null) {
                        var tempMusicInfo = A31MusicModel.Current.ListInfos.Find ((obj) => {
                            return obj.ListName == listnamet.Text;
                        });
                        if (tempMusicInfo == null) {
                            return;
                        }
                        A31AddListMuisc a31AddListMuisc = new A31AddListMuisc ();
                        MainPage.MainFrameLayout.AddChidren (a31AddListMuisc);
                        a31AddListMuisc.Show (listnamet.Text, tempMusicInfo.MusicInfoList);
                    } else {
                        var tempMusicInfo = A31MusicModel.Current.ListInfos.Find ((obj) => {
                            return obj.ListName == listnamet.Text;
                        });
                        if (tempMusicInfo == null) {
                            return;
                        }
                        //null == tempMusicInfo.MusicInfoList.Find ((music) => { return music.Title == musicInfo.Title; })
                        var s = tempMusicInfo.MusicInfoList.Find ((music) => { return music.Title == musicInfo.Title; });
                        if (null == s) {
                            tempMusicInfo.MusicInfoList.Add (musicInfo);
                            A31MusicModel.Save ();
                        }
                        RemoveFromParent ();
                        MainPage.AddTip (Language.StringByID (MyInternationalizationString.addsuccess), 1000);
                    }
                };
                radius.MouseUpEventHandler += lists;
                listback.MouseUpEventHandler += lists;
                listnamet.MouseUpEventHandler += lists;
 
                var del = new Button {
                    TextID = MyInternationalizationString.Musicdel,
                    BackgroundColor = 0xFFFF0000,
                    Tag = listInfo.ListName,
                };
                del.MouseUpEventHandler += (sender1, e1) => {
                    for (int j = 0; j < A31MusicModel.Current.ListInfos.Count; j++) {
                        if (A31MusicModel.Current.ListInfos [j].ListName == del.Tag.ToString ()) {
                            A31MusicModel.Current.ListInfos.RemoveAt (j);
                            break;
                        }
                    }
                    addlistrow.RemoveFromParent ();
                    A31MusicModel.Save ();
                };
                addlistrow.AddRightView (del);
 
            }
        }
    }
}