diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.SharedUI/Components/SelectedObjectCollection.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.SharedUI/Components/SelectedObjectCollection.cs | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/Software/Visual_Studio/Tango.SharedUI/Components/SelectedObjectCollection.cs b/Software/Visual_Studio/Tango.SharedUI/Components/SelectedObjectCollection.cs index 8aa087ed3..a174dc070 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Components/SelectedObjectCollection.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Components/SelectedObjectCollection.cs @@ -1,14 +1,32 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.SharedUI.Components; + +public static class ISelectedObjectCollectionExt +{ + public static IList<SelectedObject> GetItems(this ISelectedObjectCollection source) + { + return source.Cast<SelectedObject>().ToList(); + } +} namespace Tango.SharedUI.Components { - public class SelectedObjectCollection<T> : ObservableCollection<SelectedObject<T>> + public interface ISelectedObjectCollection : IEnumerable, INotifyCollectionChanged + { + event EventHandler SelectionChanged; + ObservableCollection<Object> Source { get; set; } + ObservableCollection<Object> SynchedSource { get; set; } + } + + public class SelectedObjectCollection<T> : ObservableCollection<SelectedObject<T>>, ISelectedObjectCollection { private Func<T, T, bool> _compareFunc; @@ -16,6 +34,11 @@ namespace Tango.SharedUI.Components public ObservableCollection<T> Source { get; set; } public ObservableCollection<T> SynchedSource { get; set; } + ObservableCollection<object> ISelectedObjectCollection.Source { get; set; } + ObservableCollection<object> ISelectedObjectCollection.SynchedSource { get; set; } + + public bool IsReadOnly { get; } + public SelectedObjectCollection(ObservableCollection<T> source, ObservableCollection<T> synchedSource, Func<T, T, bool> compareFunc) { _compareFunc = compareFunc; @@ -77,5 +100,25 @@ namespace Tango.SharedUI.Components SelectionChanged?.Invoke(this, new EventArgs()); } + + public void Add(SelectedObject item) + { + base.Add((SelectedObject<T>)item); + } + + public bool Contains(SelectedObject item) + { + return base.Contains((SelectedObject<T>)item); + } + + public void CopyTo(SelectedObject[] array, int arrayIndex) + { + base.CopyTo(array.Cast<SelectedObject<T>>().ToArray(), arrayIndex); + } + + public bool Remove(SelectedObject item) + { + return base.Remove((SelectedObject<T>)item); + } } } |
