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

80 lines
2.2 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-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
{
2025-08-07 17:41:58 -07:00
public static ObservableCollection<Song> SongCollection { get; } = new();
2025-08-06 17:03:37 -07:00
public Selection()
{
InitializeComponent();
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-07 17:41:58 -07:00
SongCollection.CollectionChanged += OnSongsChg;
DataContext = this;
2025-08-08 02:00:48 -07:00
// placeholder data
2025-08-08 00:08:45 -07:00
if (SongCollection.Count == 0)
{
SongCollection.Add(
new Song { Id = "S00-000", Name = "A Name", Artist = "An Artist", Source = Consts.NUM_SOURCE[2] }
);
SongCollection.Add(
new Song { Id = "S00-001", Name = "A Name", Artist = "An Artist", Source = Consts.NUM_SOURCE[3] }
);
}
2025-08-06 17:03:37 -07:00
}
private void OnSongsChg(object? sender, NotifyCollectionChangedEventArgs e)
{
Console.WriteLine("Songs collection changed!");
if (e.NewItems != null)
{
Console.WriteLine("Added...");
2025-08-07 17:41:58 -07:00
foreach (Song added in e.NewItems)
2025-08-06 17:03:37 -07:00
{
2025-08-07 17:41:58 -07:00
Console.WriteLine($"[{added.Id}] {added.Artist} - {added.Name}");
2025-08-06 17:03:37 -07:00
}
}
if (e.OldItems != null)
{
Console.WriteLine("Removed...");
2025-08-07 17:41:58 -07:00
foreach (Song rem in e.OldItems)
2025-08-06 17:03:37 -07:00
{
2025-08-07 17:41:58 -07:00
Console.WriteLine($"[{rem.Id}] {rem.Artist} - {rem.Name}");
2025-08-06 17:03:37 -07:00
}
}
}
}