diff --git a/AideDeJeu/AideDeJeu/AideDeJeu.csproj b/AideDeJeu/AideDeJeu/AideDeJeu.csproj index d7ea06a8..cc18baa3 100644 --- a/AideDeJeu/AideDeJeu/AideDeJeu.csproj +++ b/AideDeJeu/AideDeJeu/AideDeJeu.csproj @@ -36,11 +36,8 @@ Code - - MonsterDetailPage.xaml - - - SpellDetailPage.xaml + + ItemDetailPage.xaml MainPage.xaml diff --git a/AideDeJeu/AideDeJeu/ViewModels/ItemDetailViewModel.cs b/AideDeJeu/AideDeJeu/ViewModels/ItemDetailViewModel.cs new file mode 100644 index 00000000..47240540 --- /dev/null +++ b/AideDeJeu/AideDeJeu/ViewModels/ItemDetailViewModel.cs @@ -0,0 +1,218 @@ +using AideDeJeu.Tools; +using AideDeJeuLib; +using AideDeJeuLib.Monsters; +using System; +using System.Diagnostics; +using System.Threading.Tasks; +using Xamarin.Forms; + +namespace AideDeJeu.ViewModels +{ + public class ItemDetailViewModel : BaseViewModel + { + Item _Item = null; + public Item Item + { + get { return _Item; } + set + { + SetProperty(ref _Item, value); + //OnPropertyChanged(nameof(TypeSizeAlignment)); + //OnPropertyChanged(nameof(ArmorClass)); + //OnPropertyChanged(nameof(HitPoints)); + //OnPropertyChanged(nameof(Speed)); + //OnPropertyChanged(nameof(SavingThrows)); + //OnPropertyChanged(nameof(Skills)); + //OnPropertyChanged(nameof(DamageVulnerabilities)); + //OnPropertyChanged(nameof(DamageResistances)); + //OnPropertyChanged(nameof(DamageImmunities)); + //OnPropertyChanged(nameof(ConditionImmunities)); + //OnPropertyChanged(nameof(Senses)); + //OnPropertyChanged(nameof(Languages)); + //OnPropertyChanged(nameof(Challenge)); + //OnPropertyChanged(nameof(Duration)); + //OnPropertyChanged(nameof(Duration)); + } + } + + //public FormattedString TypeSizeAlignment + //{ + // get + // { + // var fd = FormatedTextHelpers.FontData.FromResource("contentital"); + // var fs = new FormattedString(); + // fs.Spans.Add(new Span() { Text = string.Format("{0} de taille {1}, {2}", Item.Type, Item.Size, Item.Alignment), FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); + // return fs; + // } + //} + + //public FormattedString ArmorClass + //{ + // get + // { + // var fd = FormatedTextHelpers.FontData.FromResource("content"); + // var fs = new FormattedString(); + // fs.Spans.Add(new Span() { Text = string.Format("Classe d'armure {0}", Item.ArmorClass), FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); + // return fs; + // } + //} + + //public FormattedString HitPoints + //{ + // get + // { + // var fd = FormatedTextHelpers.FontData.FromResource("content"); + // var fs = new FormattedString(); + // fs.Spans.Add(new Span() { Text = string.Format("Points de vie {0}", Item.HitPoints), FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); + // return fs; + // } + //} + + //public FormattedString Speed + //{ + // get + // { + // var fd = FormatedTextHelpers.FontData.FromResource("content"); + // var fs = new FormattedString(); + // fs.Spans.Add(new Span() { Text = string.Format("Vitesse {0}", Item.Speed), FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); + // return fs; + // } + //} + + //public FormattedString SavingThrows + //{ + // get + // { + // var fd = FormatedTextHelpers.FontData.FromResource("content"); + // var fdb = FormatedTextHelpers.FontData.FromResource("contentbold"); + // var fs = new FormattedString(); + // fs.Spans.Add(new Span() { Text = "Jets de sauvegarde ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor }); + // fs.Spans.Add(new Span() { Text = Item.SavingThrows, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); + // return fs; + // } + //} + + //public FormattedString Skills + //{ + // get + // { + // var fd = FormatedTextHelpers.FontData.FromResource("content"); + // var fdb = FormatedTextHelpers.FontData.FromResource("contentbold"); + // var fs = new FormattedString(); + // fs.Spans.Add(new Span() { Text = "Compétence ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor }); + // fs.Spans.Add(new Span() { Text = Item.Skills, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); + // return fs; + // } + //} + + + //public FormattedString DamageVulnerabilities + //{ + // get + // { + // var fd = FormatedTextHelpers.FontData.FromResource("content"); + // var fdb = FormatedTextHelpers.FontData.FromResource("contentbold"); + // var fs = new FormattedString(); + // fs.Spans.Add(new Span() { Text = "Vulnérabilité aux dégâts ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor }); + // fs.Spans.Add(new Span() { Text = Item.DamageVulnerabilities, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); + // return fs; + // } + //} + + //public FormattedString DamageImmunities + //{ + // get + // { + // var fd = FormatedTextHelpers.FontData.FromResource("content"); + // var fdb = FormatedTextHelpers.FontData.FromResource("contentbold"); + // var fs = new FormattedString(); + // fs.Spans.Add(new Span() { Text = "Immunité contre les dégâts ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor }); + // fs.Spans.Add(new Span() { Text = Item.DamageImmunities, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); + // return fs; + // } + //} + + //public FormattedString ConditionImmunities + //{ + // get + // { + // var fd = FormatedTextHelpers.FontData.FromResource("content"); + // var fdb = FormatedTextHelpers.FontData.FromResource("contentbold"); + // var fs = new FormattedString(); + // fs.Spans.Add(new Span() { Text = "Immunité contre les états ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor }); + // fs.Spans.Add(new Span() { Text = Item.ConditionImmunities, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); + // return fs; + // } + //} + + //public FormattedString DamageResistances + //{ + // get + // { + // var fd = FormatedTextHelpers.FontData.FromResource("content"); + // var fdb = FormatedTextHelpers.FontData.FromResource("contentbold"); + // var fs = new FormattedString(); + // fs.Spans.Add(new Span() { Text = "Résistance aux dégâts ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor }); + // fs.Spans.Add(new Span() { Text = Item.DamageResistances, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); + // return fs; + // } + //} + + + + //public FormattedString Senses + //{ + // get + // { + // var fd = FormatedTextHelpers.FontData.FromResource("content"); + // var fdb = FormatedTextHelpers.FontData.FromResource("contentbold"); + // var fs = new FormattedString(); + // fs.Spans.Add(new Span() { Text = "Sens ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor }); + // fs.Spans.Add(new Span() { Text = Item.Senses, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); + // return fs; + // } + //} + + //public FormattedString Languages + //{ + // get + // { + // var fd = FormatedTextHelpers.FontData.FromResource("content"); + // var fdb = FormatedTextHelpers.FontData.FromResource("contentbold"); + // var fs = new FormattedString(); + // fs.Spans.Add(new Span() { Text = "Langues ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor }); + // fs.Spans.Add(new Span() { Text = Item.Languages, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); + // return fs; + // } + //} + + //public FormattedString Challenge + //{ + // get + // { + // var fd = FormatedTextHelpers.FontData.FromResource("content"); + // var fdb = FormatedTextHelpers.FontData.FromResource("contentbold"); + // var fs = new FormattedString(); + // fs.Spans.Add(new Span() { Text = "Dangerosité ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor }); + // fs.Spans.Add(new Span() { Text = Item.Challenge, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); + // return fs; + // } + //} + + public Command LoadItemCommand { get; set; } + + public ItemDetailViewModel(Item item = null) + { + Title = item?.Name; + Item = item; + LoadItemCommand = new Command(async () => await ExecuteLoadItemCommand()); + } + async Task ExecuteLoadItemCommand() + { + } + } + + + + +} diff --git a/AideDeJeu/AideDeJeu/ViewModels/ItemsViewModel.cs b/AideDeJeu/AideDeJeu/ViewModels/ItemsViewModel.cs index a2003b56..3ad4cbce 100644 --- a/AideDeJeu/AideDeJeu/ViewModels/ItemsViewModel.cs +++ b/AideDeJeu/AideDeJeu/ViewModels/ItemsViewModel.cs @@ -13,7 +13,7 @@ using System.Linq; namespace AideDeJeu.ViewModels { - public abstract class ItemsViewModel : BaseViewModel + public class ItemsViewModel : BaseViewModel { CancellationTokenSource cancellationTokenSource; @@ -23,7 +23,10 @@ namespace AideDeJeu.ViewModels LoadItemsCommand = new Command(async () => await ExecuteLoadItemsCommandAsync().ConfigureAwait(false)); } public ICommand LoadItemsCommand { get; protected set; } - public abstract Task ExecuteGotoItemCommandAsync(Item item); + public async Task ExecuteGotoItemCommandAsync(Item item) + { + await Main.Navigator.GotoItemDetailPageAsync(item); + } protected ItemSourceType ItemSourceType; diff --git a/AideDeJeu/AideDeJeu/ViewModels/MainViewModel.cs b/AideDeJeu/AideDeJeu/ViewModels/MainViewModel.cs index 7e0512e8..ec5f2a7a 100644 --- a/AideDeJeu/AideDeJeu/ViewModels/MainViewModel.cs +++ b/AideDeJeu/AideDeJeu/ViewModels/MainViewModel.cs @@ -27,13 +27,10 @@ namespace AideDeJeu.ViewModels { Spell = 0x01, Monster = 0x10, - //VF = 0x0100, VO = 0x1100, HD = 0x1000, - //SpellVF = Spell | VF, SpellVO = Spell | VO, SpellHD = Spell | HD, - //MonsterVF = Monster | VF, MonsterVO = Monster | VO, MonsterHD = Monster | HD, } @@ -64,12 +61,10 @@ namespace AideDeJeu.ViewModels public Dictionary> AllItemsViewModel = new Dictionary>() { - //{ ItemSourceType.SpellVF, new Lazy(() => new SpellsViewModel(ItemSourceType.SpellVF)) }, - { ItemSourceType.SpellVO, new Lazy(() => new SpellsViewModel(ItemSourceType.SpellVO)) }, - { ItemSourceType.SpellHD, new Lazy(() => new SpellsViewModel(ItemSourceType.SpellHD)) }, - //{ ItemSourceType.MonsterVF, new Lazy(() => new MonstersViewModel(ItemSourceType.MonsterVF)) }, - { ItemSourceType.MonsterVO, new Lazy(() => new MonstersViewModel(ItemSourceType.MonsterVO)) }, - { ItemSourceType.MonsterHD, new Lazy(() => new MonstersViewModel(ItemSourceType.MonsterHD)) }, + { ItemSourceType.SpellVO, new Lazy(() => new ItemsViewModel(ItemSourceType.SpellVO)) }, + { ItemSourceType.SpellHD, new Lazy(() => new ItemsViewModel(ItemSourceType.SpellHD)) }, + { ItemSourceType.MonsterVO, new Lazy(() => new ItemsViewModel(ItemSourceType.MonsterVO)) }, + { ItemSourceType.MonsterHD, new Lazy(() => new ItemsViewModel(ItemSourceType.MonsterHD)) }, }; public ItemsViewModel GetItemsViewModel(ItemSourceType itemSourceType) @@ -79,10 +74,8 @@ namespace AideDeJeu.ViewModels public Dictionary> AllFiltersViewModel = new Dictionary>() { - //{ ItemSourceType.SpellVF, new Lazy(() => new VFSpellFilterViewModel()) }, { ItemSourceType.SpellVO, new Lazy(() => new VOSpellFilterViewModel()) }, { ItemSourceType.SpellHD, new Lazy(() => new HDSpellFilterViewModel()) }, - //{ ItemSourceType.MonsterVF, new Lazy(() => new VFMonsterFilterViewModel()) }, { ItemSourceType.MonsterVO, new Lazy(() => new VOMonsterFilterViewModel()) }, { ItemSourceType.MonsterHD, new Lazy(() => new HDMonsterFilterViewModel()) }, }; @@ -171,7 +164,7 @@ namespace AideDeJeu.ViewModels var spell = spells.Where(i => Tools.Helpers.IdFromName(i.Name) == anchor).FirstOrDefault(); if (spell != null) { - await Navigator.GotoSpellDetailPageAsync(spell); + await Navigator.GotoItemDetailPageAsync(spell); } } else if (file == "spells_vo") @@ -180,7 +173,7 @@ namespace AideDeJeu.ViewModels var spell = spells.Where(i => Tools.Helpers.IdFromName(i.Name) == anchor).FirstOrDefault(); if (spell != null) { - await Navigator.GotoSpellDetailPageAsync(spell); + await Navigator.GotoItemDetailPageAsync(spell); } } else if (file == "monsters_hd") @@ -189,7 +182,7 @@ namespace AideDeJeu.ViewModels var monster = monsters.Where(i => Tools.Helpers.IdFromName(i.Name) == anchor).FirstOrDefault(); if (monster != null) { - await Navigator.GotoMonsterDetailPageAsync(monster); + await Navigator.GotoItemDetailPageAsync(monster); } } else if (file == "monsters_vo") @@ -198,7 +191,7 @@ namespace AideDeJeu.ViewModels var monster = monsters.Where(i => Tools.Helpers.IdFromName(i.Name) == anchor).FirstOrDefault(); if (monster != null) { - await Navigator.GotoMonsterDetailPageAsync(monster); + await Navigator.GotoItemDetailPageAsync(monster); } } else diff --git a/AideDeJeu/AideDeJeu/ViewModels/MonsterDetailViewModel.cs b/AideDeJeu/AideDeJeu/ViewModels/MonsterDetailViewModel.cs deleted file mode 100644 index d2528515..00000000 --- a/AideDeJeu/AideDeJeu/ViewModels/MonsterDetailViewModel.cs +++ /dev/null @@ -1,217 +0,0 @@ -using AideDeJeu.Tools; -using AideDeJeuLib.Monsters; -using System; -using System.Diagnostics; -using System.Threading.Tasks; -using Xamarin.Forms; - -namespace AideDeJeu.ViewModels -{ - public class MonsterDetailViewModel : BaseViewModel - { - Monster _Item = null; - public Monster Item - { - get { return _Item; } - set - { - SetProperty(ref _Item, value); - OnPropertyChanged(nameof(TypeSizeAlignment)); - OnPropertyChanged(nameof(ArmorClass)); - OnPropertyChanged(nameof(HitPoints)); - OnPropertyChanged(nameof(Speed)); - OnPropertyChanged(nameof(SavingThrows)); - OnPropertyChanged(nameof(Skills)); - OnPropertyChanged(nameof(DamageVulnerabilities)); - OnPropertyChanged(nameof(DamageResistances)); - OnPropertyChanged(nameof(DamageImmunities)); - OnPropertyChanged(nameof(ConditionImmunities)); - OnPropertyChanged(nameof(Senses)); - OnPropertyChanged(nameof(Languages)); - OnPropertyChanged(nameof(Challenge)); - //OnPropertyChanged(nameof(Duration)); - //OnPropertyChanged(nameof(Duration)); - } - } - - public FormattedString TypeSizeAlignment - { - get - { - var fd = FormatedTextHelpers.FontData.FromResource("contentital"); - var fs = new FormattedString(); - fs.Spans.Add(new Span() { Text = string.Format("{0} de taille {1}, {2}", Item.Type, Item.Size, Item.Alignment), FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); - return fs; - } - } - - public FormattedString ArmorClass - { - get - { - var fd = FormatedTextHelpers.FontData.FromResource("content"); - var fs = new FormattedString(); - fs.Spans.Add(new Span() { Text = string.Format("Classe d'armure {0}", Item.ArmorClass), FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); - return fs; - } - } - - public FormattedString HitPoints - { - get - { - var fd = FormatedTextHelpers.FontData.FromResource("content"); - var fs = new FormattedString(); - fs.Spans.Add(new Span() { Text = string.Format("Points de vie {0}", Item.HitPoints), FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); - return fs; - } - } - - public FormattedString Speed - { - get - { - var fd = FormatedTextHelpers.FontData.FromResource("content"); - var fs = new FormattedString(); - fs.Spans.Add(new Span() { Text = string.Format("Vitesse {0}", Item.Speed), FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); - return fs; - } - } - - public FormattedString SavingThrows - { - get - { - var fd = FormatedTextHelpers.FontData.FromResource("content"); - var fdb = FormatedTextHelpers.FontData.FromResource("contentbold"); - var fs = new FormattedString(); - fs.Spans.Add(new Span() { Text = "Jets de sauvegarde ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor }); - fs.Spans.Add(new Span() { Text = Item.SavingThrows, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); - return fs; - } - } - - public FormattedString Skills - { - get - { - var fd = FormatedTextHelpers.FontData.FromResource("content"); - var fdb = FormatedTextHelpers.FontData.FromResource("contentbold"); - var fs = new FormattedString(); - fs.Spans.Add(new Span() { Text = "Compétence ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor }); - fs.Spans.Add(new Span() { Text = Item.Skills, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); - return fs; - } - } - - - public FormattedString DamageVulnerabilities - { - get - { - var fd = FormatedTextHelpers.FontData.FromResource("content"); - var fdb = FormatedTextHelpers.FontData.FromResource("contentbold"); - var fs = new FormattedString(); - fs.Spans.Add(new Span() { Text = "Vulnérabilité aux dégâts ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor }); - fs.Spans.Add(new Span() { Text = Item.DamageVulnerabilities, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); - return fs; - } - } - - public FormattedString DamageImmunities - { - get - { - var fd = FormatedTextHelpers.FontData.FromResource("content"); - var fdb = FormatedTextHelpers.FontData.FromResource("contentbold"); - var fs = new FormattedString(); - fs.Spans.Add(new Span() { Text = "Immunité contre les dégâts ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor }); - fs.Spans.Add(new Span() { Text = Item.DamageImmunities, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); - return fs; - } - } - - public FormattedString ConditionImmunities - { - get - { - var fd = FormatedTextHelpers.FontData.FromResource("content"); - var fdb = FormatedTextHelpers.FontData.FromResource("contentbold"); - var fs = new FormattedString(); - fs.Spans.Add(new Span() { Text = "Immunité contre les états ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor }); - fs.Spans.Add(new Span() { Text = Item.ConditionImmunities, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); - return fs; - } - } - - public FormattedString DamageResistances - { - get - { - var fd = FormatedTextHelpers.FontData.FromResource("content"); - var fdb = FormatedTextHelpers.FontData.FromResource("contentbold"); - var fs = new FormattedString(); - fs.Spans.Add(new Span() { Text = "Résistance aux dégâts ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor }); - fs.Spans.Add(new Span() { Text = Item.DamageResistances, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); - return fs; - } - } - - - - public FormattedString Senses - { - get - { - var fd = FormatedTextHelpers.FontData.FromResource("content"); - var fdb = FormatedTextHelpers.FontData.FromResource("contentbold"); - var fs = new FormattedString(); - fs.Spans.Add(new Span() { Text = "Sens ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor }); - fs.Spans.Add(new Span() { Text = Item.Senses, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); - return fs; - } - } - - public FormattedString Languages - { - get - { - var fd = FormatedTextHelpers.FontData.FromResource("content"); - var fdb = FormatedTextHelpers.FontData.FromResource("contentbold"); - var fs = new FormattedString(); - fs.Spans.Add(new Span() { Text = "Langues ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor }); - fs.Spans.Add(new Span() { Text = Item.Languages, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor }); - return fs; - } - } - - public FormattedString Challenge - { - get - { - var fd = FormatedTextHelpers.FontData.FromResource("content"); - var fdb = FormatedTextHelpers.FontData.FromResource("contentbold"); - var fs = new FormattedString(); - fs.Spans.Add(new Span() { Text = "Dangerosité ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor }); - fs.Spans.Add(new Span() { Text = Item.Challenge, 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() - { - } - } - - - - -} diff --git a/AideDeJeu/AideDeJeu/ViewModels/MonstersViewModel.cs b/AideDeJeu/AideDeJeu/ViewModels/MonstersViewModel.cs deleted file mode 100644 index 63b8879d..00000000 --- a/AideDeJeu/AideDeJeu/ViewModels/MonstersViewModel.cs +++ /dev/null @@ -1,27 +0,0 @@ -using AideDeJeu.Tools; -using AideDeJeuLib; -using AideDeJeuLib.Monsters; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Runtime.Serialization.Json; -using System.Threading.Tasks; - -namespace AideDeJeu.ViewModels -{ - public class MonstersViewModel : ItemsViewModel - { - public MonstersViewModel(ItemSourceType itemSourceType) : base(itemSourceType) - { - } - - public override async Task ExecuteGotoItemCommandAsync(Item item) - { - await Main.Navigator.GotoMonsterDetailPageAsync(item as Monster); - } - } -} \ No newline at end of file diff --git a/AideDeJeu/AideDeJeu/ViewModels/Navigator.cs b/AideDeJeu/AideDeJeu/ViewModels/Navigator.cs index 5dcb89dc..ab52af6f 100644 --- a/AideDeJeu/AideDeJeu/ViewModels/Navigator.cs +++ b/AideDeJeu/AideDeJeu/ViewModels/Navigator.cs @@ -14,8 +14,7 @@ namespace AideDeJeu.ViewModels public interface INavigator { Task GotoAboutPageAsync(); - Task GotoMonsterDetailPageAsync(Item item); - Task GotoSpellDetailPageAsync(Item item); + Task GotoItemDetailPageAsync(Item item); } public class Navigator : INavigator { @@ -31,26 +30,14 @@ namespace AideDeJeu.ViewModels await Navigation.PushAsync(new Views.AboutPage()); } - public async Task GotoMonsterDetailPageAsync(Item item) + public async Task GotoItemDetailPageAsync(Item item) { - var monster = item as Monster; if (item == null) return; - var vm = new MonsterDetailViewModel(monster); + var vm = new ItemDetailViewModel(item); vm.LoadItemCommand.Execute(null); - await Navigation.PushAsync(new MonsterDetailPage(vm)); - } - - public async Task GotoSpellDetailPageAsync(Item item) - { - var spell = item as Spell; - if (item == null) - return; - - var vm = new SpellDetailViewModel(spell); - vm.LoadItemCommand.Execute(null); - await Navigation.PushAsync(new SpellDetailPage(vm)); + await Navigation.PushAsync(new ItemDetailPage(vm)); } diff --git a/AideDeJeu/AideDeJeu/ViewModels/SpellDetailViewModel.cs b/AideDeJeu/AideDeJeu/ViewModels/SpellDetailViewModel.cs deleted file mode 100644 index fb5f4a8a..00000000 --- a/AideDeJeu/AideDeJeu/ViewModels/SpellDetailViewModel.cs +++ /dev/null @@ -1,110 +0,0 @@ -using AideDeJeu.Tools; -using AideDeJeuLib.Spells; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Diagnostics; -using System.Linq; -using System.Threading.Tasks; -using Xamarin.Forms; - -namespace AideDeJeu.ViewModels -{ - public class SpellDetailViewModel : BaseViewModel - { - Spell _Item = null; - public Spell Item - { - get { return _Item; } - set - { - SetProperty(ref _Item, value); - OnPropertyChanged(nameof(TypeLevel)); - OnPropertyChanged(nameof(CastingTime)); - OnPropertyChanged(nameof(Range)); - OnPropertyChanged(nameof(Components)); - OnPropertyChanged(nameof(Duration)); - } - } - - 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} {2}", capType, Item?.Level, Item?.Rituel), 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 SpellDetailViewModel(Spell item = null) - { - Title = item?.Name; - Item = item; - LoadItemCommand = new Command(async () => await ExecuteLoadItemCommand()); - } - async Task ExecuteLoadItemCommand() - { - } - } - - - - -} diff --git a/AideDeJeu/AideDeJeu/ViewModels/SpellsViewModel.cs b/AideDeJeu/AideDeJeu/ViewModels/SpellsViewModel.cs deleted file mode 100644 index c9b0649f..00000000 --- a/AideDeJeu/AideDeJeu/ViewModels/SpellsViewModel.cs +++ /dev/null @@ -1,27 +0,0 @@ -using AideDeJeuLib; -using AideDeJeuLib.Spells; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Runtime.Serialization.Json; -using System.Threading.Tasks; - -namespace AideDeJeu.ViewModels -{ - public class SpellsViewModel : ItemsViewModel - { - public SpellsViewModel(ItemSourceType itemSourceType) : base(itemSourceType) - { - } - - public override async Task ExecuteGotoItemCommandAsync(Item item) - { - await Main.Navigator.GotoSpellDetailPageAsync(item as Spell); - } - - } -} \ No newline at end of file diff --git a/AideDeJeu/AideDeJeu/Views/ItemDetailPage.xaml b/AideDeJeu/AideDeJeu/Views/ItemDetailPage.xaml new file mode 100644 index 00000000..c8088a59 --- /dev/null +++ b/AideDeJeu/AideDeJeu/Views/ItemDetailPage.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/AideDeJeu/AideDeJeu/Views/MonsterDetailPage.xaml.cs b/AideDeJeu/AideDeJeu/Views/ItemDetailPage.xaml.cs similarity index 90% rename from AideDeJeu/AideDeJeu/Views/MonsterDetailPage.xaml.cs rename to AideDeJeu/AideDeJeu/Views/ItemDetailPage.xaml.cs index 46686168..685a6b3b 100644 --- a/AideDeJeu/AideDeJeu/Views/MonsterDetailPage.xaml.cs +++ b/AideDeJeu/AideDeJeu/Views/ItemDetailPage.xaml.cs @@ -12,19 +12,20 @@ using System.Linq; using AideDeJeuLib.Spells; using System.Text; using System.Globalization; +using AideDeJeuLib; namespace AideDeJeu.Views { [XamlCompilation(XamlCompilationOptions.Compile)] - public partial class MonsterDetailPage : ContentPage + public partial class ItemDetailPage : ContentPage { - MonsterDetailViewModel viewModel; + ItemDetailViewModel viewModel; - public MonsterDetailPage(MonsterDetailViewModel viewModel) + public ItemDetailPage(ItemDetailViewModel itemVM) { InitializeComponent(); - BindingContext = this.viewModel = viewModel; + BindingContext = this.viewModel = itemVM; mdMarkdown.NavigateToLink = async (s) => await viewModel.Main.NavigateToLink(s); //mdNameVO.NavigateToLink = async (s) => await viewModel.Main.NavigateToLink(s); @@ -34,7 +35,7 @@ namespace AideDeJeu.Views //mdLegendaryActions.NavigateToLink = async (s) => await viewModel.Main.NavigateToLink(s); } - public MonsterDetailPage() + public ItemDetailPage() { InitializeComponent(); @@ -45,7 +46,7 @@ namespace AideDeJeu.Views //Description = "This is an item description." }; - viewModel = new MonsterDetailViewModel(item); + viewModel = new ItemDetailViewModel(item); BindingContext = viewModel; } diff --git a/AideDeJeu/AideDeJeu/Views/MonsterDetailPage.xaml b/AideDeJeu/AideDeJeu/Views/MonsterDetailPage.xaml deleted file mode 100644 index 4db697bb..00000000 --- a/AideDeJeu/AideDeJeu/Views/MonsterDetailPage.xaml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/AideDeJeu/AideDeJeu/Views/SpellDetailPage.xaml b/AideDeJeu/AideDeJeu/Views/SpellDetailPage.xaml deleted file mode 100644 index 2b10bdb6..00000000 --- a/AideDeJeu/AideDeJeu/Views/SpellDetailPage.xaml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/AideDeJeu/AideDeJeu/Views/SpellDetailPage.xaml.cs b/AideDeJeu/AideDeJeu/Views/SpellDetailPage.xaml.cs deleted file mode 100644 index 8385ebe2..00000000 --- a/AideDeJeu/AideDeJeu/Views/SpellDetailPage.xaml.cs +++ /dev/null @@ -1,46 +0,0 @@ - -using AideDeJeu.ViewModels; -using AideDeJeuLib.Spells; -using Xamarin.Forms; -using Xamarin.Forms.Xaml; - -namespace AideDeJeu.Views -{ - [XamlCompilation(XamlCompilationOptions.Compile)] - public partial class SpellDetailPage : ContentPage - { - SpellDetailViewModel viewModel; - - public SpellDetailPage(SpellDetailViewModel viewModel) - { - InitializeComponent(); - - BindingContext = this.viewModel = viewModel; - - //mdNameVO.NavigateToLink = async (s) => await viewModel.Main.NavigateToLink(s); - mdDescription.NavigateToLink = async (s) => await viewModel.Main.NavigateToLink(s); - - } - - public SpellDetailPage() - { - InitializeComponent(); - - var item = new SpellHD - { - Name = "", - NameVO = "", - //Description = "This is an item description." - }; - - viewModel = new SpellDetailViewModel(item); - BindingContext = viewModel; - } - - private void ListView_ItemTapped(object sender, ItemTappedEventArgs e) - { - if (e.Item == null) return; - ((ListView)sender).SelectedItem = null; - } - } -} \ No newline at end of file