diff --git a/AideDeJeu/AideDeJeu/ViewModels/MainViewModel.cs b/AideDeJeu/AideDeJeu/ViewModels/MainViewModel.cs index a14fbf50..551632f4 100644 --- a/AideDeJeu/AideDeJeu/ViewModels/MainViewModel.cs +++ b/AideDeJeu/AideDeJeu/ViewModels/MainViewModel.cs @@ -9,17 +9,6 @@ using Xamarin.Forms; namespace AideDeJeu.ViewModels { - [Flags] - public enum ItemSourceType - { - SpellVO, - SpellHD, - MonsterVO, - MonsterHD, - ConditionVO, - ConditionHD, - } - public class MainViewModel : BaseViewModel { private bool _isLoading; @@ -50,83 +39,16 @@ namespace AideDeJeu.ViewModels return itemsViewModel; } - //public Dictionary> AllFiltersViewModel = new Dictionary>() - //{ - // { ItemSourceType.SpellVO, () => new VOSpellFilterViewModel() }, - // { ItemSourceType.SpellHD, () => new HDSpellFilterViewModel() }, - // { ItemSourceType.MonsterVO, () => new VOMonsterFilterViewModel() }, - // { ItemSourceType.MonsterHD, () => new HDMonsterFilterViewModel() }, - // { ItemSourceType.ConditionHD, () => new SearchFilterViewModel() }, - // { ItemSourceType.ConditionVO, () => new SearchFilterViewModel() }, - //}; - - //public FilterViewModel GetFilterViewModel(ItemSourceType itemSourceType) - //{ - // return AllFiltersViewModel[itemSourceType].Invoke(); - //} - - //public IEnumerable _Items = new List(); - //public IEnumerable Items - //{ - // get - // { - // return _Items; - // } - // set - // { - // SetProperty(ref _Items, value); - // } - //} - public Command LoadItemsCommand { get; private set; } - //public Command GotoItemCommand { get; private set; } - - //public Command SwitchToSpellsHD { get; private set; } - //public Command SwitchToMonstersHD { get; private set; } - //public Command SwitchToSpellsVO { get; private set; } - //public Command SwitchToMonstersVO { get; private set; } public Command AboutCommand { get; private set; } public Navigator Navigator { get; set; } public MainViewModel() { - //GotoItemCommand = new Command(async (item) => - //{ - // await Navigator.GotoItemDetailPageAsync(item); - //}); AboutCommand = new Command(async () => await Main.Navigator.GotoAboutPageAsync()); } - ItemSourceType MDFileToItemSourceType(string file) - { - if (file == "spells_hd") - { - return ItemSourceType.SpellHD; - } - else if (file == "spells_vo") - { - return ItemSourceType.SpellVO; - } - else if (file == "monsters_hd") - { - return ItemSourceType.MonsterHD; - } - else if (file == "monsters_vo") - { - return ItemSourceType.MonsterVO; - } - else if (file == "conditions_hd") - { - return ItemSourceType.ConditionHD; - } - else if (file == "conditions_vo") - { - return ItemSourceType.ConditionVO; - } - return ItemSourceType.SpellHD; - } - public async Task NavigateToLink(string s) { if (s != null) @@ -137,12 +59,11 @@ namespace AideDeJeu.ViewModels var match = regex.Match(s); var file = match.Groups["file"].Value; var anchor = match.Groups["anchor"].Value; - var itemSourceType = MDFileToItemSourceType(file); - var spells = await GetAllItemsAsync(file); - var spell = spells.Where(i => Tools.Helpers.IdFromName(i.Name) == anchor).FirstOrDefault(); - if (spell != null) + var items = await GetAllItemsAsync(file); + var item = items.Where(i => Tools.Helpers.IdFromName(i.Name) == anchor).FirstOrDefault(); + if (item != null) { - await Navigator.GotoItemDetailPageAsync(spell); + await Navigator.GotoItemDetailPageAsync(item); } } else @@ -150,13 +71,11 @@ namespace AideDeJeu.ViewModels var regex = new Regex("/(?.*)\\.md"); var match = regex.Match(s); var file = match.Groups["file"].Value; - //var itemSourceType = MDFileToItemSourceType(file); var items = await GetItemsViewModelAsync(file); items.LoadItemsCommand.Execute(null); await Navigator.GotoItemsPageAsync(items); } } } - } } \ No newline at end of file