-
Notifications
You must be signed in to change notification settings - Fork 147
/
Copy pathDataContext.cs
73 lines (59 loc) · 1.94 KB
/
DataContext.cs
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
using System.ComponentModel;
using System.Runtime.CompilerServices;
using BLiveSpotify_Plugin.Annotations;
namespace BLiveSpotify_Plugin
{
public class PlayDeviceModel
{
public string PlaylistId { get; set; }
public string PlaylistName { get; set; }
}
public class MusicModel
{
public string MusicId { get; set; }
public string MusicName { get; set; }
public string MusicArtist { get; set; }
}
public class PluginDataContext : INotifyPropertyChanged
{
private PlayDeviceModel _selectedPlayList;
public PlayDeviceModel SelectedPlayList
{
get => _selectedPlayList;
set
{
if (Equals(value, _selectedPlayList)) return;
var spotifyObj = Plugin.spotifyLib;
if (spotifyObj != null)
{
spotifyObj.playdevice = value?.PlaylistId;
spotifyObj.SaveConfig();
_selectedPlayList = value;
}
OnPropertyChanged();
}
}
private bool IsLogin => !string.IsNullOrEmpty(Plugin.spotifyLib.refresh_token);
public string LoginStatus => IsLogin ? "已登入" : "未登入";
public BLiveSpotify_Plugin Plugin { get; set; }
public bool Status
{
get => Plugin?.Status == true;
set
{
if (Plugin == null) return;
if (value)
Plugin.Start();
else
Plugin.Stop();
OnPropertyChanged();
}
}
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
public virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}