mirror of
https://github.com/muskit/MercuryConverter.git
synced 2026-06-03 04:34:25 -07:00
UI work
This commit is contained in:
@@ -7,25 +7,25 @@
|
||||
>
|
||||
<DockPanel>
|
||||
<ContentControl Name="SelectionInfo" DockPanel.Dock="Right" Width="250">
|
||||
<Label Content="SelectionInfo"/>
|
||||
<StackPanel Margin="12">
|
||||
<Image Source="/Assets/jacket-placeholder.png"/>
|
||||
</StackPanel>
|
||||
</ContentControl>
|
||||
<StackPanel>
|
||||
<Expander HorizontalAlignment="Stretch" BorderThickness="0">
|
||||
<Expander.Header>
|
||||
Search/Filter
|
||||
</Expander.Header>
|
||||
<StackPanel Name="Filter">
|
||||
<TextBox />
|
||||
</StackPanel>
|
||||
</Expander>
|
||||
<DataGrid Name="ListingTable">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="ID"/>
|
||||
<DataGridTextColumn Header="Title"/>
|
||||
<DataGridTextColumn Header="Artist"/>
|
||||
<DataGridTextColumn Header="Source"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</StackPanel>
|
||||
<DockPanel Margin="0 0 8 0">
|
||||
<DockPanel Margin="0 0 0 8" DockPanel.Dock="Top">
|
||||
<ComboBox DockPanel.Dock="Right" Width="160" PlaceholderText="Source filter" Name="SourceFilter"/>
|
||||
<TextBox Margin="0 0 8 0" Watermark="Search for title, artist, charter..."/>
|
||||
</DockPanel>
|
||||
<UserControl Background="{DynamicResource DataGridContentBackground}">
|
||||
<DataGrid Name="ListingTable" IsReadOnly="True" SelectionMode="Extended" ItemsSource="{Binding SongCollection}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="ID" Width="90" Binding="{Binding Id}"/>
|
||||
<DataGridTextColumn Header="Title" Width="*" Binding="{Binding Name}"/>
|
||||
<DataGridTextColumn Header="Artist" Width="*" Binding="{Binding Artist}"/>
|
||||
<DataGridTextColumn Header="Source" Width="150" Binding="{Binding Source}"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</UserControl>
|
||||
</DockPanel>
|
||||
</DockPanel>
|
||||
</Panel>
|
||||
@@ -1,15 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using Avalonia.Controls;
|
||||
using MercuryConverter.Data;
|
||||
|
||||
namespace MercuryConverter.Views;
|
||||
|
||||
public partial class Selection : Panel
|
||||
{
|
||||
public static ObservableCollection<Song> SongCollection { get; } = new();
|
||||
public Selection()
|
||||
{
|
||||
InitializeComponent();
|
||||
Database.Songs.CollectionChanged += OnSongsChg;
|
||||
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
|
||||
SongCollection.Add(
|
||||
new Song { Id = "S00-000", Name = "A Name", Artist = "An Artist", Source = Consts.NUM_SOURCE[2] }
|
||||
);
|
||||
SongCollection.Add(
|
||||
new Song { Id = "S00-000", Name = "A Name", Artist = "An Artist", Source = Consts.NUM_SOURCE[3] }
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
private void OnSongsChg(object? sender, NotifyCollectionChangedEventArgs e)
|
||||
@@ -19,17 +42,17 @@ public partial class Selection : Panel
|
||||
if (e.NewItems != null)
|
||||
{
|
||||
Console.WriteLine("Added...");
|
||||
foreach (Data.Song added in e.NewItems)
|
||||
foreach (Song added in e.NewItems)
|
||||
{
|
||||
Console.WriteLine($"[{added.id}] {added.artist} - {added.name}");
|
||||
Console.WriteLine($"[{added.Id}] {added.Artist} - {added.Name}");
|
||||
}
|
||||
}
|
||||
if (e.OldItems != null)
|
||||
{
|
||||
Console.WriteLine("Removed...");
|
||||
foreach (Data.Song rem in e.OldItems)
|
||||
foreach (Song rem in e.OldItems)
|
||||
{
|
||||
Console.WriteLine($"[{rem.id}] {rem.artist} - {rem.name}");
|
||||
Console.WriteLine($"[{rem.Id}] {rem.Artist} - {rem.Name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user