Files
MercuryConverter/UI/Views/Selection/Selection.axaml.cs
T

69 lines
1.9 KiB
C#
Raw Normal View History

2025-08-08 02:00:48 -07:00
using Microsoft.VisualBasic;
2025-08-06 17:03:37 -07:00
using System;
2025-08-07 17:41:58 -07:00
using System.Collections.ObjectModel;
2025-08-06 17:03:37 -07:00
using System.Collections.Specialized;
2025-08-08 02:00:48 -07:00
using System.Threading.Tasks;
2025-08-06 17:03:37 -07:00
using Avalonia.Controls;
2025-08-07 17:41:58 -07:00
using MercuryConverter.Data;
2025-08-08 02:00:48 -07:00
using Avalonia;
2025-08-19 01:47:03 -07:00
using Avalonia.Threading;
using Avalonia.Media;
using System.IO;
using Avalonia.Media.Imaging;
2025-08-06 17:03:37 -07:00
2025-08-11 23:02:15 -07:00
namespace MercuryConverter.UI.Views;
2025-08-06 17:03:37 -07:00
public partial class Selection : Panel
{
public Selection()
{
InitializeComponent();
2025-08-19 01:47:03 -07:00
ListingTable.CellPointerPressed += OnCellClicked;
2025-08-07 17:41:58 -07:00
ListingTable.SelectionMode = DataGridSelectionMode.Extended;
2025-08-08 02:00:48 -07:00
foreach (var (k, v) in Consts.NUM_SOURCE)
{
FilterSourceContainer.Children.Add(
new CheckBox
{
Name = $"FilterSourceCheckbox{k}",
Content = v,
}
);
}
foreach (var (k, v) in Consts.CATEGORY_INDEX)
{
if (k == -1)
continue;
FilterCategoryContainer.Children.Add(
new CheckBox
{
Name = $"FilterCategoryCheckbox{k}",
Content = v,
}
);
}
2025-08-19 01:47:03 -07:00
}
private void OnCellClicked(object? sender, DataGridCellPointerPressedEventArgs e)
{
Console.WriteLine($"{e.PointerPressedEventArgs.KeyModifiers} - {e.Cell}");
2025-08-08 02:00:48 -07:00
2025-08-19 01:47:03 -07:00
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;
});
}
2025-08-06 17:03:37 -07:00
}
}