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
using System;
using System.Collections.Generic;
using Shared;
using Shared.SimpleControl;
using Shared.SimpleControl.Phone.Music;
using Shared.SimpleControl.R;
 
namespace SmartHome.UI.SimpleControl.Phone.Music
{
    class A31TidalMymusic : FrameLayout
    {
        public void Show (string listname)
        {
            AddChidren (new Button {
                Height = Application.GetRealHeight (36),
                BackgroundColor = SkinStyle.Current.MusicTopFrameLayout,
            });
 
            var topFrameLayout = new FrameLayout {
                Height = Application.GetRealHeight (100),
                Y = Application.GetRealHeight (36),
                BackgroundColor = SkinStyle.Current.MusicTopFrameLayout,
            };
 
            AddChidren (topFrameLayout);
 
            var whatnew = new Button {
                //TextID = MyInternationalizationString.Musiclike,
                Text =listname.ToUpper(),
                TextColor = SkinStyle.Current.MusicTextColor,
            };
            topFrameLayout.AddChidren (whatnew);
 
            var Search = new Button {
                Width = Application.GetMinRealAverage (60),
                Height = Application.GetMinRealAverage (80),
                X = Application.GetRealWidth (535),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "MusicIcon/seekdevice.png",
            };
            //topFrameLayout.AddChidren (Search);
            Search.MouseUpEventHandler += (sender, e) => {
 
            };
 
            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) => {
 
                RemoveFromParent ();
            };
            VerticalScrolViewLayout middle = new VerticalScrolViewLayout {
                Y = topFrameLayout.Bottom,
                Height = Application.GetRealHeight (Application.DesignHeight - 136),
                //BackgroundColor = 0xff2F2F2F,
                BackgroundColor = SkinStyle.Current.MusicVerticalScrolViewLayout,
            };
 
            AddChidren (middle);
 
            foreach (var musicInfo in A31MusicModel.Current.TidalLikelist)
            {
                var row = new RowLayout {
                    Height = Application.GetRealHeight (100),
                    LineColor = SkinStyle.Current.MusicRowLayoutLineColor,
                };
                middle.AddChidren (row);
 
                var imageBtn = new Button {
                    Width = Application.GetRealWidth (61),
                    Height = Application.GetRealHeight (61),
                    X = Application.GetRealWidth (20),
                    Gravity = Gravity.CenterVertical,
                    Radius = (uint)Application.GetRealHeight (4),
                    UnSelectedImagePath = System.IO.File.Exists (musicInfo.Image) ? musicInfo.Image : "MusicIcon/musicplay1.png",
                    Tag = musicInfo,
                };
                row.AddChidren (imageBtn);
 
                var listmusic = new Button {
                    Width = Application.GetRealWidth (400),
                    Height = Application.GetRealHeight (50),
                    Text = musicInfo.Title,
                    TextAlignment = TextAlignment.BottomLeft,
                    X = Application.GetRealWidth (100),
                    Tag = musicInfo,
                    TextColor = SkinStyle.Current.MusicTextColor,
                };
                row.AddChidren (listmusic);
 
                var artists = new Button {
                    Width = Application.GetRealWidth (400),
                    Height = Application.GetRealHeight (50),
                    TextAlignment = TextAlignment.TopLeft,
                    X = Application.GetRealWidth (100),
                    Y = listmusic.Bottom,
                    //TextColor = 0x75ffffff,
                    Text = musicInfo.Artist,
                    Tag = musicInfo,
                    TextColor = SkinStyle.Current.MusicArtistTextColor,
                };
                row.AddChidren (artists);
 
                var del = new Button {
                    TextID = MyInternationalizationString.Musicdel,
                    BackgroundColor = 0xFFFF0000,
                    Tag = musicInfo,
                };
                del.MouseUpEventHandler += (sender1, e1) => {
                    A31MusicModel.Current.TidalLikelist.Remove (del.Tag as MusicInfo);
                    row.RemoveFromParent ();
                    A31MusicModel.Save ();
                };
                row.AddRightView (del);
 
                EventHandler<MouseEventArgs> TrackMusic = (sender, e) => {
                    row.BackgroundColor = 0xffFE5E00;
                    System.Threading.Tasks.Task.Run (() => {
                        Application.RunOnMainThread (() => {
                            for (int i = MainPage.MainFrameLayout.ChildrenCount - 1; 0 <= i; i--) {
                                var view = MainPage.MainFrameLayout.GetChildren (i);
                                if (view.GetType () == typeof (A31PlayListPage)) {
                                    view.RemoveFromParent ();
                                } else {
                                    break;
                                }
                            }
                            MainPage.MainFrameLayout.RemoveAt (MainPage.MainFrameLayout.ChildrenCount - 1);
                            MainPage.MainFrameLayout.RemoveAt (MainPage.MainFrameLayout.ChildrenCount - 1);
                            MainPage.MainFrameLayout.RemoveAt (MainPage.MainFrameLayout.ChildrenCount - 1);
 
                            A31PlayMusicPage a31PlayMusicPage = new A31PlayMusicPage ();
                            MainPage.MainFrameLayout.AddChidren (a31PlayMusicPage);
                            a31PlayMusicPage.Show (new List<MusicInfo> ());
                            A31MusicModel.Current.A31PlayStatus.Title = listmusic.Text;
                            System.Threading.Tasks.Task.Run (() => {
                                A31NewPage.tidalpushList (listmusic.Tag as MusicInfo, A31MusicModel.Current.TidalLikelist);
                            });
                        });
                    });
                };
                imageBtn.MouseUpEventHandler += TrackMusic;
                listmusic.MouseUpEventHandler += TrackMusic;
                artists.MouseUpEventHandler += TrackMusic;
 
            }
 
        }
    }
}