mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-29 14:35:45 +00:00
Début ajout des listes de monstres
This commit is contained in:
parent
afe188de0b
commit
a75eaa90ef
20 changed files with 1053 additions and 158 deletions
|
|
@ -20,6 +20,15 @@
|
||||||
<Compile Update="Views\AboutPage.xaml.cs">
|
<Compile Update="Views\AboutPage.xaml.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Update="Views\MainPage.xaml.cs">
|
||||||
|
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Update="Views\MonstersPage.xaml.cs">
|
||||||
|
<DependentUpon>MonstersPage.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Update="Views\MonsterDetailPage.xaml.cs">
|
||||||
|
<DependentUpon>MonsterDetailPage.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Update="Views\SpellDetailPage.xaml.cs">
|
<Compile Update="Views\SpellDetailPage.xaml.cs">
|
||||||
<DependentUpon>SpellDetailPage.xaml</DependentUpon>
|
<DependentUpon>SpellDetailPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
@ -29,8 +38,9 @@
|
||||||
<Compile Update="Views\ItemsPage.xaml.cs">
|
<Compile Update="Views\ItemsPage.xaml.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Update="Views\MainPage.xaml.cs">
|
<Compile Update="Views\SpellsPage.xaml.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
|
<DependentUpon>SpellsPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Update="Views\NewItemPage.xaml.cs">
|
<Compile Update="Views\NewItemPage.xaml.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ namespace AideDeJeu
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
MainPage = new NavigationPage(new MainPage());
|
MainPage = new NavigationPage(new MonstersPage()); // MainPage());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnStart ()
|
protected override void OnStart ()
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ namespace AideDeJeu.Services
|
||||||
|
|
||||||
public async Task<IEnumerable<Item>> GetItemsAsync(bool forceRefresh = false)
|
public async Task<IEnumerable<Item>> GetItemsAsync(bool forceRefresh = false)
|
||||||
{
|
{
|
||||||
var scrapper = new Scrappers();
|
var scrapper = new SpellsScrappers();
|
||||||
var spells = await scrapper.GetSpells(await scrapper.GetSpellIds("c"));
|
var spells = await scrapper.GetSpells(await scrapper.GetSpellIds("c"));
|
||||||
items = spells.Select(spell => new Item() { Text = spell.Title, Description = spell.DescriptionText }).ToList();
|
items = spells.Select(spell => new Item() { Text = spell.Title, Description = spell.DescriptionText }).ToList();
|
||||||
return await Task.FromResult(items);
|
return await Task.FromResult(items);
|
||||||
|
|
|
||||||
79
AideDeJeu/AideDeJeu/Services/MonsterDataStore.cs
Normal file
79
AideDeJeu/AideDeJeu/Services/MonsterDataStore.cs
Normal file
|
|
@ -0,0 +1,79 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using AideDeJeu.Models;
|
||||||
|
using AideDeJeuLib;
|
||||||
|
using AideDeJeuLib.Monsters;
|
||||||
|
using AideDeJeuLib.Spells;
|
||||||
|
|
||||||
|
[assembly: Xamarin.Forms.Dependency(typeof(AideDeJeu.Services.SpellDataStore))]
|
||||||
|
namespace AideDeJeu.Services
|
||||||
|
{
|
||||||
|
//public class MonsterDataStore : IDataStore<Monster>
|
||||||
|
//{
|
||||||
|
// List<Spell> items;
|
||||||
|
|
||||||
|
// public MonsterDataStore()
|
||||||
|
// {
|
||||||
|
// items = new List<Spell>();
|
||||||
|
// var mockItems = new List<Spell>
|
||||||
|
// {
|
||||||
|
// };
|
||||||
|
|
||||||
|
// foreach (var item in mockItems)
|
||||||
|
// {
|
||||||
|
// items.Add(item);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public async Task<bool> AddItemAsync(Spell item)
|
||||||
|
// {
|
||||||
|
// items.Add(item);
|
||||||
|
|
||||||
|
// return await Task.FromResult(true);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public async Task<bool> UpdateItemAsync(Spell item)
|
||||||
|
// {
|
||||||
|
// var _item = items.Where((Spell arg) => arg.Id == item.Id).FirstOrDefault();
|
||||||
|
// items.Remove(_item);
|
||||||
|
// items.Add(item);
|
||||||
|
|
||||||
|
// return await Task.FromResult(true);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public async Task<bool> DeleteItemAsync(Spell item)
|
||||||
|
// {
|
||||||
|
// var _item = items.Where((Spell arg) => arg.Id == item.Id).FirstOrDefault();
|
||||||
|
// items.Remove(_item);
|
||||||
|
|
||||||
|
// return await Task.FromResult(true);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public async Task<Spell> GetItemAsync(string id)
|
||||||
|
// {
|
||||||
|
// return await Task.FromResult(items.FirstOrDefault(s => s.Id == id));
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public async Task<IEnumerable<Monster>> GetItemsAsync(bool forceRefresh = false)
|
||||||
|
// {
|
||||||
|
// var scrapper = new MonstersScrappers();
|
||||||
|
// //items = (await scrapper.GetSpells(await scrapper.GetSpellIds(""))).ToList();
|
||||||
|
// items = (await scrapper.GetMonsters()).ToList();
|
||||||
|
|
||||||
|
// //items = spells.Select(spell => new Item() { Text = spell.Title, Description = spell.DescriptionText }).ToList();
|
||||||
|
// return await Task.FromResult(items);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public async Task<IEnumerable<Monster>> GetItemsAsync(string classe, int niveauMin, int niveauMax, string ecole, string rituel, string source)
|
||||||
|
// {
|
||||||
|
// var scrapper = new MonstersScrappers();
|
||||||
|
// items = (await scrapper.GetMonsters(classe: classe, niveauMin: niveauMin, niveauMax: niveauMax, ecole: ecole, rituel: rituel, source: source)).ToList();
|
||||||
|
|
||||||
|
// return await Task.FromResult(items);
|
||||||
|
// }
|
||||||
|
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
@ -58,7 +58,7 @@ namespace AideDeJeu.Services
|
||||||
|
|
||||||
public async Task<IEnumerable<Spell>> GetItemsAsync(bool forceRefresh = false)
|
public async Task<IEnumerable<Spell>> GetItemsAsync(bool forceRefresh = false)
|
||||||
{
|
{
|
||||||
var scrapper = new Scrappers();
|
var scrapper = new SpellsScrappers();
|
||||||
//items = (await scrapper.GetSpells(await scrapper.GetSpellIds(""))).ToList();
|
//items = (await scrapper.GetSpells(await scrapper.GetSpellIds(""))).ToList();
|
||||||
items = (await scrapper.GetSpells()).ToList();
|
items = (await scrapper.GetSpells()).ToList();
|
||||||
|
|
||||||
|
|
@ -68,7 +68,7 @@ namespace AideDeJeu.Services
|
||||||
|
|
||||||
public async Task<IEnumerable<Spell>> GetItemsAsync(string classe, int niveauMin, int niveauMax, string ecole, string rituel, string source)
|
public async Task<IEnumerable<Spell>> GetItemsAsync(string classe, int niveauMin, int niveauMax, string ecole, string rituel, string source)
|
||||||
{
|
{
|
||||||
var scrapper = new Scrappers();
|
var scrapper = new SpellsScrappers();
|
||||||
items = (await scrapper.GetSpells(classe: classe, niveauMin: niveauMin, niveauMax: niveauMax, ecole: ecole, rituel: rituel, source: source)).ToList();
|
items = (await scrapper.GetSpells(classe: classe, niveauMin: niveauMin, niveauMax: niveauMax, ecole: ecole, rituel: rituel, source: source)).ToList();
|
||||||
|
|
||||||
return await Task.FromResult(items);
|
return await Task.FromResult(items);
|
||||||
|
|
|
||||||
147
AideDeJeu/AideDeJeu/ViewModels/MonsterDetailViewModel.cs
Normal file
147
AideDeJeu/AideDeJeu/ViewModels/MonsterDetailViewModel.cs
Normal file
|
|
@ -0,0 +1,147 @@
|
||||||
|
using AideDeJeu.Tools;
|
||||||
|
using AideDeJeuLib.Spells;
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
using System.Reactive.Linq;
|
||||||
|
using AideDeJeuLib.Monsters;
|
||||||
|
|
||||||
|
namespace AideDeJeu.ViewModels
|
||||||
|
{
|
||||||
|
public class MonsterDetailViewModel : BaseViewModel
|
||||||
|
{
|
||||||
|
Monster _Item = null;
|
||||||
|
public Monster Item
|
||||||
|
{
|
||||||
|
get { return _Item; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _Item, value);
|
||||||
|
//OnPropertyChanged(nameof(Description));
|
||||||
|
//OnPropertyChanged(nameof(TypeLevel));
|
||||||
|
//OnPropertyChanged(nameof(CastingTime));
|
||||||
|
//OnPropertyChanged(nameof(Range));
|
||||||
|
//OnPropertyChanged(nameof(Components));
|
||||||
|
//OnPropertyChanged(nameof(Duration));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//public FormattedString Description
|
||||||
|
//{
|
||||||
|
// get
|
||||||
|
// {
|
||||||
|
// var fs = new FormattedString();
|
||||||
|
// if (Item?.DescriptionDiv != null)
|
||||||
|
// {
|
||||||
|
// FormatedTextHelpers.HtmlToFormatedString(Item?.DescriptionDiv, fs, FontAttributes.None);
|
||||||
|
// }
|
||||||
|
// return fs;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
//public FormattedString TypeLevel
|
||||||
|
//{
|
||||||
|
// get
|
||||||
|
// {
|
||||||
|
// var fd = FormatedTextHelpers.FontData.FromResource("contentital");
|
||||||
|
// var fs = new FormattedString();
|
||||||
|
// var capType = Item.Type.First().ToString().ToUpper() + Item.Type.Substring(1);
|
||||||
|
// fs.Spans.Add(new Span() { Text = string.Format("{0} de niveau {1}", capType, Item.Level), FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor});
|
||||||
|
// return fs;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
//public FormattedString CastingTime
|
||||||
|
//{
|
||||||
|
// get
|
||||||
|
// {
|
||||||
|
// var fd = FormatedTextHelpers.FontData.FromResource("content");
|
||||||
|
// var fdb = FormatedTextHelpers.FontData.FromResource("contentbold");
|
||||||
|
// var fs = new FormattedString();
|
||||||
|
// fs.Spans.Add(new Span() { Text = "Durée d'incantation : ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor });
|
||||||
|
// fs.Spans.Add(new Span() { Text = Item.CastingTime, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
|
||||||
|
// return fs;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
//public FormattedString Range
|
||||||
|
//{
|
||||||
|
// get
|
||||||
|
// {
|
||||||
|
// var fd = FormatedTextHelpers.FontData.FromResource("content");
|
||||||
|
// var fdb = FormatedTextHelpers.FontData.FromResource("contentbold");
|
||||||
|
// var fs = new FormattedString();
|
||||||
|
// fs.Spans.Add(new Span() { Text = "Portée : ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor });
|
||||||
|
// fs.Spans.Add(new Span() { Text = Item.Range, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
|
||||||
|
// return fs;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
//public FormattedString Components
|
||||||
|
//{
|
||||||
|
// get
|
||||||
|
// {
|
||||||
|
// var fd = FormatedTextHelpers.FontData.FromResource("content");
|
||||||
|
// var fdb = FormatedTextHelpers.FontData.FromResource("contentbold");
|
||||||
|
// var fs = new FormattedString();
|
||||||
|
// fs.Spans.Add(new Span() { Text = "Composantes : ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor });
|
||||||
|
// fs.Spans.Add(new Span() { Text = Item.Components, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
|
||||||
|
// return fs;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
//public FormattedString Duration
|
||||||
|
//{
|
||||||
|
// get
|
||||||
|
// {
|
||||||
|
// var fd = FormatedTextHelpers.FontData.FromResource("content");
|
||||||
|
// var fdb = FormatedTextHelpers.FontData.FromResource("contentbold");
|
||||||
|
// var fs = new FormattedString();
|
||||||
|
// fs.Spans.Add(new Span() { Text = "Durée : ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor });
|
||||||
|
// fs.Spans.Add(new Span() { Text = Item.Duration, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
|
||||||
|
// return fs;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
public Command LoadItemCommand { get; set; }
|
||||||
|
|
||||||
|
public MonsterDetailViewModel(Monster item = null)
|
||||||
|
{
|
||||||
|
Title = item?.Name;
|
||||||
|
Item = item;
|
||||||
|
LoadItemCommand = new Command(async () => await ExecuteLoadItemCommand());
|
||||||
|
}
|
||||||
|
async Task ExecuteLoadItemCommand()
|
||||||
|
{
|
||||||
|
if (IsBusy)
|
||||||
|
return;
|
||||||
|
|
||||||
|
IsBusy = true;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//Items.Clear();
|
||||||
|
var item = await new MonstersScrappers().GetMonster(Item.Id);
|
||||||
|
Item = item;
|
||||||
|
//foreach (var item in items)
|
||||||
|
//{
|
||||||
|
// Items.Add(item);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.WriteLine(ex);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IsBusy = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
214
AideDeJeu/AideDeJeu/ViewModels/MonstersViewModel.cs
Normal file
214
AideDeJeu/AideDeJeu/ViewModels/MonstersViewModel.cs
Normal file
|
|
@ -0,0 +1,214 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
using AideDeJeu.Models;
|
||||||
|
using AideDeJeu.Views;
|
||||||
|
using AideDeJeuLib;
|
||||||
|
using AideDeJeuLib.Spells;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using AideDeJeuLib.Monsters;
|
||||||
|
|
||||||
|
namespace AideDeJeu.ViewModels
|
||||||
|
{
|
||||||
|
public class MonstersViewModel : BaseViewModel
|
||||||
|
{
|
||||||
|
public ObservableCollection<Monster> Items { get; set; }
|
||||||
|
|
||||||
|
public List<KeyValuePair<string, string>> Classes { get; set; } = new List<KeyValuePair<string, string>>()
|
||||||
|
{
|
||||||
|
new KeyValuePair<string, string>("", "Toutes" ),
|
||||||
|
new KeyValuePair<string, string>("b", "Barde" ),
|
||||||
|
new KeyValuePair<string, string>("c", "Clerc" ),
|
||||||
|
new KeyValuePair<string, string>("d", "Druide" ),
|
||||||
|
new KeyValuePair<string, string>("s", "Ensorceleur" ),
|
||||||
|
new KeyValuePair<string, string>("w", "Magicien" ),
|
||||||
|
new KeyValuePair<string, string>("p", "Paladin" ),
|
||||||
|
new KeyValuePair<string, string>("r", "Rôdeur" ),
|
||||||
|
new KeyValuePair<string, string>("k", "Sorcier" ),
|
||||||
|
};
|
||||||
|
|
||||||
|
public List<KeyValuePair<int, string>> Niveaux { get; set; } = new List<KeyValuePair<int, string>>()
|
||||||
|
{
|
||||||
|
new KeyValuePair<int, string>(0, "Sorts mineurs"),
|
||||||
|
new KeyValuePair<int, string>(1, "Niveau 1"),
|
||||||
|
new KeyValuePair<int, string>(2, "Niveau 2"),
|
||||||
|
new KeyValuePair<int, string>(3, "Niveau 3"),
|
||||||
|
new KeyValuePair<int, string>(4, "Niveau 4"),
|
||||||
|
new KeyValuePair<int, string>(5, "Niveau 5"),
|
||||||
|
new KeyValuePair<int, string>(6, "Niveau 6"),
|
||||||
|
new KeyValuePair<int, string>(7, "Niveau 7"),
|
||||||
|
new KeyValuePair<int, string>(8, "Niveau 8"),
|
||||||
|
new KeyValuePair<int, string>(9, "Niveau 9"),
|
||||||
|
};
|
||||||
|
|
||||||
|
public List<KeyValuePair<string, string>> Ecoles { get; set; } = new List<KeyValuePair<string, string>>()
|
||||||
|
{
|
||||||
|
new KeyValuePair<string, string>("", "Toutes"),
|
||||||
|
new KeyValuePair<string, string>("abjuration", "Abjuration"),
|
||||||
|
new KeyValuePair<string, string>("divination", "Divination"),
|
||||||
|
new KeyValuePair<string, string>("enchantement", "Enchantement"),
|
||||||
|
new KeyValuePair<string, string>("evocation", "Évocation"),
|
||||||
|
new KeyValuePair<string, string>("illusion", "Illusion"),
|
||||||
|
new KeyValuePair<string, string>("invocation", "Invocation"),
|
||||||
|
new KeyValuePair<string, string>("necromancie", "Nécromancie"),
|
||||||
|
new KeyValuePair<string, string>("transmutation", "Transmutation"),
|
||||||
|
};
|
||||||
|
|
||||||
|
public List<KeyValuePair<string, string>> Rituels { get; set; } = new List<KeyValuePair<string, string>>()
|
||||||
|
{
|
||||||
|
new KeyValuePair<string, string>("", "Tous"),
|
||||||
|
new KeyValuePair<string, string>("1", "Rituel"),
|
||||||
|
};
|
||||||
|
|
||||||
|
public List<KeyValuePair<string, string>> Sources { get; set; } = new List<KeyValuePair<string, string>>()
|
||||||
|
{
|
||||||
|
new KeyValuePair<string, string>("", "Toutes"),
|
||||||
|
new KeyValuePair<string, string>("srd", "SRD"),
|
||||||
|
new KeyValuePair<string, string>("ph", "PHB"),
|
||||||
|
new KeyValuePair<string, string>("sup", "SCAG, XGtE"),
|
||||||
|
};
|
||||||
|
|
||||||
|
private int _Classe = 0;
|
||||||
|
public int Classe
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _Classe;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _Classe, value);
|
||||||
|
LoadItemsCommand.Execute(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private int _NiveauMin = 0;
|
||||||
|
public int NiveauMin
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _NiveauMin;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _NiveauMin, value);
|
||||||
|
if (_NiveauMax < _NiveauMin)
|
||||||
|
{
|
||||||
|
SetProperty(ref _NiveauMax, value, nameof(NiveauMax));
|
||||||
|
}
|
||||||
|
LoadItemsCommand.Execute(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private int _NiveauMax = 9;
|
||||||
|
public int NiveauMax
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _NiveauMax;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _NiveauMax, value);
|
||||||
|
if (_NiveauMax < _NiveauMin)
|
||||||
|
{
|
||||||
|
SetProperty(ref _NiveauMin, value, nameof(NiveauMin));
|
||||||
|
}
|
||||||
|
LoadItemsCommand.Execute(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private int _Ecole = 0;
|
||||||
|
public int Ecole
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _Ecole;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _Ecole, value);
|
||||||
|
LoadItemsCommand.Execute(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private int _Rituel = 0;
|
||||||
|
public int Rituel
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _Rituel;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _Rituel, value);
|
||||||
|
LoadItemsCommand.Execute(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private int _Source = 0;
|
||||||
|
public int Source
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _Source;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _Source, value);
|
||||||
|
LoadItemsCommand.Execute(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Command LoadItemsCommand { get; set; }
|
||||||
|
|
||||||
|
public MonstersViewModel()
|
||||||
|
{
|
||||||
|
//Title = "Browse";
|
||||||
|
Items = new ObservableCollection<Monster>();
|
||||||
|
LoadItemsCommand = new Command(async () => await ExecuteLoadItemsCommand());
|
||||||
|
|
||||||
|
//MessagingCenter.Subscribe<NewItemPage, Spell>(this, "AddItem", async (obj, item) =>
|
||||||
|
//{
|
||||||
|
// var _item = item as Item;
|
||||||
|
// Items.Add(_item);
|
||||||
|
// await DataStore.AddItemAsync(_item);
|
||||||
|
//});
|
||||||
|
}
|
||||||
|
|
||||||
|
async Task ExecuteLoadItemsCommand()
|
||||||
|
{
|
||||||
|
if (IsBusy)
|
||||||
|
return;
|
||||||
|
|
||||||
|
IsBusy = true;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//<option value="b">Barde</option>
|
||||||
|
//<option value="c">Clerc</option>
|
||||||
|
//<option value="d">Druide</option>
|
||||||
|
//<option value="s">Ensorceleur</option>
|
||||||
|
//<option value="w">Magicien</option>
|
||||||
|
//<option value="p">Paladin</option>
|
||||||
|
//<option value="r">Rôdeur</option>
|
||||||
|
//<option value="k">Sorcier</option>
|
||||||
|
|
||||||
|
Items.Clear();
|
||||||
|
var items = await new MonstersScrappers().GetMonsters();
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
Items.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.WriteLine(ex);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IsBusy = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -122,7 +122,7 @@ namespace AideDeJeu.ViewModels
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//Items.Clear();
|
//Items.Clear();
|
||||||
var item = await new Scrappers().GetSpell(Item.Id);
|
var item = await new SpellsScrappers().GetSpell(Item.Id);
|
||||||
Item = item;
|
Item = item;
|
||||||
//foreach (var item in items)
|
//foreach (var item in items)
|
||||||
//{
|
//{
|
||||||
|
|
|
||||||
|
|
@ -8,122 +8,14 @@
|
||||||
>
|
>
|
||||||
<MasterDetailPage.Master>
|
<MasterDetailPage.Master>
|
||||||
<ContentPage Title=" ">
|
<ContentPage Title=" ">
|
||||||
<StackLayout Orientation="Vertical" Padding="15">
|
|
||||||
<!--<StackLayout Orientation="Horizontal">
|
|
||||||
<Button Clicked="OnPlay" Image="ic_play.png" />
|
|
||||||
<Button Clicked="OnStop" Image="ic_stop.png" />
|
|
||||||
</StackLayout>-->
|
|
||||||
<!--<ListView x:Name="NavigationView" ItemsSource="{Binding MainMenu}">
|
|
||||||
<ListView.ItemTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<TextCell Text="{Binding Title}" TextColor="Black" Command="{Binding Path=BindingContext.OpenUrl, Source={x:Reference Name=This}}" CommandParameter="{Binding Url}" />
|
|
||||||
</DataTemplate>
|
|
||||||
</ListView.ItemTemplate>
|
|
||||||
</ListView>-->
|
|
||||||
<!--<Label Text="Liste" />
|
|
||||||
<Picker HorizontalOptions="FillAndExpand">
|
|
||||||
<Picker.Items>
|
|
||||||
<x:String>Sorts</x:String>
|
|
||||||
</Picker.Items>
|
|
||||||
</Picker>-->
|
|
||||||
|
|
||||||
<Label Text="Classe" Style="{StaticResource Key=subsubsection}" />
|
|
||||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Classes, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Classe}" />
|
|
||||||
|
|
||||||
<Label Text="Niveau minimum" Style="{StaticResource Key=subsubsection}" />
|
|
||||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Niveaux, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding NiveauMin}" />
|
|
||||||
|
|
||||||
<Label Text="Niveau maximum" Style="{StaticResource Key=subsubsection}" />
|
|
||||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Niveaux, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding NiveauMax}" />
|
|
||||||
|
|
||||||
<Label Text="École" Style="{StaticResource Key=subsubsection}" />
|
|
||||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Ecoles, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Ecole}" />
|
|
||||||
|
|
||||||
<Label Text="Rituel" Style="{StaticResource Key=subsubsection}" />
|
|
||||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Rituels, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Rituel}" />
|
|
||||||
|
|
||||||
<Label Text="Source" Style="{StaticResource Key=subsubsection}" />
|
|
||||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Sources, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Source}" />
|
|
||||||
</StackLayout>
|
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
</MasterDetailPage.Master>
|
</MasterDetailPage.Master>
|
||||||
<MasterDetailPage.Detail>
|
<MasterDetailPage.Detail>
|
||||||
<ContentPage>
|
<ContentPage>
|
||||||
<ContentPage.ToolbarItems>
|
<ContentPage.ToolbarItems>
|
||||||
<!--<ToolbarItem Name="Home" Text="Accueil" Order="Primary" Icon="ic_home.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/" />
|
|
||||||
<ToolbarItem Name="Spells" Text="Sorts" Order="Primary" Icon="ic_home.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/" />-->
|
|
||||||
<!--<ToolbarItem Name="Blog" Text="Blog" Order="Primary" Icon="ic_blog.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Blog/" />
|
|
||||||
<ToolbarItem Name="Wikis" Text="Wikis" Order="Primary" Icon="ic_wikis.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Wiki/" />
|
|
||||||
<ToolbarItem Name="Forum" Text="Forum" Order="Primary" Icon="ic_forum.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Forum/" />
|
|
||||||
|
|
||||||
<ToolbarItem Name="Gallery2" Text="Galerie" Order="Secondary" Icon="ic_gallery.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Media/" />
|
|
||||||
<ToolbarItem Name="Plays2" Text="Parties" Order="Secondary" Icon="ic_plays.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Wiki/Parties.MainPage.ashx" />
|
|
||||||
<ToolbarItem Name="Search2" Text="Rechercher" Order="Secondary" Icon="ic_search.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/search/default.aspx" />-->
|
|
||||||
<!--<ToolbarItem Text="Profil" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/forum/yaf_cp_profile.aspx" />
|
|
||||||
<ToolbarItem Text="Messages privés" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/forum/default.aspx?g=cp_pm" />
|
|
||||||
<ToolbarItem Text="Connexion" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/members/login.aspx" />
|
|
||||||
<ToolbarItem Text="Déconnexion" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/members/logout.aspx" />
|
|
||||||
<ToolbarItem Text="Inscription" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/members/register.aspx" />-->
|
|
||||||
</ContentPage.ToolbarItems>
|
</ContentPage.ToolbarItems>
|
||||||
<Grid>
|
<Grid>
|
||||||
<ListView x:Name="ItemsListView"
|
|
||||||
ItemsSource="{Binding Items}"
|
|
||||||
VerticalOptions="FillAndExpand"
|
|
||||||
HasUnevenRows="true"
|
|
||||||
RefreshCommand="{Binding LoadItemsCommand}"
|
|
||||||
IsPullToRefreshEnabled="true"
|
|
||||||
IsRefreshing="{Binding IsBusy, Mode=OneWay}"
|
|
||||||
CachingStrategy="RecycleElement"
|
|
||||||
ItemSelected="OnItemSelected">
|
|
||||||
<ListView.ItemTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<ViewCell>
|
|
||||||
<StackLayout Padding="10">
|
|
||||||
<Label Text="{Binding Title}"
|
|
||||||
LineBreakMode="NoWrap"
|
|
||||||
Style="{DynamicResource subsubsection}"
|
|
||||||
FontSize="16" />
|
|
||||||
<!--<Label Text="{Binding Description}"
|
|
||||||
LineBreakMode="NoWrap"
|
|
||||||
Style="{DynamicResource ListItemDetailTextStyle}"
|
|
||||||
FontSize="13" />-->
|
|
||||||
</StackLayout>
|
|
||||||
</ViewCell>
|
|
||||||
</DataTemplate>
|
|
||||||
</ListView.ItemTemplate>
|
|
||||||
</ListView>
|
|
||||||
<!--<WebView x:Name="MainView" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" Navigating="OnNavigating" Source="{Binding Source}" />-->
|
|
||||||
<!--<ActivityIndicator x:Name="aiProgress" Color="Black" IsRunning="True" IsVisible="True" />-->
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
</MasterDetailPage.Detail>
|
</MasterDetailPage.Detail>
|
||||||
</MasterDetailPage>
|
</MasterDetailPage>
|
||||||
|
|
||||||
<!--<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
|
||||||
xmlns:views="clr-namespace:AideDeJeu.Views"
|
|
||||||
x:Class="AideDeJeu.Views.MainPage">
|
|
||||||
<TabbedPage.Children>
|
|
||||||
<NavigationPage Title="Browse">
|
|
||||||
<NavigationPage.Icon>
|
|
||||||
<OnPlatform x:TypeArguments="FileImageSource">
|
|
||||||
<On Platform="iOS" Value="tab_feed.png"/>
|
|
||||||
</OnPlatform>
|
|
||||||
</NavigationPage.Icon>
|
|
||||||
<x:Arguments>
|
|
||||||
<views:ItemsPage />
|
|
||||||
</x:Arguments>
|
|
||||||
</NavigationPage>
|
|
||||||
|
|
||||||
<NavigationPage Title="About">
|
|
||||||
<NavigationPage.Icon>
|
|
||||||
<OnPlatform x:TypeArguments="FileImageSource">
|
|
||||||
<On Platform="iOS" Value="tab_about.png"/>
|
|
||||||
</OnPlatform>
|
|
||||||
</NavigationPage.Icon>
|
|
||||||
<x:Arguments>
|
|
||||||
<views:AboutPage />
|
|
||||||
</x:Arguments>
|
|
||||||
</NavigationPage>
|
|
||||||
</TabbedPage.Children>
|
|
||||||
</TabbedPage>-->
|
|
||||||
|
|
@ -1,51 +1,14 @@
|
||||||
using AideDeJeu.Models;
|
using Xamarin.Forms;
|
||||||
using AideDeJeu.ViewModels;
|
|
||||||
using AideDeJeuLib;
|
|
||||||
using AideDeJeuLib.Spells;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
using Xamarin.Forms;
|
|
||||||
using Xamarin.Forms.Xaml;
|
using Xamarin.Forms.Xaml;
|
||||||
|
|
||||||
namespace AideDeJeu.Views
|
namespace AideDeJeu.Views
|
||||||
{
|
{
|
||||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||||
public partial class MainPage : MasterDetailPage //TabbedPage
|
public partial class MainPage : MasterDetailPage
|
||||||
{
|
{
|
||||||
SpellsViewModel viewModel;
|
|
||||||
|
|
||||||
public MainPage ()
|
public MainPage ()
|
||||||
{
|
{
|
||||||
InitializeComponent ();
|
InitializeComponent ();
|
||||||
|
|
||||||
BindingContext = viewModel = new SpellsViewModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
async void OnItemSelected(object sender, SelectedItemChangedEventArgs args)
|
|
||||||
{
|
|
||||||
var item = args.SelectedItem as Spell;
|
|
||||||
if (item == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var spellvm = new SpellDetailViewModel(item);
|
|
||||||
spellvm.LoadItemCommand.Execute(null);
|
|
||||||
await Navigation.PushAsync(new SpellDetailPage(spellvm));
|
|
||||||
|
|
||||||
// Manually deselect item.
|
|
||||||
ItemsListView.SelectedItem = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
async void AddItem_Clicked(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
//await Navigation.PushModalAsync(new NavigationPage(new NewItemPage()));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnAppearing()
|
|
||||||
{
|
|
||||||
base.OnAppearing();
|
|
||||||
|
|
||||||
if (viewModel.Items.Count == 0)
|
|
||||||
viewModel.LoadItemsCommand.Execute(null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
50
AideDeJeu/AideDeJeu/Views/MonsterDetailPage.xaml
Normal file
50
AideDeJeu/AideDeJeu/Views/MonsterDetailPage.xaml
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
x:Class="AideDeJeu.Views.MonsterDetailPage"
|
||||||
|
Title="{Binding Title}">
|
||||||
|
<ScrollView>
|
||||||
|
<StackLayout Orientation="Vertical" Padding="15">
|
||||||
|
<Label Text="{Binding Item.Title}" Style="{StaticResource Key=subsubsection}" />
|
||||||
|
|
||||||
|
<Label Text=" " />
|
||||||
|
|
||||||
|
<Label FormattedText="{Binding TypeLevel}" />
|
||||||
|
<!--<StackLayout Orientation="Horizontal">
|
||||||
|
<Label Text="{Binding Item.Type}" Style="{StaticResource Key=contentital}" />
|
||||||
|
<Label Text="{Binding Item.Level, StringFormat='de niveau {0}'}" Style="{StaticResource Key=contentital}" />
|
||||||
|
</StackLayout>-->
|
||||||
|
|
||||||
|
<Label FormattedText="{Binding CastingTime}" />
|
||||||
|
<!--<StackLayout Orientation="Horizontal">
|
||||||
|
<Label Text="Durée d'incantation :" LineBreakMode="NoWrap" Style="{StaticResource Key=contentbold}" />
|
||||||
|
<Label Text="{Binding Item.CastingTime}" Style="{StaticResource Key=content}" />
|
||||||
|
</StackLayout>-->
|
||||||
|
|
||||||
|
|
||||||
|
<Label FormattedText="{Binding Range}" />
|
||||||
|
<!--<StackLayout Orientation="Horizontal">
|
||||||
|
<Label Text="Portée :" LineBreakMode="NoWrap" Style="{StaticResource Key=contentbold}" />
|
||||||
|
<Label Text="{Binding Item.Range}" Style="{StaticResource Key=content}" />
|
||||||
|
</StackLayout>-->
|
||||||
|
|
||||||
|
<Label FormattedText="{Binding Components}" />
|
||||||
|
<!--<StackLayout Orientation="Horizontal">
|
||||||
|
<Label Text="Composantes :" LineBreakMode="NoWrap" Style="{StaticResource Key=contentbold}" />
|
||||||
|
<Label Text="{Binding Item.Components}" Style="{StaticResource Key=content}" />
|
||||||
|
</StackLayout>-->
|
||||||
|
|
||||||
|
<Label FormattedText="{Binding Duration}" />
|
||||||
|
<!--<StackLayout Orientation="Horizontal">
|
||||||
|
<Label Text="Durée :" LineBreakMode="NoWrap" Style="{StaticResource Key=contentbold}" />
|
||||||
|
<Label Text="{Binding Item.Duration}" Style="{StaticResource Key=content}" />
|
||||||
|
</StackLayout>-->
|
||||||
|
|
||||||
|
<Label Text=" " />
|
||||||
|
|
||||||
|
<Label FormattedText="{Binding Description}" Style="{StaticResource Key=content}" />
|
||||||
|
|
||||||
|
<Label Text="{Binding Item.Source}" Style="{StaticResource Key=content}" />
|
||||||
|
</StackLayout>
|
||||||
|
</ScrollView>
|
||||||
|
</ContentPage>
|
||||||
40
AideDeJeu/AideDeJeu/Views/MonsterDetailPage.xaml.cs
Normal file
40
AideDeJeu/AideDeJeu/Views/MonsterDetailPage.xaml.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
using Xamarin.Forms;
|
||||||
|
using Xamarin.Forms.Xaml;
|
||||||
|
|
||||||
|
using AideDeJeu.Models;
|
||||||
|
using AideDeJeu.ViewModels;
|
||||||
|
using AideDeJeuLib;
|
||||||
|
using AideDeJeuLib.Spells;
|
||||||
|
using AideDeJeuLib.Monsters;
|
||||||
|
|
||||||
|
namespace AideDeJeu.Views
|
||||||
|
{
|
||||||
|
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||||
|
public partial class MonsterDetailPage : ContentPage
|
||||||
|
{
|
||||||
|
MonsterDetailViewModel viewModel;
|
||||||
|
|
||||||
|
public MonsterDetailPage(MonsterDetailViewModel viewModel)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
BindingContext = this.viewModel = viewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MonsterDetailPage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
var item = new Monster
|
||||||
|
{
|
||||||
|
Name = "",
|
||||||
|
//Description = "This is an item description."
|
||||||
|
};
|
||||||
|
|
||||||
|
viewModel = new MonsterDetailViewModel(item);
|
||||||
|
BindingContext = viewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
129
AideDeJeu/AideDeJeu/Views/MonstersPage.xaml
Normal file
129
AideDeJeu/AideDeJeu/Views/MonstersPage.xaml
Normal file
|
|
@ -0,0 +1,129 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
xmlns:local="clr-namespace:AideDeJeu.Views"
|
||||||
|
x:Class="AideDeJeu.Views.MonstersPage"
|
||||||
|
x:Name="This"
|
||||||
|
IsPresented="False"
|
||||||
|
>
|
||||||
|
<MasterDetailPage.Master>
|
||||||
|
<ContentPage Title=" ">
|
||||||
|
<StackLayout Orientation="Vertical" Padding="15">
|
||||||
|
<!--<StackLayout Orientation="Horizontal">
|
||||||
|
<Button Clicked="OnPlay" Image="ic_play.png" />
|
||||||
|
<Button Clicked="OnStop" Image="ic_stop.png" />
|
||||||
|
</StackLayout>-->
|
||||||
|
<!--<ListView x:Name="NavigationView" ItemsSource="{Binding MainMenu}">
|
||||||
|
<ListView.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<TextCell Text="{Binding Title}" TextColor="Black" Command="{Binding Path=BindingContext.OpenUrl, Source={x:Reference Name=This}}" CommandParameter="{Binding Url}" />
|
||||||
|
</DataTemplate>
|
||||||
|
</ListView.ItemTemplate>
|
||||||
|
</ListView>-->
|
||||||
|
<!--<Label Text="Liste" />
|
||||||
|
<Picker HorizontalOptions="FillAndExpand">
|
||||||
|
<Picker.Items>
|
||||||
|
<x:String>Sorts</x:String>
|
||||||
|
</Picker.Items>
|
||||||
|
</Picker>-->
|
||||||
|
|
||||||
|
<Label Text="Classe" Style="{StaticResource Key=subsubsection}" />
|
||||||
|
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Classes, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Classe}" />
|
||||||
|
|
||||||
|
<Label Text="Niveau minimum" Style="{StaticResource Key=subsubsection}" />
|
||||||
|
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Niveaux, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding NiveauMin}" />
|
||||||
|
|
||||||
|
<Label Text="Niveau maximum" Style="{StaticResource Key=subsubsection}" />
|
||||||
|
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Niveaux, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding NiveauMax}" />
|
||||||
|
|
||||||
|
<Label Text="École" Style="{StaticResource Key=subsubsection}" />
|
||||||
|
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Ecoles, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Ecole}" />
|
||||||
|
|
||||||
|
<Label Text="Rituel" Style="{StaticResource Key=subsubsection}" />
|
||||||
|
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Rituels, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Rituel}" />
|
||||||
|
|
||||||
|
<Label Text="Source" Style="{StaticResource Key=subsubsection}" />
|
||||||
|
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Sources, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Source}" />
|
||||||
|
</StackLayout>
|
||||||
|
</ContentPage>
|
||||||
|
</MasterDetailPage.Master>
|
||||||
|
<MasterDetailPage.Detail>
|
||||||
|
<ContentPage>
|
||||||
|
<ContentPage.ToolbarItems>
|
||||||
|
<!--<ToolbarItem Name="Home" Text="Accueil" Order="Primary" Icon="ic_home.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/" />
|
||||||
|
<ToolbarItem Name="Spells" Text="Sorts" Order="Primary" Icon="ic_home.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/" />-->
|
||||||
|
<!--<ToolbarItem Name="Blog" Text="Blog" Order="Primary" Icon="ic_blog.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Blog/" />
|
||||||
|
<ToolbarItem Name="Wikis" Text="Wikis" Order="Primary" Icon="ic_wikis.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Wiki/" />
|
||||||
|
<ToolbarItem Name="Forum" Text="Forum" Order="Primary" Icon="ic_forum.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Forum/" />
|
||||||
|
|
||||||
|
<ToolbarItem Name="Gallery2" Text="Galerie" Order="Secondary" Icon="ic_gallery.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Media/" />
|
||||||
|
<ToolbarItem Name="Plays2" Text="Parties" Order="Secondary" Icon="ic_plays.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Wiki/Parties.MainPage.ashx" />
|
||||||
|
<ToolbarItem Name="Search2" Text="Rechercher" Order="Secondary" Icon="ic_search.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/search/default.aspx" />-->
|
||||||
|
<!--<ToolbarItem Text="Profil" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/forum/yaf_cp_profile.aspx" />
|
||||||
|
<ToolbarItem Text="Messages privés" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/forum/default.aspx?g=cp_pm" />
|
||||||
|
<ToolbarItem Text="Connexion" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/members/login.aspx" />
|
||||||
|
<ToolbarItem Text="Déconnexion" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/members/logout.aspx" />
|
||||||
|
<ToolbarItem Text="Inscription" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/members/register.aspx" />-->
|
||||||
|
</ContentPage.ToolbarItems>
|
||||||
|
<Grid>
|
||||||
|
<ListView x:Name="ItemsListView"
|
||||||
|
ItemsSource="{Binding Items}"
|
||||||
|
VerticalOptions="FillAndExpand"
|
||||||
|
HasUnevenRows="true"
|
||||||
|
RefreshCommand="{Binding LoadItemsCommand}"
|
||||||
|
IsPullToRefreshEnabled="true"
|
||||||
|
IsRefreshing="{Binding IsBusy, Mode=OneWay}"
|
||||||
|
CachingStrategy="RecycleElement"
|
||||||
|
ItemSelected="OnItemSelected">
|
||||||
|
<ListView.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<ViewCell>
|
||||||
|
<StackLayout Padding="10">
|
||||||
|
<Label Text="{Binding Name}"
|
||||||
|
LineBreakMode="NoWrap"
|
||||||
|
Style="{DynamicResource subsubsection}"
|
||||||
|
FontSize="16" />
|
||||||
|
<!--<Label Text="{Binding Description}"
|
||||||
|
LineBreakMode="NoWrap"
|
||||||
|
Style="{DynamicResource ListItemDetailTextStyle}"
|
||||||
|
FontSize="13" />-->
|
||||||
|
</StackLayout>
|
||||||
|
</ViewCell>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListView.ItemTemplate>
|
||||||
|
</ListView>
|
||||||
|
<!--<WebView x:Name="MainView" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" Navigating="OnNavigating" Source="{Binding Source}" />-->
|
||||||
|
<!--<ActivityIndicator x:Name="aiProgress" Color="Black" IsRunning="True" IsVisible="True" />-->
|
||||||
|
</Grid>
|
||||||
|
</ContentPage>
|
||||||
|
</MasterDetailPage.Detail>
|
||||||
|
</MasterDetailPage>
|
||||||
|
|
||||||
|
<!--<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
xmlns:views="clr-namespace:AideDeJeu.Views"
|
||||||
|
x:Class="AideDeJeu.Views.MainPage">
|
||||||
|
<TabbedPage.Children>
|
||||||
|
<NavigationPage Title="Browse">
|
||||||
|
<NavigationPage.Icon>
|
||||||
|
<OnPlatform x:TypeArguments="FileImageSource">
|
||||||
|
<On Platform="iOS" Value="tab_feed.png"/>
|
||||||
|
</OnPlatform>
|
||||||
|
</NavigationPage.Icon>
|
||||||
|
<x:Arguments>
|
||||||
|
<views:ItemsPage />
|
||||||
|
</x:Arguments>
|
||||||
|
</NavigationPage>
|
||||||
|
|
||||||
|
<NavigationPage Title="About">
|
||||||
|
<NavigationPage.Icon>
|
||||||
|
<OnPlatform x:TypeArguments="FileImageSource">
|
||||||
|
<On Platform="iOS" Value="tab_about.png"/>
|
||||||
|
</OnPlatform>
|
||||||
|
</NavigationPage.Icon>
|
||||||
|
<x:Arguments>
|
||||||
|
<views:AboutPage />
|
||||||
|
</x:Arguments>
|
||||||
|
</NavigationPage>
|
||||||
|
</TabbedPage.Children>
|
||||||
|
</TabbedPage>-->
|
||||||
52
AideDeJeu/AideDeJeu/Views/MonstersPage.xaml.cs
Normal file
52
AideDeJeu/AideDeJeu/Views/MonstersPage.xaml.cs
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
using AideDeJeu.Models;
|
||||||
|
using AideDeJeu.ViewModels;
|
||||||
|
using AideDeJeuLib;
|
||||||
|
using AideDeJeuLib.Monsters;
|
||||||
|
using AideDeJeuLib.Spells;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
using Xamarin.Forms;
|
||||||
|
using Xamarin.Forms.Xaml;
|
||||||
|
|
||||||
|
namespace AideDeJeu.Views
|
||||||
|
{
|
||||||
|
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||||
|
public partial class MonstersPage : MasterDetailPage //TabbedPage
|
||||||
|
{
|
||||||
|
MonstersViewModel viewModel;
|
||||||
|
|
||||||
|
public MonstersPage ()
|
||||||
|
{
|
||||||
|
InitializeComponent ();
|
||||||
|
|
||||||
|
BindingContext = viewModel = new MonstersViewModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
async void OnItemSelected(object sender, SelectedItemChangedEventArgs args)
|
||||||
|
{
|
||||||
|
var item = args.SelectedItem as Monster;
|
||||||
|
if (item == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var spellvm = new MonsterDetailViewModel(item);
|
||||||
|
spellvm.LoadItemCommand.Execute(null);
|
||||||
|
await Navigation.PushAsync(new MonsterDetailPage(spellvm));
|
||||||
|
|
||||||
|
// Manually deselect item.
|
||||||
|
ItemsListView.SelectedItem = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async void AddItem_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//await Navigation.PushModalAsync(new NavigationPage(new NewItemPage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnAppearing()
|
||||||
|
{
|
||||||
|
base.OnAppearing();
|
||||||
|
|
||||||
|
if (viewModel.Items.Count == 0)
|
||||||
|
viewModel.LoadItemsCommand.Execute(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
129
AideDeJeu/AideDeJeu/Views/SpellsPage.xaml
Normal file
129
AideDeJeu/AideDeJeu/Views/SpellsPage.xaml
Normal file
|
|
@ -0,0 +1,129 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
xmlns:local="clr-namespace:AideDeJeu.Views"
|
||||||
|
x:Class="AideDeJeu.Views.SpellsPage"
|
||||||
|
x:Name="This"
|
||||||
|
IsPresented="False"
|
||||||
|
>
|
||||||
|
<MasterDetailPage.Master>
|
||||||
|
<ContentPage Title=" ">
|
||||||
|
<StackLayout Orientation="Vertical" Padding="15">
|
||||||
|
<!--<StackLayout Orientation="Horizontal">
|
||||||
|
<Button Clicked="OnPlay" Image="ic_play.png" />
|
||||||
|
<Button Clicked="OnStop" Image="ic_stop.png" />
|
||||||
|
</StackLayout>-->
|
||||||
|
<!--<ListView x:Name="NavigationView" ItemsSource="{Binding MainMenu}">
|
||||||
|
<ListView.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<TextCell Text="{Binding Title}" TextColor="Black" Command="{Binding Path=BindingContext.OpenUrl, Source={x:Reference Name=This}}" CommandParameter="{Binding Url}" />
|
||||||
|
</DataTemplate>
|
||||||
|
</ListView.ItemTemplate>
|
||||||
|
</ListView>-->
|
||||||
|
<!--<Label Text="Liste" />
|
||||||
|
<Picker HorizontalOptions="FillAndExpand">
|
||||||
|
<Picker.Items>
|
||||||
|
<x:String>Sorts</x:String>
|
||||||
|
</Picker.Items>
|
||||||
|
</Picker>-->
|
||||||
|
|
||||||
|
<Label Text="Classe" Style="{StaticResource Key=subsubsection}" />
|
||||||
|
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Classes, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Classe}" />
|
||||||
|
|
||||||
|
<Label Text="Niveau minimum" Style="{StaticResource Key=subsubsection}" />
|
||||||
|
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Niveaux, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding NiveauMin}" />
|
||||||
|
|
||||||
|
<Label Text="Niveau maximum" Style="{StaticResource Key=subsubsection}" />
|
||||||
|
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Niveaux, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding NiveauMax}" />
|
||||||
|
|
||||||
|
<Label Text="École" Style="{StaticResource Key=subsubsection}" />
|
||||||
|
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Ecoles, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Ecole}" />
|
||||||
|
|
||||||
|
<Label Text="Rituel" Style="{StaticResource Key=subsubsection}" />
|
||||||
|
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Rituels, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Rituel}" />
|
||||||
|
|
||||||
|
<Label Text="Source" Style="{StaticResource Key=subsubsection}" />
|
||||||
|
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Sources, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Source}" />
|
||||||
|
</StackLayout>
|
||||||
|
</ContentPage>
|
||||||
|
</MasterDetailPage.Master>
|
||||||
|
<MasterDetailPage.Detail>
|
||||||
|
<ContentPage>
|
||||||
|
<ContentPage.ToolbarItems>
|
||||||
|
<!--<ToolbarItem Name="Home" Text="Accueil" Order="Primary" Icon="ic_home.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/" />
|
||||||
|
<ToolbarItem Name="Spells" Text="Sorts" Order="Primary" Icon="ic_home.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/" />-->
|
||||||
|
<!--<ToolbarItem Name="Blog" Text="Blog" Order="Primary" Icon="ic_blog.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Blog/" />
|
||||||
|
<ToolbarItem Name="Wikis" Text="Wikis" Order="Primary" Icon="ic_wikis.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Wiki/" />
|
||||||
|
<ToolbarItem Name="Forum" Text="Forum" Order="Primary" Icon="ic_forum.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Forum/" />
|
||||||
|
|
||||||
|
<ToolbarItem Name="Gallery2" Text="Galerie" Order="Secondary" Icon="ic_gallery.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Media/" />
|
||||||
|
<ToolbarItem Name="Plays2" Text="Parties" Order="Secondary" Icon="ic_plays.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Wiki/Parties.MainPage.ashx" />
|
||||||
|
<ToolbarItem Name="Search2" Text="Rechercher" Order="Secondary" Icon="ic_search.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/search/default.aspx" />-->
|
||||||
|
<!--<ToolbarItem Text="Profil" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/forum/yaf_cp_profile.aspx" />
|
||||||
|
<ToolbarItem Text="Messages privés" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/forum/default.aspx?g=cp_pm" />
|
||||||
|
<ToolbarItem Text="Connexion" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/members/login.aspx" />
|
||||||
|
<ToolbarItem Text="Déconnexion" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/members/logout.aspx" />
|
||||||
|
<ToolbarItem Text="Inscription" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/members/register.aspx" />-->
|
||||||
|
</ContentPage.ToolbarItems>
|
||||||
|
<Grid>
|
||||||
|
<ListView x:Name="ItemsListView"
|
||||||
|
ItemsSource="{Binding Items}"
|
||||||
|
VerticalOptions="FillAndExpand"
|
||||||
|
HasUnevenRows="true"
|
||||||
|
RefreshCommand="{Binding LoadItemsCommand}"
|
||||||
|
IsPullToRefreshEnabled="true"
|
||||||
|
IsRefreshing="{Binding IsBusy, Mode=OneWay}"
|
||||||
|
CachingStrategy="RecycleElement"
|
||||||
|
ItemSelected="OnItemSelected">
|
||||||
|
<ListView.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<ViewCell>
|
||||||
|
<StackLayout Padding="10">
|
||||||
|
<Label Text="{Binding Title}"
|
||||||
|
LineBreakMode="NoWrap"
|
||||||
|
Style="{DynamicResource subsubsection}"
|
||||||
|
FontSize="16" />
|
||||||
|
<!--<Label Text="{Binding Description}"
|
||||||
|
LineBreakMode="NoWrap"
|
||||||
|
Style="{DynamicResource ListItemDetailTextStyle}"
|
||||||
|
FontSize="13" />-->
|
||||||
|
</StackLayout>
|
||||||
|
</ViewCell>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListView.ItemTemplate>
|
||||||
|
</ListView>
|
||||||
|
<!--<WebView x:Name="MainView" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" Navigating="OnNavigating" Source="{Binding Source}" />-->
|
||||||
|
<!--<ActivityIndicator x:Name="aiProgress" Color="Black" IsRunning="True" IsVisible="True" />-->
|
||||||
|
</Grid>
|
||||||
|
</ContentPage>
|
||||||
|
</MasterDetailPage.Detail>
|
||||||
|
</MasterDetailPage>
|
||||||
|
|
||||||
|
<!--<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
xmlns:views="clr-namespace:AideDeJeu.Views"
|
||||||
|
x:Class="AideDeJeu.Views.MainPage">
|
||||||
|
<TabbedPage.Children>
|
||||||
|
<NavigationPage Title="Browse">
|
||||||
|
<NavigationPage.Icon>
|
||||||
|
<OnPlatform x:TypeArguments="FileImageSource">
|
||||||
|
<On Platform="iOS" Value="tab_feed.png"/>
|
||||||
|
</OnPlatform>
|
||||||
|
</NavigationPage.Icon>
|
||||||
|
<x:Arguments>
|
||||||
|
<views:ItemsPage />
|
||||||
|
</x:Arguments>
|
||||||
|
</NavigationPage>
|
||||||
|
|
||||||
|
<NavigationPage Title="About">
|
||||||
|
<NavigationPage.Icon>
|
||||||
|
<OnPlatform x:TypeArguments="FileImageSource">
|
||||||
|
<On Platform="iOS" Value="tab_about.png"/>
|
||||||
|
</OnPlatform>
|
||||||
|
</NavigationPage.Icon>
|
||||||
|
<x:Arguments>
|
||||||
|
<views:AboutPage />
|
||||||
|
</x:Arguments>
|
||||||
|
</NavigationPage>
|
||||||
|
</TabbedPage.Children>
|
||||||
|
</TabbedPage>-->
|
||||||
51
AideDeJeu/AideDeJeu/Views/SpellsPage.xaml.cs
Normal file
51
AideDeJeu/AideDeJeu/Views/SpellsPage.xaml.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
using AideDeJeu.Models;
|
||||||
|
using AideDeJeu.ViewModels;
|
||||||
|
using AideDeJeuLib;
|
||||||
|
using AideDeJeuLib.Spells;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
using Xamarin.Forms;
|
||||||
|
using Xamarin.Forms.Xaml;
|
||||||
|
|
||||||
|
namespace AideDeJeu.Views
|
||||||
|
{
|
||||||
|
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||||
|
public partial class SpellsPage : MasterDetailPage //TabbedPage
|
||||||
|
{
|
||||||
|
SpellsViewModel viewModel;
|
||||||
|
|
||||||
|
public SpellsPage ()
|
||||||
|
{
|
||||||
|
InitializeComponent ();
|
||||||
|
|
||||||
|
BindingContext = viewModel = new SpellsViewModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
async void OnItemSelected(object sender, SelectedItemChangedEventArgs args)
|
||||||
|
{
|
||||||
|
var item = args.SelectedItem as Spell;
|
||||||
|
if (item == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var spellvm = new SpellDetailViewModel(item);
|
||||||
|
spellvm.LoadItemCommand.Execute(null);
|
||||||
|
await Navigation.PushAsync(new SpellDetailPage(spellvm));
|
||||||
|
|
||||||
|
// Manually deselect item.
|
||||||
|
ItemsListView.SelectedItem = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async void AddItem_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//await Navigation.PushModalAsync(new NavigationPage(new NewItemPage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnAppearing()
|
||||||
|
{
|
||||||
|
base.OnAppearing();
|
||||||
|
|
||||||
|
if (viewModel.Items.Count == 0)
|
||||||
|
viewModel.LoadItemsCommand.Execute(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -10,8 +10,4 @@
|
||||||
<PackageReference Include="HtmlAgilityPack" Version="1.8.1" />
|
<PackageReference Include="HtmlAgilityPack" Version="1.8.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Monsters\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
68
AideDeJeu/AideDeJeuLib/Monsters/Monster.cs
Normal file
68
AideDeJeu/AideDeJeuLib/Monsters/Monster.cs
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
using HtmlAgilityPack;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace AideDeJeuLib.Monsters
|
||||||
|
{
|
||||||
|
public class Monster
|
||||||
|
{
|
||||||
|
public string Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string NameVO { get; set; }
|
||||||
|
public string Power { get; set; }
|
||||||
|
public string Type { get; set; }
|
||||||
|
public string Size { get; set; }
|
||||||
|
public string Alignment { get; set; }
|
||||||
|
public string Legendary { get; set; }
|
||||||
|
public string Source { get; set; }
|
||||||
|
public string ArmorClass { get; set; }
|
||||||
|
public string HitPoints { get; set; }
|
||||||
|
public string Speed { get; set; }
|
||||||
|
public string Strength { get; set; }
|
||||||
|
public string Dexterity { get; set; }
|
||||||
|
public string Constitution { get; set; }
|
||||||
|
public string Intelligence { get; set; }
|
||||||
|
public string Wisdom { get; set; }
|
||||||
|
public string Charisma { get; set; }
|
||||||
|
public string SavingThrows { get; set; }
|
||||||
|
public string Skills { get; set; }
|
||||||
|
public string Senses { get; set; }
|
||||||
|
public string Languages { get; set; }
|
||||||
|
public string Challenge { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
public string Picture { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static Monster FromHtml(HtmlNode nodeMonster)
|
||||||
|
{
|
||||||
|
var monster = new Monster();
|
||||||
|
var divMonster = nodeMonster.SelectSingleNode("div[@class='monstre']");
|
||||||
|
monster.Name = divMonster.SelectSingleNode("h1").InnerText;
|
||||||
|
monster.NameVO = divMonster.SelectSingleNode("div[@class='trad']/a").InnerText;
|
||||||
|
var divSansSerif = divMonster.SelectSingleNode("div[@class='sansSerif']");
|
||||||
|
var typeSizeAlignment = divSansSerif.SelectSingleNode("h2/em").InnerText;
|
||||||
|
var matchesTypeSizeAlignment = new Regex("(?<type>.*) de taille (?<size>.*), (?<alignment>.*)").Match(typeSizeAlignment);
|
||||||
|
monster.Type = matchesTypeSizeAlignment.Groups["type"].Value;
|
||||||
|
monster.Size = matchesTypeSizeAlignment.Groups["size"].Value;
|
||||||
|
monster.Alignment = matchesTypeSizeAlignment.Groups["alignment"].Value;
|
||||||
|
var divRed = divSansSerif.SelectSingleNode("div[@class='red']");
|
||||||
|
monster.Strength = divRed.SelectSingleNode("strong").NextSibling.InnerText;
|
||||||
|
//monster.LevelType = nodeSpell.SelectSingleNode("h2/em").InnerText;
|
||||||
|
//monster.Level = spell.LevelType.Split(new string[] { " - " }, StringSplitOptions.None)[0].Split(' ')[1];
|
||||||
|
//monster.Type = spell.LevelType.Split(new string[] { " - " }, StringSplitOptions.None)[1];
|
||||||
|
//monster.CastingTime = nodeSpell.SelectSingleNode("div[@class='paragraphe']").InnerText.Split(new string[] { " : " }, StringSplitOptions.None)[1];
|
||||||
|
//monster.Range = nodeSpell.SelectSingleNode("div[strong/text()='Portée']").InnerText.Split(new string[] { " : " }, StringSplitOptions.None)[1];
|
||||||
|
//monster.Components = nodeSpell.SelectSingleNode("div[strong/text()='Composantes']").InnerText.Split(new string[] { " : " }, StringSplitOptions.None)[1];
|
||||||
|
//monster.Duration = nodeSpell.SelectSingleNode("div[strong/text()='Durée']").InnerText.Split(new string[] { " : " }, StringSplitOptions.None)[1];
|
||||||
|
//monster.DescriptionDiv = nodeSpell.SelectSingleNode("div[contains(@class,'description')]");
|
||||||
|
//monster.Overflow = nodeSpell.SelectSingleNode("div[@class='overflow']")?.InnerText;
|
||||||
|
//monster.NoOverflow = nodeSpell.SelectSingleNode("div[@class='nooverflow']")?.InnerText;
|
||||||
|
//monster.Source = nodeSpell.SelectSingleNode("div[@class='source']").InnerText;
|
||||||
|
return monster;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
75
AideDeJeu/AideDeJeuLib/Monsters/MonstersScrappers.cs
Normal file
75
AideDeJeu/AideDeJeuLib/Monsters/MonstersScrappers.cs
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
using HtmlAgilityPack;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AideDeJeuLib.Monsters
|
||||||
|
{
|
||||||
|
public class MonstersScrappers
|
||||||
|
{
|
||||||
|
public HttpClient GetHttpClient()
|
||||||
|
{
|
||||||
|
var client = new HttpClient();
|
||||||
|
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("text/html"));
|
||||||
|
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xhtml+xml"));
|
||||||
|
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml"));
|
||||||
|
client.DefaultRequestHeaders.AcceptLanguage.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("fr"));
|
||||||
|
client.DefaultRequestHeaders.AcceptLanguage.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("fr-FR"));
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<Monster>> GetMonsters(string categorie = "", string type = "", string niveauMin = "", string niveauMax = "", string taille = "", string legendaire = "", string source = "srd")
|
||||||
|
{
|
||||||
|
string html = null;
|
||||||
|
using (var client = GetHttpClient())
|
||||||
|
{
|
||||||
|
// https://www.aidedd.org/regles/monstres/?min=.25&max=20&c=M&sz=TP&lg=si&t=Humano%C3%AFde&s=srd
|
||||||
|
|
||||||
|
html = await client.GetStringAsync(string.Format($"https://www.aidedd.org/regles/monstres/?c={categorie}&t={type}&min={niveauMin}&max={niveauMax}&sz={taille}&lg={legendaire}&s={source}", categorie, type, niveauMin, niveauMax, taille, legendaire, source));
|
||||||
|
}
|
||||||
|
var pack = new HtmlDocument();
|
||||||
|
pack.LoadHtml(html);
|
||||||
|
var trs = pack.GetElementbyId("liste").Element("table").Elements("tr").ToList();
|
||||||
|
var monsters = new List<Monster>();
|
||||||
|
foreach (var tr in trs)
|
||||||
|
{
|
||||||
|
var tds = tr.Elements("td").ToArray();
|
||||||
|
if (tds.Length > 0)
|
||||||
|
{
|
||||||
|
var monster = new Monster();
|
||||||
|
monster.Name = tds[0].InnerText;
|
||||||
|
var href = tds[0].Element("a").GetAttributeValue("href", "");
|
||||||
|
var regex = new Regex("vf=(?<id>.*)");
|
||||||
|
monster.Id = regex.Match(href).Groups["id"].Value;
|
||||||
|
monster.Power = tds[1].InnerText;
|
||||||
|
monster.Type = tds[2].InnerText;
|
||||||
|
monster.Size = tds[3].InnerText;
|
||||||
|
monster.Alignment = tds[4].InnerText;
|
||||||
|
monster.Legendary = tds[5].InnerText;
|
||||||
|
monsters.Add(monster);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return monsters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Monster> GetMonster(string id)
|
||||||
|
{
|
||||||
|
string html = null;
|
||||||
|
using (var client = GetHttpClient())
|
||||||
|
{
|
||||||
|
// https://www.aidedd.org/dnd/monstres.php?vf=aarakocra
|
||||||
|
|
||||||
|
html = await client.GetStringAsync(string.Format($"https://www.aidedd.org/dnd/monstres.php?vf={id}", id));
|
||||||
|
}
|
||||||
|
var pack = new HtmlDocument();
|
||||||
|
pack.LoadHtml(html);
|
||||||
|
var divBloc = pack.DocumentNode.SelectNodes("//div[contains(@class,'bloc')]").FirstOrDefault();
|
||||||
|
return Monster.FromHtml(divBloc);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -10,7 +10,7 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace AideDeJeuLib.Spells
|
namespace AideDeJeuLib.Spells
|
||||||
{
|
{
|
||||||
public class Scrappers
|
public class SpellsScrappers
|
||||||
{
|
{
|
||||||
public HttpClient GetHttpClient()
|
public HttpClient GetHttpClient()
|
||||||
{
|
{
|
||||||
Loading…
Add table
Add a link
Reference in a new issue