57 lines
1.4 KiB
C#
57 lines
1.4 KiB
C#
using Harmonia.Core.Playlists;
|
|
using Harmonia.WinUI.ViewModels;
|
|
using Microsoft.UI.Xaml;
|
|
using Microsoft.UI.Xaml.Controls;
|
|
using Microsoft.UI.Xaml.Input;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Harmonia.WinUI.Views;
|
|
|
|
public sealed partial class PlaylistView : UserControl
|
|
{
|
|
private readonly PlaylistViewModel _viewModel;
|
|
|
|
public PlaylistView()
|
|
{
|
|
InitializeComponent();
|
|
_viewModel = (PlaylistViewModel)DataContext;
|
|
}
|
|
|
|
private void Image_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
//Image? image = sender as Image;
|
|
|
|
//if (image == null)
|
|
// return;
|
|
|
|
//image.DataContextChanged += Image_DataContextChanged;
|
|
|
|
//var song = (PlaylistSong)image.DataContext;
|
|
|
|
//if (song == null)
|
|
// return;
|
|
|
|
//Task.Run(async () => await FetchImage(song.Song, image));
|
|
}
|
|
|
|
private void Image_Unloaded(object sender, RoutedEventArgs e)
|
|
{
|
|
//Image? image = sender as Image;
|
|
|
|
//if (image == null)
|
|
// return;
|
|
|
|
//image.DataContextChanged -= Image_DataContextChanged;
|
|
}
|
|
|
|
private async void PlaylistListViewItem_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
|
|
{
|
|
if (sender is not FrameworkElement element)
|
|
return;
|
|
|
|
if (element == null || element.DataContext is not PlaylistSong playlistSong)
|
|
return;
|
|
|
|
await _viewModel.PlaySongAsync(playlistSong);
|
|
}
|
|
} |