wxr
2020-06-16 f6fd8acd7c53c44187e70b4709443318a628f4b5
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
using System;
using Shared;
namespace HDL_ON.UI.Music.View
{
    public class SongView
    {
        /// <summary>
        /// 父控件
        /// </summary>
        public FrameLayout musicViewFl = new FrameLayout
        {
            Width = Application.GetRealWidth(375),
            Height = Application.GetRealHeight(44),
        };
 
        /// <summary>
        /// 列表当前播放音乐图标
        /// </summary>
        public Button playIconBtn = new Button
        {
            X = Application.GetRealWidth(16),
            Y = Application.GetRealHeight(10),
            Width = Application.GetMinRealAverage(24),
            Height = Application.GetMinRealAverage(24),
            UnSelectedImagePath = "MusicIcon/playStatus.png",
            Visible = false,
            Name = "playStatus",
        };
 
        /// <summary>
        /// 歌曲控件
        /// </summary>
        public Button songBtn = new Button
        {
            X = Application.GetRealWidth(16),
            Y = Application.GetRealHeight(11),
            Width = Application.GetRealWidth(100),
            Height = Application.GetRealHeight(22),
            TextColor = Color.MusicTxet14Color,
            TextSize = TextSize.Text16,
            TextAlignment = TextAlignment.CenterLeft,
            Name = "song",
        };
 
 
 
        /// <summary>
        /// 歌手控件
        /// </summary>
        public Button singerBtn = new Button
        {
            Y = Application.GetRealHeight(11),
            Height = Application.GetRealHeight(22),
            TextColor = Color.MusicNoTxetColor,
            TextSize = TextSize.Text12,
            TextAlignment = TextAlignment.CenterLeft,
            //Text =("-" +songs.Artist).Trim(),
            Name = "singer",
        };
 
        /// <summary>
        /// 添加喜爱音乐控件
        /// </summary>
        public Button loveIcon = new Button
        {
            X = Application.GetRealWidth(291),
            Y = Application.GetRealHeight(8),
            Width = Application.GetMinRealAverage(28),
            Height = Application.GetMinRealAverage(28),
            UnSelectedImagePath = "MusicIcon/love.png",
            SelectedImagePath = "MusicIcon/loveSelected.png",
        };
 
        /// <summary>
        /// 添加到我的列表
        /// </summary>
        public Button addIcon = new Button
        {
            X = Application.GetRealWidth(335),
            Y = Application.GetRealHeight(8),
            Width = Application.GetMinRealAverage(28),
            Height = Application.GetMinRealAverage(28),
            UnSelectedImagePath = "MusicIcon/addMusic.png",
        };
        /// <summary>
        /// 点击控件
        /// </summary>
        public Button clickBtn = new Button
        {
            Width = Application.GetRealWidth(280),
            Height = Application.GetRealHeight(44),
        };
 
        /// <summary>
        /// 布局歌曲信息的View
        /// </summary>
        /// <returns></returns>
        public FrameLayout SongFrameLayout()
        {
            musicViewFl.AddChidren(playIconBtn);
            musicViewFl.AddChidren(songBtn);
            singerBtn.X = songBtn.Right;
            musicViewFl.AddChidren(singerBtn);
            musicViewFl.AddChidren(clickBtn);
            musicViewFl.AddChidren(loveIcon);
            musicViewFl.AddChidren(addIcon);
            return musicViewFl;
            /*
            View.SongView songView = new View.SongView();
            middViewLayout.AddChidren(songView.SongFrameLayout());
            songView.songBtn.Tag = songs.URL;
            if (string.IsNullOrEmpty(songs.Title))
            {
                //防止歌曲名字为空抛异常
                songs.Title = " ";
            }
            songView.songBtn.Text = songs.Title.Trim();
            var wText = songView.songBtn.GetTextWidth();//获取文本宽度
                                                        ///(歌曲+歌手)宽度最大值时280
            if (wText > 280)
            {
 
                songView.songBtn.Width = Application.GetRealWidth(280);
            }
            else
            {
                songView.songBtn.Width = wText + 5;
            }
            songView.singerBtn.X = songView.songBtn.Right;
            if (string.IsNullOrEmpty(songs.Artist))
            {
                //防止歌手名字为空抛异常
                songs.Artist = " ";
            }
            songView.singerBtn.Text = "-" + songs.Artist.Trim();
 
            songView.singerBtn.Width = Application.GetRealWidth(280 - songView.songBtn.Width);
            if (wText > 280)
            {
                ///歌名长度小于280才可以显示歌手出来
                songView.singerBtn.Width = Application.GetRealWidth(0);
            }
 
            songView.loveIcon.MouseUpEventHandler += (sender, e) =>
            {
                songView.loveIcon.IsSelected = !songView.loveIcon.IsSelected;
                if (songView.loveIcon.IsSelected)
                {
                    ///查找音乐是否存在在列表
                    var music1 = A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.URL == songs.URL);
                    if (music1 == null)
                    {
                        ///没有存在就添加
                        A31MusicModel.Current.LoveMusicInfoList.Add(songs);
                    }
                }
                else
                {
                    ///查找音乐是否存在在列表
                    var music1 = A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.URL == songs.URL);
                    if (music1 != null)
                    {
                        ///存在就删除
                        A31MusicModel.Current.LoveMusicInfoList.Remove(songs);
                    }
 
                }
                // A31MusicModel.Save();
            };
            var music = A31MusicModel.Current.LoveMusicInfoList.Find((m) => m.URL == songs.URL);
            if (music != null)
            {
                songView.loveIcon.IsSelected = true;
            }
            else
            {
                songView.loveIcon.IsSelected = false;
            }
            songView.clickBtn.Tag = number;//标记播放哪一首歌曲
            songView.clickBtn.MouseUpEventHandler += (sender, e) =>
            {
 
                System.Threading.Tasks.Task.Run(() =>
                {
                    System.Threading.Thread.Sleep(50);
                    Application.RunOnMainThread(() =>
                    {
                        //移除界面
                        A31MusicModel.Current.A31PlayStatus.Title = songView.songBtn.Text;
                        MainPage.BasePageView.RemoveViewByTag("Music");
                        //A31PlayMusicPage a31PlayMusicPage = new A31PlayMusicPage();
                        //MainPage.BasePageView.AddChidren(a31PlayMusicPage);
                        //a31PlayMusicPage.Show();
                        //MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                        System.Threading.Tasks.Task.Run(() =>
                        {
                            PlayStrinfg(songView.clickBtn.Tag);
                        });
                    });
                });
 
            };
            */
 
 
        }
 
    }
}