diff --git a/AideDeJeu/AideDeJeu/Models/Item.cs b/AideDeJeu/AideDeJeu/Models/Item.cs index 2f7a4eba..f130fb7b 100644 --- a/AideDeJeu/AideDeJeu/Models/Item.cs +++ b/AideDeJeu/AideDeJeu/Models/Item.cs @@ -5,12 +5,13 @@ using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.Text.RegularExpressions; +using System.Threading.Tasks; using System.Xml; namespace AideDeJeuLib { [DataContract] - public class Item : IList + public class Item //: IList { private List _Items; @@ -29,68 +30,73 @@ namespace AideDeJeuLib _Items = new List(); } - public string Header { get; set; } - - public int Count => _Items.Count(); - - public bool IsReadOnly => false; - - public Item this[int index] { get => _Items[index]; set => _Items[index] = value; } - - public IEnumerator GetEnumerator() + public async Task> GetChildrenAsync() { - return _Items?.GetEnumerator(); + return _Items; } - IEnumerator IEnumerable.GetEnumerator() - { - return _Items?.GetEnumerator(); - } + //public string Header { get; set; } + + //public int Count => _Items.Count(); + + //public bool IsReadOnly => false; + + //public Item this[int index] { get => _Items[index]; set => _Items[index] = value; } + + //public IEnumerator GetEnumerator() + //{ + // return _Items?.GetEnumerator(); + //} + + ////IEnumerator IEnumerable.GetEnumerator() + ////{ + //// return _Items?.GetEnumerator(); + ////} public virtual FilterViewModel GetNewFilterViewModel() { return null; } - public int IndexOf(Item item) - { - return _Items.IndexOf(item); - } + //public int IndexOf(Item item) + //{ + // return _Items.IndexOf(item); + //} - public void Insert(int index, Item item) - { - _Items.Insert(index, item); - } + //public void Insert(int index, Item item) + //{ + // _Items.Insert(index, item); + //} - public void RemoveAt(int index) - { - _Items.RemoveAt(index); - } + //public void RemoveAt(int index) + //{ + // _Items.RemoveAt(index); + //} - public void Add(Item item) + public void AddChild(Item item) { _Items.Add(item); } - public void Clear() - { - _Items.Clear(); - } + //public void Clear() + //{ + // _Items.Clear(); + //} - public bool Contains(Item item) - { - return _Items.Contains(item); - } + //public bool Contains(Item item) + //{ + // return _Items.Contains(item); + //} - public void CopyTo(Item[] array, int arrayIndex) - { - _Items.CopyTo(array, arrayIndex); - } + //public void CopyTo(Item[] array, int arrayIndex) + //{ + // _Items.CopyTo(array, arrayIndex); + //} - public bool Remove(Item item) - { - throw new NotImplementedException(); - } + //public bool Remove(Item item) + //{ + // throw new NotImplementedException(); + //} [DataMember] public virtual string Id { get; set; } diff --git a/AideDeJeu/AideDeJeu/ViewModels/BookmarksViewModel.cs b/AideDeJeu/AideDeJeu/ViewModels/BookmarksViewModel.cs index 321a68ab..871a2ac7 100644 --- a/AideDeJeu/AideDeJeu/ViewModels/BookmarksViewModel.cs +++ b/AideDeJeu/AideDeJeu/ViewModels/BookmarksViewModel.cs @@ -51,21 +51,21 @@ namespace AideDeJeu.ViewModels } } - public List GetBookmarkCollection(string key) + public async Task> GetBookmarkCollection(string key) { if (App.Current.Properties.ContainsKey(key)) { var property = App.Current.Properties[key] as string; if (property != null) { - return ToItems(property); + return await ToItems(property); } } return null; } - public void LoadBookmarkCollection(string key) + public async Task LoadBookmarkCollection(string key) { - var items = GetBookmarkCollection(key); + var items = await GetBookmarkCollection(key); BookmarkCollection.Clear(); if (items != null) { @@ -76,7 +76,7 @@ namespace AideDeJeu.ViewModels public async Task AddBookmarkAsync(string key, Item item) { var linkItem = new LinkItem() { Name = item.Name, AltName = item.AltName, Link = item.Id }; - var items = GetBookmarkCollection(key); + var items = (await GetBookmarkCollection(key)).ToList(); if(items == null) { items = new List(); @@ -104,13 +104,13 @@ namespace AideDeJeu.ViewModels return md; } - public List ToItems(string md) + public async Task> ToItems(string md) { var item = Store.ToItem(null, md); //if(item is Items) //{ var items = item; // as Items; - return items.ToList(); + return await items.GetChildrenAsync(); //} //return new List { item }; } diff --git a/AideDeJeu/AideDeJeu/ViewModels/ItemsViewModel.cs b/AideDeJeu/AideDeJeu/ViewModels/ItemsViewModel.cs index 8a492244..409deef4 100644 --- a/AideDeJeu/AideDeJeu/ViewModels/ItemsViewModel.cs +++ b/AideDeJeu/AideDeJeu/ViewModels/ItemsViewModel.cs @@ -58,6 +58,19 @@ namespace AideDeJeu.ViewModels } } + public IEnumerable _Children = new List(); + public IEnumerable Children + { + get + { + return _Children; + } + set + { + SetProperty(ref _Children, value); + } + } + private Item _SelectedItem; public Item SelectedItem { @@ -106,12 +119,14 @@ namespace AideDeJeu.ViewModels { if (Filter != null) { - var items = await Filter.FilterItems(AllItems, cancellationToken: cancellationToken); + var items = await Filter.FilterItems(await AllItems.GetChildrenAsync(), cancellationToken: cancellationToken); Items = new Item(items.ToList()); + Children = items; } else { Items = AllItems; + Children = await AllItems.GetChildrenAsync(); } } catch (OperationCanceledException ex) diff --git a/AideDeJeu/AideDeJeu/ViewModels/StoreViewModel.cs b/AideDeJeu/AideDeJeu/ViewModels/StoreViewModel.cs index c7624616..5c0289eb 100644 --- a/AideDeJeu/AideDeJeu/ViewModels/StoreViewModel.cs +++ b/AideDeJeu/AideDeJeu/ViewModels/StoreViewModel.cs @@ -87,7 +87,7 @@ namespace AideDeJeu.ViewModels else //if (currentItem is Items) { var items = currentItem; // as Items; - items.Add(subItem); + items.AddChild(subItem); } enumerator.MoveNext(); } diff --git a/AideDeJeu/AideDeJeu/Views/FilteredItemsPage.xaml b/AideDeJeu/AideDeJeu/Views/FilteredItemsPage.xaml index 85849b96..8d1a4a90 100644 --- a/AideDeJeu/AideDeJeu/Views/FilteredItemsPage.xaml +++ b/AideDeJeu/AideDeJeu/Views/FilteredItemsPage.xaml @@ -53,7 +53,7 @@ - + diff --git a/AideDeJeu/AideDeJeu/Views/ItemsPage.xaml b/AideDeJeu/AideDeJeu/Views/ItemsPage.xaml index 19a39028..172ff14b 100644 --- a/AideDeJeu/AideDeJeu/Views/ItemsPage.xaml +++ b/AideDeJeu/AideDeJeu/Views/ItemsPage.xaml @@ -21,7 +21,7 @@ --> - + (it as Spell).Source.Contains(classe)).OrderBy(it => (it as Spell).Level).ThenBy(it => it.Name);