using System.Collections.Generic; using System.Windows; using System.Windows.Controls; using DominionBase; namespace Dominion.NET_WPF.Controls { /// /// Interaction logic for ucObjectList.xaml /// public partial class ucObjectList : UserControl { public static readonly DependencyProperty ObjectsProperty = DependencyProperty.Register("Objects", typeof(IEnumerable), typeof(ucObjectList), new PropertyMetadata(null)); public IEnumerable Objects { get { return (IEnumerable)GetValue(ObjectsProperty); } set { SetValue(ObjectsProperty, value); wpObjects.Children.Clear(); if (value == null) return; foreach (var obj in value) { if (obj == null) { // Let's throw in a spacer wpObjects.Children.Add(new Label { Margin = new Thickness(5, 0, 0, 0) }); } else if (obj is IDisplayable oDisp) { wpObjects.Children.Add(new ucCardIcon { Size = CardSize.Text, Card = oDisp }); } else if (obj is Token oToken) { wpObjects.Children.Add(new ucTokenIcon { Token = oToken, Margin = new Thickness(2, 5, 2, 5) }); } } } } public ucObjectList() { InitializeComponent(); } } }