wire up Selection's Sidebar Info

This commit is contained in:
Alex
2025-08-19 01:47:03 -07:00
parent ad446b9e91
commit 8d0eab66c0
3 changed files with 27 additions and 6 deletions
+25 -1
View File
@@ -6,6 +6,10 @@ using System.Threading.Tasks;
using Avalonia.Controls;
using MercuryConverter.Data;
using Avalonia;
using Avalonia.Threading;
using Avalonia.Media;
using System.IO;
using Avalonia.Media.Imaging;
namespace MercuryConverter.UI.Views;
@@ -14,6 +18,7 @@ public partial class Selection : Panel
public Selection()
{
InitializeComponent();
ListingTable.CellPointerPressed += OnCellClicked;
ListingTable.SelectionMode = DataGridSelectionMode.Extended;
foreach (var (k, v) in Consts.NUM_SOURCE)
@@ -39,7 +44,26 @@ public partial class Selection : Panel
}
);
}
}
// DataContext = this;
private void OnCellClicked(object? sender, DataGridCellPointerPressedEventArgs e)
{
Console.WriteLine($"{e.PointerPressedEventArgs.KeyModifiers} - {e.Cell}");
if (e.Row.DataContext is Song song)
{
Console.WriteLine($"{song.Id}: {song.Artist} - {song.Name}");
Dispatcher.UIThread.Post(() =>
{
if (song.Jacket != null)
{
var file = File.OpenRead(song.Jacket);
InfoImageJacket.Source = new Bitmap(file);
}
InfoNameText.Text = song.Name;
InfoArtistText.Text = song.Artist;
InfoSourceText.Text = song.SourceName;
});
}
}
}