mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-12-16 23:29:47 +00:00
Clean
This commit is contained in:
parent
c21afecba6
commit
8765112c55
1 changed files with 4 additions and 85 deletions
|
|
@ -9,17 +9,6 @@ using Xamarin.Forms;
|
||||||
|
|
||||||
namespace AideDeJeu.ViewModels
|
namespace AideDeJeu.ViewModels
|
||||||
{
|
{
|
||||||
[Flags]
|
|
||||||
public enum ItemSourceType
|
|
||||||
{
|
|
||||||
SpellVO,
|
|
||||||
SpellHD,
|
|
||||||
MonsterVO,
|
|
||||||
MonsterHD,
|
|
||||||
ConditionVO,
|
|
||||||
ConditionHD,
|
|
||||||
}
|
|
||||||
|
|
||||||
public class MainViewModel : BaseViewModel
|
public class MainViewModel : BaseViewModel
|
||||||
{
|
{
|
||||||
private bool _isLoading;
|
private bool _isLoading;
|
||||||
|
|
@ -50,83 +39,16 @@ namespace AideDeJeu.ViewModels
|
||||||
return itemsViewModel;
|
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 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 Command LoadItemsCommand { get; private set; }
|
public Command LoadItemsCommand { 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 AboutCommand { get; private set; }
|
public Command AboutCommand { get; private set; }
|
||||||
|
|
||||||
public Navigator Navigator { get; set; }
|
public Navigator Navigator { get; set; }
|
||||||
|
|
||||||
public MainViewModel()
|
public MainViewModel()
|
||||||
{
|
{
|
||||||
//GotoItemCommand = new Command<Item>(async (item) =>
|
|
||||||
//{
|
|
||||||
// await Navigator.GotoItemDetailPageAsync(item);
|
|
||||||
//});
|
|
||||||
AboutCommand = new Command(async () => await Main.Navigator.GotoAboutPageAsync());
|
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)
|
public async Task NavigateToLink(string s)
|
||||||
{
|
{
|
||||||
if (s != null)
|
if (s != null)
|
||||||
|
|
@ -137,12 +59,11 @@ namespace AideDeJeu.ViewModels
|
||||||
var match = regex.Match(s);
|
var match = regex.Match(s);
|
||||||
var file = match.Groups["file"].Value;
|
var file = match.Groups["file"].Value;
|
||||||
var anchor = match.Groups["anchor"].Value;
|
var anchor = match.Groups["anchor"].Value;
|
||||||
var itemSourceType = MDFileToItemSourceType(file);
|
var items = await GetAllItemsAsync(file);
|
||||||
var spells = await GetAllItemsAsync(file);
|
var item = items.Where(i => Tools.Helpers.IdFromName(i.Name) == anchor).FirstOrDefault();
|
||||||
var spell = spells.Where(i => Tools.Helpers.IdFromName(i.Name) == anchor).FirstOrDefault();
|
if (item != null)
|
||||||
if (spell != null)
|
|
||||||
{
|
{
|
||||||
await Navigator.GotoItemDetailPageAsync(spell);
|
await Navigator.GotoItemDetailPageAsync(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -150,13 +71,11 @@ namespace AideDeJeu.ViewModels
|
||||||
var regex = new Regex("/(?<file>.*)\\.md");
|
var regex = new Regex("/(?<file>.*)\\.md");
|
||||||
var match = regex.Match(s);
|
var match = regex.Match(s);
|
||||||
var file = match.Groups["file"].Value;
|
var file = match.Groups["file"].Value;
|
||||||
//var itemSourceType = MDFileToItemSourceType(file);
|
|
||||||
var items = await GetItemsViewModelAsync(file);
|
var items = await GetItemsViewModelAsync(file);
|
||||||
items.LoadItemsCommand.Execute(null);
|
items.LoadItemsCommand.Execute(null);
|
||||||
await Navigator.GotoItemsPageAsync(items);
|
await Navigator.GotoItemsPageAsync(items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue