From 12a13b4194d4497309377ce0510171611d341cb4 Mon Sep 17 00:00:00 2001 From: Alex <15199219+muskit@users.noreply.github.com> Date: Tue, 19 Aug 2025 20:01:43 -0700 Subject: [PATCH] chartinfo tweaks, add ID --- src/UI/Views/Selection/ChartInfo.axaml.cs | 2 +- src/UI/Views/Selection/Selection.axaml | 5 ++-- src/UI/Views/Selection/Selection.axaml.cs | 29 ++++++++++++++++------- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/UI/Views/Selection/ChartInfo.axaml.cs b/src/UI/Views/Selection/ChartInfo.axaml.cs index 401a293..cf379c7 100644 --- a/src/UI/Views/Selection/ChartInfo.axaml.cs +++ b/src/UI/Views/Selection/ChartInfo.axaml.cs @@ -10,7 +10,7 @@ public partial class ChartInfo : UserControl { private static readonly IReadOnlyDictionary COLORS = new Dictionary(){ {Difficulty.Normal, (new Color(0xff, 0x1b, 0x7c, 0xff), new Color(0xff, 0x3f, 0x66, 0xfa))}, - {Difficulty.Hard, (new Color(0xff, 0xFF, 0xC3, 0x00), new Color(0xff, 0xFF, 0xA0, 0x00))}, + {Difficulty.Hard, (new Color(0xff, 0xF2, 0xB5, 0x00), new Color(0xff, 0xFF, 0xA0, 0x00))}, {Difficulty.Expert, (new Color(0xff, 0xFF, 0x00, 0x84), new Color(0xff, 0xCF, 0x00, 0x5B))}, {Difficulty.Inferno, (new Color(0xff, 0x40, 0x00, 0x43), new Color(0xff, 0x1F, 0x00, 0x20))} }; diff --git a/src/UI/Views/Selection/Selection.axaml b/src/UI/Views/Selection/Selection.axaml index c32b72e..151a53d 100644 --- a/src/UI/Views/Selection/Selection.axaml +++ b/src/UI/Views/Selection/Selection.axaml @@ -19,11 +19,12 @@ + - - + + diff --git a/src/UI/Views/Selection/Selection.axaml.cs b/src/UI/Views/Selection/Selection.axaml.cs index 9087c8d..daf5b15 100644 --- a/src/UI/Views/Selection/Selection.axaml.cs +++ b/src/UI/Views/Selection/Selection.axaml.cs @@ -1,16 +1,13 @@ -using Microsoft.VisualBasic; using System; -using System.Collections.ObjectModel; -using System.Collections.Specialized; -using System.Threading.Tasks; +using System.Linq; using Avalonia.Controls; using MercuryConverter.Data; -using Avalonia; using Avalonia.Threading; -using Avalonia.Media; using System.IO; using Avalonia.Media.Imaging; using SaturnData.Notation.Core; +using System.Collections.Generic; +using UAssetAPI.UnrealTypes.EngineEnums; namespace MercuryConverter.UI.Views; @@ -20,6 +17,7 @@ public partial class Selection : Panel { InitializeComponent(); ListingTable.CellPointerPressed += OnCellClicked; + ListingTable.SelectionChanged += OnSelectionChange; ListingTable.SelectionMode = DataGridSelectionMode.Extended; foreach (var (k, v) in Consts.NUM_SOURCE) @@ -47,13 +45,25 @@ public partial class Selection : Panel } } + /// + /// Table cell right click handler. + /// + /// + /// private void OnCellClicked(object? sender, DataGridCellPointerPressedEventArgs e) { - Console.WriteLine($"{e.PointerPressedEventArgs.KeyModifiers} - {e.Cell}"); + var cell = e.Cell; + var tb = (TextBlock)cell.Content!; - if (e.Row.DataContext is Song song) + Console.WriteLine($"{e.PointerPressedEventArgs.Properties.IsRightButtonPressed} - {e.Cell.Content}"); + } + + private void OnSelectionChange(object sender, SelectionChangedEventArgs e) + { + if (e.AddedItems.Count > 0) { - Console.WriteLine($"{song.Id}: {song.Artist} - {song.Name}"); + var song = (Song) e.AddedItems[e.AddedItems.Count-1]!; + Dispatcher.UIThread.Post(() => { if (song.Jacket != null) @@ -61,6 +71,7 @@ public partial class Selection : Panel var file = File.OpenRead(song.Jacket); InfoImageJacket.Source = new Bitmap(file); } + InfoId.Text = song.Id; InfoNameText.Text = song.Name; InfoArtistText.Text = song.Artist; InfoSourceText.Text = song.SourceName;