mirror of
https://github.com/muskit/MercuryConverter.git
synced 2026-06-02 20:24:26 -07:00
wire up Selection's Sidebar Info
This commit is contained in:
@@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user