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
using System;
using System.Collections.Generic;
using Shared.SimpleControl.Pad;
using Shared.SimpleControl;
using System.Text;
using Shared;
 
namespace Shared.SimpleControl.Pad.Music
{
    /// <summary>
    /// 音乐播放列表界面
    /// </summary>
    class ListPage : Shared.FrameLayout
    {
        public void Musiclist (MusicModel musicModel, List<KeyAndValue> playListmusic, string Listname, int sourceID)
        {
            var topFrameLayout = new FrameLayout () {
                Height = Application.GetRealHeight (140),
            };
            AddChidren (topFrameLayout);
 
            var titleBtn = new Button {
                BackgroundColor = 0xFF121212,
                Text = Listname,
                TextSize = 15,
            };
            topFrameLayout.AddChidren (titleBtn);
 
            var verticalScrolViewLayout = new VerticalScrolViewLayout {
                Y = Application.GetRealHeight (140),
                BackgroundColor = 0xff2F2F2F,
            };
            AddChidren (verticalScrolViewLayout);
 
            for (int i = 0; i < playListmusic.Count; i++) {
                var rowsong = new RowLayout {
                    Height = Application.GetRealHeight (100),
                };
                verticalScrolViewLayout.AddChidren (rowsong);
 
                var titleMusic = new Button {
                    Width = Application.GetRealWidth (80),
                    Height = Application.GetRealHeight (70),
                    X = Application.GetRealWidth (10),
                    Gravity = Gravity.CenterVertical,
                    UnSelectedImagePath = "MusicIcon/PlayMusic.png",
                };
                rowsong.AddChidren (titleMusic);
 
                var song = new Button {
                    Text = playListmusic [i].name,
                    TextAlignment = TextAlignment.CenterLeft,
                    X = Application.GetRealWidth (120),
                    Tag = playListmusic [i].number,
                };
                rowsong.AddChidren (song);
                song.MouseUpEventHandler += (sender, e) => {
                    rowsong.BackgroundColor = 0xffFE5E00;
                    System.Threading.Tasks.Task.Run (() => {
                        System.Threading.Thread.Sleep (200);
                        Application.RunOnMainThread (() => {
                            RemoveFromParent ();
                            Control.ControlBytesSend (Command.ControlMusicModel2, musicModel.SubnetID, musicModel.DeviceID, MusicModel.MusiceBytes ("*Z01" + sourceID + "SONG" + song.Tag + "2"), SendCount.Zero);
                        });
                    });
                };
 
                var del = new Button {
                    Text = "删除",
                    BackgroundColor = 0xFFFF0000,
                    Tag = playListmusic [i].number,
                };
                rowsong.AddRightView (del);
 
                del.MouseUpEventHandler += (sender, e) => {
                    if (sourceID == 1) {
                        for (int j = 0; j < musicModel.SDCardSongList.Count; j++) {
                            if (musicModel.SDCardSongList [j].number == del.Tag.ToString ()) {
                                musicModel.SDCardSongList.RemoveAt (j);
                                break;
                            }
                        }
                    } else if (sourceID == 2) {
                        for (int j = 0; j < musicModel.NasSongList.Count; j++) {
                            if (musicModel.NasSongList [j].number == del.Tag.ToString ()) {
                                musicModel.NasSongList.RemoveAt (j);
                                break;
                            }
                        }
                    }
                    rowsong.RemoveFromParent ();
                };
            }
        }
    }
}