|
@@ -114,7 +114,7 @@ namespace InABox.Avalonia
|
|
|
AllItems.CollectionChanged += (sender, args) => ItemsChanged(AllItems);
|
|
|
// EnableSynchronization(AllItems);
|
|
|
|
|
|
- Items = new CoreObservableCollection<TItem>();
|
|
|
+ //Items = new CoreObservableCollection<TItem>();
|
|
|
// EnableSynchronization(Items);
|
|
|
|
|
|
Reset();
|
|
@@ -220,7 +220,7 @@ namespace InABox.Avalonia
|
|
|
{
|
|
|
Loaded = false;
|
|
|
AllItems.Clear();
|
|
|
- Items.Clear();
|
|
|
+ //Items.Clear();
|
|
|
Images.Clear();
|
|
|
}
|
|
|
|
|
@@ -233,7 +233,7 @@ namespace InABox.Avalonia
|
|
|
// force = force || Host.Status == ConnectionStatus.Connected;
|
|
|
|
|
|
var selectedIDs = SelectedItems.Select(x => x.ID).ToHashSet();
|
|
|
- Items.Clear();
|
|
|
+ //Items.Clear();
|
|
|
|
|
|
var dataFileName = DataFileName();
|
|
|
if (!force && !Loaded && CoreRepository.IsCached(dataFileName))
|
|
@@ -316,9 +316,9 @@ namespace InABox.Avalonia
|
|
|
|
|
|
private CoreTable _table = new CoreTable();
|
|
|
|
|
|
- public CoreObservableCollection<TItem> Items { get; private set; }
|
|
|
+ public IEnumerable<TItem> Items => SearchAndSort();
|
|
|
|
|
|
- public int ItemCount => Items.Count;
|
|
|
+ public int ItemCount => Items.Count();
|
|
|
|
|
|
IEnumerable ICoreRepository.Items => Items;
|
|
|
|
|
@@ -413,26 +413,30 @@ namespace InABox.Avalonia
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public ICoreRepository Search()
|
|
|
+ private TItem[] SearchAndSort()
|
|
|
{
|
|
|
- List<TItem> items;
|
|
|
+ List<TItem> _result;
|
|
|
if (AllItems != null)
|
|
|
{
|
|
|
if (SearchPredicate != null)
|
|
|
{
|
|
|
var search = AllItems.Where(SearchPredicate);
|
|
|
- items = new List<TItem>(search);
|
|
|
+ _result = new List<TItem>(search);
|
|
|
}
|
|
|
else
|
|
|
- items = new List<TItem>(AllItems);
|
|
|
+ _result = new List<TItem>(AllItems);
|
|
|
}
|
|
|
else
|
|
|
- items = new List<TItem>();
|
|
|
+ _result = new List<TItem>();
|
|
|
|
|
|
if (SortPredicate != null)
|
|
|
- items = SortPredicate(items);
|
|
|
+ _result = SortPredicate(_result);
|
|
|
|
|
|
- Items.ReplaceRange(items);
|
|
|
+ return _result.ToArray();
|
|
|
+ }
|
|
|
+
|
|
|
+ public ICoreRepository Search()
|
|
|
+ {
|
|
|
OnPropertyChanged(nameof(Items));
|
|
|
OnPropertyChanged(nameof(ItemCount));
|
|
|
return this;
|