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;
|
|
|
|
|
using Avalonia.Controls;
|
2025-08-07 17:41:58 -07:00
|
|
|
using MercuryConverter.Data;
|
2025-08-06 17:03:37 -07:00
|
|
|
|
|
|
|
|
namespace MercuryConverter.Views;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
SourceFilter.ItemsSource = new string[]{
|
|
|
|
|
"",
|
|
|
|
|
Consts.NUM_SOURCE[1],
|
|
|
|
|
Consts.NUM_SOURCE[2],
|
|
|
|
|
Consts.NUM_SOURCE[3],
|
|
|
|
|
Consts.NUM_SOURCE[4],
|
|
|
|
|
Consts.NUM_SOURCE[5],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
SongCollection.CollectionChanged += OnSongsChg;
|
|
|
|
|
DataContext = this;
|
|
|
|
|
|
|
|
|
|
// test 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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|