1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-30 15:06:06 +00:00

Nettoyage

This commit is contained in:
Yan Maniez 2018-07-15 15:31:44 +02:00
parent 30bd94ddae
commit c21afecba6
2 changed files with 43 additions and 64 deletions

View file

@ -84,17 +84,18 @@ namespace AideDeJeu.ViewModels
SetProperty(ref _SelectedItem, value);
if (_SelectedItem != null)
{
Main.GotoItemCommand.Execute(_SelectedItem);
Main.Navigator.GotoItemDetailPageAsync(_SelectedItem);
//Main.GotoItemCommand.Execute(_SelectedItem);
}
}
}
public IEnumerable<Item> AllItems;
public Items AllItems;
public async Task InitAsync()
{
//AllItems = await Main.GetAllItemsAsync(ItemSourceType);
Title = (AllItems as Item)?.Name;
Filter = (AllItems as Items).GetNewFilterViewModel(); //Main.GetFilterViewModel(ItemSourceType);
Title = AllItems.Name;
Filter = AllItems.GetNewFilterViewModel(); //Main.GetFilterViewModel(ItemSourceType);
Filter.LoadItemsCommand = LoadItemsCommand;
}

View file

@ -29,94 +29,72 @@ namespace AideDeJeu.ViewModels
set => SetProperty(ref _isLoading, value);
}
private Dictionary<string, IEnumerable<Item>> _AllItems = new Dictionary<string, IEnumerable<Item>>();
public async Task<IEnumerable<Item>> GetAllItemsAsync(string source)
private Dictionary<string, Items> _AllItems = new Dictionary<string, Items>();
public async Task<Items> GetAllItemsAsync(string source)
{
if (!_AllItems.ContainsKey(source))
{
//var md = await Tools.Helpers.GetStringFromUrl($"https://raw.githubusercontent.com/Nioux/AideDeJeu/master/Data/{source}.md");
var md = await Tools.Helpers.GetResourceStringAsync($"AideDeJeu.Data.{source}.md");
_AllItems[source] = Tools.MarkdownExtensions.ToItem(md) as IEnumerable<Item>;
_AllItems[source] = Tools.MarkdownExtensions.ToItem(md) as Items;
}
return _AllItems[source];
}
//public List<KeyValuePair<ItemSourceType, string>> ItemsSources { get; set; } = new List<KeyValuePair<ItemSourceType, string>>()
//{
// new KeyValuePair<ItemSourceType, string>(ItemSourceType.SpellHD, "Sorts (H&D)"),
// new KeyValuePair<ItemSourceType, string>(ItemSourceType.SpellVO, "Spells (VO)"),
// new KeyValuePair<ItemSourceType, string>(ItemSourceType.MonsterHD, "Créatures (H&D)"),
// new KeyValuePair<ItemSourceType, string>(ItemSourceType.MonsterVO, "Monsters (VO)"),
// new KeyValuePair<ItemSourceType, string>(ItemSourceType.ConditionHD, "Etats spéciaux (H&D)"),
// new KeyValuePair<ItemSourceType, string>(ItemSourceType.ConditionVO, "Conditions (VO)"),
//};
//public Dictionary<ItemSourceType, Func<ItemsViewModel>> AllItemsViewModel = new Dictionary<ItemSourceType, Func<ItemsViewModel>>()
//{
// { ItemSourceType.SpellVO, () => new ItemsViewModel(ItemSourceType.SpellVO) },
// { ItemSourceType.SpellHD, () => new ItemsViewModel(ItemSourceType.SpellHD) },
// { ItemSourceType.MonsterVO, () => new ItemsViewModel(ItemSourceType.MonsterVO) },
// { ItemSourceType.MonsterHD, () => new ItemsViewModel(ItemSourceType.MonsterHD) },
// { ItemSourceType.ConditionHD, () => new ItemsViewModel(ItemSourceType.ConditionHD) },
// { ItemSourceType.ConditionVO, () => new ItemsViewModel(ItemSourceType.ConditionVO) },
//};
public async Task<ItemsViewModel> GetItemsViewModelAsync(string source)
{
var allItems = await GetAllItemsAsync(source);
var itemsViewModel = new ItemsViewModel(); //AllItemsViewModel[source].Invoke();
var itemsViewModel = new ItemsViewModel();
itemsViewModel.AllItems = allItems;
await itemsViewModel.InitAsync();
return itemsViewModel;
}
public Dictionary<ItemSourceType, Func<FilterViewModel>> AllFiltersViewModel = new Dictionary<ItemSourceType, Func<FilterViewModel>>()
{
{ 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 Dictionary<ItemSourceType, Func<FilterViewModel>> AllFiltersViewModel = new Dictionary<ItemSourceType, Func<FilterViewModel>>()
//{
// { 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 FilterViewModel GetFilterViewModel(ItemSourceType itemSourceType)
//{
// return AllFiltersViewModel[itemSourceType].Invoke();
//}
public IEnumerable<Item> _Items = new List<Item>();
public IEnumerable<Item> Items
{
get
{
return _Items;
}
set
{
SetProperty(ref _Items, value);
}
}
//public IEnumerable<Item> _Items = new List<Item>();
//public IEnumerable<Item> Items
//{
// get
// {
// return _Items;
// }
// set
// {
// SetProperty(ref _Items, value);
// }
//}
public Command LoadItemsCommand { get; private set; }
public Command<Item> GotoItemCommand { get; private set; }
//public Command<Item> 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 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<Item>(async (item) =>
{
await Navigator.GotoItemDetailPageAsync(item);
});
//GotoItemCommand = new Command<Item>(async (item) =>
//{
// await Navigator.GotoItemDetailPageAsync(item);
//});
AboutCommand = new Command(async () => await Main.Navigator.GotoAboutPageAsync());
}