From 8d0eab66c083de7874994142fb428301a1287cc7 Mon Sep 17 00:00:00 2001 From: Alex <15199219+muskit@users.noreply.github.com> Date: Tue, 19 Aug 2025 01:47:03 -0700 Subject: [PATCH] wire up Selection's Sidebar Info --- UI/Dialogs/DataScanning.axaml | 2 +- UI/Dialogs/DataScanning.axaml.cs | 5 +---- UI/Views/Selection/Selection.axaml.cs | 26 +++++++++++++++++++++++++- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/UI/Dialogs/DataScanning.axaml b/UI/Dialogs/DataScanning.axaml index 4ec8fdd..39a12b2 100644 --- a/UI/Dialogs/DataScanning.axaml +++ b/UI/Dialogs/DataScanning.axaml @@ -2,8 +2,8 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:local="clr-namespace:MercuryConverter.UI.Dialogs" xmlns:progRing="clr-namespace:AvaloniaProgressRing;assembly=AvaloniaProgressRing" + xmlns:local="clr-namespace:MercuryConverter.UI.Dialogs" x:Class="MercuryConverter.UI.Dialogs.DataScanning" > diff --git a/UI/Dialogs/DataScanning.axaml.cs b/UI/Dialogs/DataScanning.axaml.cs index aefbf83..24523c7 100644 --- a/UI/Dialogs/DataScanning.axaml.cs +++ b/UI/Dialogs/DataScanning.axaml.cs @@ -29,11 +29,8 @@ public partial class DataScanning : UserControl { Task.Run(async () => { - var path = ""; // TODO: set to current/saved data path - - // Content selection + var path = ""; // TODO: set to current/saved data path (move to config?) var selectedPath = await BeginDirSelection(); - Console.WriteLine($"selectedPath=[{selectedPath}]"); if (selectedPath == "") // cancelled opening folder { diff --git a/UI/Views/Selection/Selection.axaml.cs b/UI/Views/Selection/Selection.axaml.cs index 9744bb8..22a698f 100644 --- a/UI/Views/Selection/Selection.axaml.cs +++ b/UI/Views/Selection/Selection.axaml.cs @@ -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; + }); + } } } \ No newline at end of file