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
using System;
using System.Collections.Generic;
using System.Text;
using Shared.SimpleControl.Pad;
using Shared;
using Shared.SimpleControl.R;
 
 
namespace Shared.SimpleControl.Pad.Music
{
    class Songlist : Shared.FrameLayout
    {
        int sourceId;
        public void Show (List<KeyAndValue> listmusic, MusicModel musicMode, int sourceId, FrameLayout SettingView)
        {
            this.sourceId = sourceId;
 
            AddChidren (new Button () {
                Height = Application.GetRealHeight (30),
                BackgroundColor = 0xFF262626,
            });
 
            var topFrameLayout = new FrameLayout () {
                Height = Application.GetRealHeight (100),
                Y = Application.GetRealHeight (30),
                BackgroundColor = 0xFF121212,
            };
            AddChidren (topFrameLayout);
 
            var back = new Button {
                Width = Application.GetMinRealAverage (82),
                Height = Application.GetMinRealAverage (89),
                X = Application.GetRealWidth (10),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "MusicIcon/PlayBack.png",
            };
            topFrameLayout.AddChidren (back);
            back.MouseDownEventHandler += Back_MouseDownEventHandler;
 
            var button = new Button {
                Width = Application.GetRealWidth (200),
                Height = Application.GetRealHeight (150),
                //Text = "播放列表",                
                TextID = MyInternationalizationString.Musicplaylist,
                TextSize = 15,
                X = Application.GetRealWidth (200),
                Gravity = Gravity.Center,
            };
            topFrameLayout.AddChidren (button);
 
            var Musiclist = new VerticalScrolViewLayout {
                Width = LayoutParams.MatchParent,
                Height = Application.GetRealHeight (1136 - 130),
                BackgroundImagePath = "MusicIcon/HomepageBackgroun.png",
                Y = topFrameLayout.Bottom,
            };
            this.AddChidren (Musiclist);
 
            if (listmusic == null) {
                return;
            }
            for (int i = 0; i < listmusic.Count; i++) {
 
                var rowsong = new RowLayout {
                    Width = LayoutParams.MatchParent,
                    Height = Application.GetRealHeight (100),
                };
                Musiclist.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 {
                    Width = LayoutParams.MatchParent,
                    Height = LayoutParams.MatchParent,
                    Text = listmusic [i].name,
                    TextAlignment = TextAlignment.CenterLeft,
                    X = Application.GetRealWidth (120),
                    Tag = listmusic [i].number
                };
                rowsong.AddChidren (song);
 
                song.MouseUpEventHandler += (sender, e) => {
                    rowsong.BackgroundColor = 0xffFE5E00;
                    System.Threading.Tasks.Task.Run (() => {
                        System.Threading.Thread.Sleep (50);
                        Application.RunOnMainThread (() => {
                            //先移除当前控件的前面那个控件
                            this.Parent.RemoveAt (this.Parent.ChildrenCount - 3);
                            this.Parent.RemoveAt (this.Parent.ChildrenCount - 2);
                            //当前控件界面
                            this.RemoveFromParent ();
                            PlayPage playPage = new PlayPage { };
                            MainPage.MainFrameLayout.AddChidren (playPage);
                            playPage.Show (musicMode, listmusic, SettingView);
                            playPage.SourceId = sourceId;
                            Control.ControlBytesSend (Command.ControlMusicModel2, musicMode.SubnetID, musicMode.DeviceID, MusicModel.MusiceBytes ("*Z01" + sourceId + "SONG" + song.Tag + "2"), SendCount.Zero);
                        });
                    });
                };
 
            }
        }
 
        private void Back_MouseDownEventHandler (object sender, MouseEventArgs e)
        {
            this.RemoveFromParent ();
        }
    }
}