aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.SharedUI/Components/SelectedObjectCollection.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Tango.SharedUI/Components/SelectedObjectCollection.cs')
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Components/SelectedObjectCollection.cs44
1 files changed, 6 insertions, 38 deletions
diff --git a/Software/Visual_Studio/Tango.SharedUI/Components/SelectedObjectCollection.cs b/Software/Visual_Studio/Tango.SharedUI/Components/SelectedObjectCollection.cs
index 8aa087ed3..e09bb832e 100644
--- a/Software/Visual_Studio/Tango.SharedUI/Components/SelectedObjectCollection.cs
+++ b/Software/Visual_Studio/Tango.SharedUI/Components/SelectedObjectCollection.cs
@@ -10,69 +10,37 @@ namespace Tango.SharedUI.Components
{
public class SelectedObjectCollection<T> : ObservableCollection<SelectedObject<T>>
{
- private Func<T, T, bool> _compareFunc;
-
public event EventHandler SelectionChanged;
public ObservableCollection<T> Source { get; set; }
public ObservableCollection<T> SynchedSource { get; set; }
- public SelectedObjectCollection(ObservableCollection<T> source, ObservableCollection<T> synchedSource, Func<T, T, bool> compareFunc)
+ public SelectedObjectCollection(ObservableCollection<T> source, ObservableCollection<T> synchedSource)
{
- _compareFunc = compareFunc;
-
SynchedSource = synchedSource;
Source = source;
foreach (var item in source)
{
- var selectedItem = new SelectedObject<T>(item, _compareFunc == null ? synchedSource.Contains(item) : synchedSource.ToList().Exists(x => _compareFunc(x, item)));
+ var selectedItem = new SelectedObject<T>(item, synchedSource.Contains(item));
this.Add(selectedItem);
selectedItem.IsSelectedChanged += SelectedItem_IsSelectedChanged;
}
}
- public SelectedObjectCollection(ObservableCollection<T> source, ObservableCollection<T> synchedSource) : this(source, synchedSource, null)
- {
-
- }
-
private void SelectedItem_IsSelectedChanged(object sender, EventArgs e)
{
SelectedObject<T> item = sender as SelectedObject<T>;
-
+
if (item.IsSelected)
{
- if (_compareFunc == null)
+ if (!SynchedSource.Contains(item.Data))
{
- if (!SynchedSource.Contains(item.Data))
- {
- SynchedSource.Add(item.Data);
- }
- }
- else
- {
- if (!SynchedSource.ToList().Exists(x => _compareFunc(x, item.Data)))
- {
- SynchedSource.Add(item.Data);
- }
+ SynchedSource.Add(item.Data);
}
}
else
{
- if (_compareFunc == null)
- {
- SynchedSource.Remove(item.Data);
- }
- else
- {
- foreach (var s in SynchedSource.ToList())
- {
- if (_compareFunc(s, item.Data))
- {
- SynchedSource.Remove(s);
- }
- }
- }
+ SynchedSource.Remove(item.Data);
}
SelectionChanged?.Invoke(this, new EventArgs());