mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-10-30 23:16:09 +00:00 
			
		
		
		
	Début grosse refonte pour gestion vf/vo/hd
This commit is contained in:
		
							parent
							
								
									3e707e57b7
								
							
						
					
					
						commit
						64e236bb8f
					
				
					 14 changed files with 628 additions and 321 deletions
				
			
		|  | @ -12,6 +12,9 @@ EndProject | |||
| Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AideDeJeu", "AideDeJeu\AideDeJeu\AideDeJeu.csproj", "{C0597D88-5C09-4314-80A3-64712B02D0E9}" | ||||
| EndProject | ||||
| Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AideDeJeuWeb", "AideDeJeu\AideDeJeuWeb\AideDeJeuWeb.csproj", "{D5065DC7-7B51-4D25-8FA5-DDF0F3E6FCE4}" | ||||
| 	ProjectSection(ProjectDependencies) = postProject | ||||
| 		{C0597D88-5C09-4314-80A3-64712B02D0E9} = {C0597D88-5C09-4314-80A3-64712B02D0E9} | ||||
| 	EndProjectSection | ||||
| EndProject | ||||
| Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AideDeJeuCmd", "AideDeJeu\AideDeJeuCmd\AideDeJeuCmd.csproj", "{9DDAEA8E-7B4F-4CC1-80FC-0D511D230689}" | ||||
| 	ProjectSection(ProjectDependencies) = postProject | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| using System; | ||||
| 
 | ||||
| using AideDeJeu.ViewModels; | ||||
| using AideDeJeu.Views; | ||||
| using Xamarin.Forms; | ||||
| using Xamarin.Forms.Xaml; | ||||
|  | @ -14,7 +14,11 @@ namespace AideDeJeu | |||
| 		{ | ||||
| 			InitializeComponent(); | ||||
| 
 | ||||
|             MainPage = new MainPage(); | ||||
|             DependencyService.Register<MainViewModel>(); | ||||
|             var vm = DependencyService.Get<MainViewModel>(); | ||||
|             var mainPage = new MainPage(); | ||||
|             vm.Navigator = new Navigator(mainPage.Detail.Navigation); | ||||
|             MainPage = mainPage; | ||||
|         } | ||||
| 
 | ||||
|         protected override void OnStart () | ||||
|  |  | |||
|  | @ -1,4 +1,5 @@ | |||
| using HtmlAgilityPack; | ||||
| using AideDeJeu.ViewModels; | ||||
| using HtmlAgilityPack; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Globalization; | ||||
|  | @ -96,12 +97,12 @@ namespace AideDeJeu.Tools | |||
| 
 | ||||
|         public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||||
|         { | ||||
|             var itemType = value as ViewModels.MainViewModel.ItemType?; | ||||
|             if (itemType == ViewModels.MainViewModel.ItemType.Spell) | ||||
|             var itemType = value as ItemType?; | ||||
|             if (itemType == ItemType.Spell) | ||||
|             { | ||||
|                 return SpellsTemplate; | ||||
|             } | ||||
|             if (itemType == ViewModels.MainViewModel.ItemType.Monster) | ||||
|             if (itemType == ItemType.Monster) | ||||
|             { | ||||
|                 return MonstersTemplate; | ||||
|             } | ||||
|  | @ -121,12 +122,12 @@ namespace AideDeJeu.Tools | |||
| 
 | ||||
|         public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||||
|         { | ||||
|             var itemType = value as ViewModels.MainViewModel.ItemType?; | ||||
|             if (itemType == ViewModels.MainViewModel.ItemType.Spell) | ||||
|             var itemType = value as ItemType?; | ||||
|             if (itemType == ItemType.Spell) | ||||
|             { | ||||
|                 return Spells; | ||||
|             } | ||||
|             if (itemType == ViewModels.MainViewModel.ItemType.Monster) | ||||
|             if (itemType == ItemType.Monster) | ||||
|             { | ||||
|                 return Monsters; | ||||
|             } | ||||
|  | @ -140,4 +141,81 @@ namespace AideDeJeu.Tools | |||
|     } | ||||
| 
 | ||||
|     public class ItemTypeToStringConverter : ItemTypeConverter<string> { } | ||||
| 
 | ||||
| 
 | ||||
|     public class ItemSourceTypeConverter<T> : IValueConverter | ||||
|     { | ||||
|         public T SpellVF { get; set; } | ||||
|         public T SpellVO { get; set; } | ||||
|         public T SpellHD { get; set; } | ||||
|         public T MonsterVF { get; set; } | ||||
|         public T MonsterVO { get; set; } | ||||
|         public T MonsterHD { get; set; } | ||||
| 
 | ||||
|         public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||||
|         { | ||||
|             //var itemType = value as ItemSourceType?; | ||||
|             //if (itemType == ItemSourceType.SpellVF) | ||||
|             //{ | ||||
|             //    return SpellVF; | ||||
|             //} | ||||
|             //if (itemType == ItemSourceType.SpellVO) | ||||
|             //{ | ||||
|             //    return SpellVO; | ||||
|             //} | ||||
|             //if (itemType == ItemSourceType.SpellHD) | ||||
|             //{ | ||||
|             //    return SpellHD; | ||||
|             //} | ||||
|             //if (itemType == ItemSourceType.MonsterVF) | ||||
|             //{ | ||||
|             //    return MonsterVF; | ||||
|             //} | ||||
|             //if (itemType == ItemSourceType.MonsterVO) | ||||
|             //{ | ||||
|             //    return MonsterVO; | ||||
|             //} | ||||
|             //if (itemType == ItemSourceType.MonsterHD) | ||||
|             //{ | ||||
|             //    return MonsterHD; | ||||
|             //} | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||||
|         { | ||||
|             return null; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public class ItemSourceTypeToItemsConverter : IValueConverter | ||||
|     { | ||||
|         public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||||
|         { | ||||
|             var vm = DependencyService.Get<MainViewModel>(); | ||||
|             var itemSourceType = vm.ItemSourceType; | ||||
|             return vm.GetItemsViewModel(itemSourceType); | ||||
|         } | ||||
| 
 | ||||
|         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||||
|         { | ||||
|             return null; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public class ItemSourceTypeToFilterConverter : IValueConverter | ||||
|     { | ||||
|         public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||||
|         { | ||||
|             var vm = DependencyService.Get<MainViewModel>(); | ||||
|             var itemSourceType = vm.ItemSourceType; | ||||
|             return vm.GetFilterViewModel(itemSourceType); | ||||
|         } | ||||
| 
 | ||||
|         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||||
|         { | ||||
|             return null; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  |  | |||
							
								
								
									
										21
									
								
								AideDeJeu/AideDeJeu/Tools/Helpers.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								AideDeJeu/AideDeJeu/Tools/Helpers.cs
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,21 @@ | |||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Reflection; | ||||
| using System.Runtime.Serialization.Json; | ||||
| using System.Text; | ||||
| 
 | ||||
| namespace AideDeJeu.Tools | ||||
| { | ||||
|     public static class Helpers | ||||
|     { | ||||
|         public static T GetResourceObject<T>(string resourceName) where T : class | ||||
|         { | ||||
|             var serializer = new DataContractJsonSerializer(typeof(T)); | ||||
|             var assembly = typeof(Helpers).GetTypeInfo().Assembly; | ||||
|             using (var stream = assembly.GetManifestResourceStream(resourceName)) | ||||
|             { | ||||
|                 return serializer.ReadObject(stream) as T; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | @ -12,8 +12,13 @@ namespace AideDeJeu.ViewModels | |||
| { | ||||
|     public class BaseViewModel : INotifyPropertyChanged | ||||
|     { | ||||
|         //public SpellsScrappers SpellsScrappers => DependencyService.Get<SpellsScrappers>() ?? new SpellsScrappers(); | ||||
|         //public MonstersScrappers MonstersScrappers => DependencyService.Get<MonstersScrappers>() ?? new MonstersScrappers(); | ||||
|         public MainViewModel Main | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return DependencyService.Get<MainViewModel>(); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         bool isBusy = false; | ||||
|         public bool IsBusy | ||||
|  |  | |||
							
								
								
									
										310
									
								
								AideDeJeu/AideDeJeu/ViewModels/FilterViewModel.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										310
									
								
								AideDeJeu/AideDeJeu/ViewModels/FilterViewModel.cs
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,310 @@ | |||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Text; | ||||
| using System.Windows.Input; | ||||
| 
 | ||||
| namespace AideDeJeu.ViewModels | ||||
| { | ||||
|     public abstract class FilterViewModel : BaseViewModel | ||||
|     { | ||||
|         public ICommand LoadItemsCommand { get; protected set; } | ||||
|     } | ||||
| 
 | ||||
|     #region Spells | ||||
|     public abstract class SpellFilterViewModel : FilterViewModel | ||||
|     { | ||||
|         public abstract List<KeyValuePair<string, string>> Classes { get; } | ||||
| 
 | ||||
|         public abstract List<KeyValuePair<string, string>> Niveaux { get; } | ||||
| 
 | ||||
|         public abstract List<KeyValuePair<string, string>> Ecoles { get; } | ||||
| 
 | ||||
|         public abstract List<KeyValuePair<string, string>> Rituels { get; } | ||||
| 
 | ||||
|         public abstract List<KeyValuePair<string, string>> Sources { get; } | ||||
| 
 | ||||
| 
 | ||||
|         private int _Classe = 0; | ||||
|         public int Classe | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return _Classe; | ||||
|             } | ||||
|             set | ||||
|             { | ||||
|                 if (_Classe != value) | ||||
|                 { | ||||
|                     SetProperty(ref _Classe, value); | ||||
|                     LoadItemsCommand.Execute(null); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         private int _NiveauMin = 0; | ||||
|         public int NiveauMin | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return _NiveauMin; | ||||
|             } | ||||
|             set | ||||
|             { | ||||
|                 if (_NiveauMin != value) | ||||
|                 { | ||||
|                     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 | ||||
|             { | ||||
|                 if (_NiveauMax != value) | ||||
|                 { | ||||
|                     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 | ||||
|             { | ||||
|                 if (_Ecole != value) | ||||
|                 { | ||||
|                     SetProperty(ref _Ecole, value); | ||||
|                     LoadItemsCommand.Execute(null); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         private int _Rituel = 0; | ||||
|         public int Rituel | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return _Rituel; | ||||
|             } | ||||
|             set | ||||
|             { | ||||
|                 if (_Rituel != value) | ||||
|                 { | ||||
|                     SetProperty(ref _Rituel, value); | ||||
|                     LoadItemsCommand.Execute(null); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         private int _Source = 1; | ||||
|         public int Source | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return _Source; | ||||
|             } | ||||
|             set | ||||
|             { | ||||
|                 if (_Source != value) | ||||
|                 { | ||||
|                     SetProperty(ref _Source, value); | ||||
|                     LoadItemsCommand.Execute(null); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     public class VFSpellFilterViewModel : SpellFilterViewModel | ||||
|     { | ||||
| 
 | ||||
|         public override List<KeyValuePair<string, string>> Classes { get; } = new List<KeyValuePair<string, string>>() | ||||
|         { | ||||
|             new KeyValuePair<string, string>("", "Toutes" ), | ||||
|             new KeyValuePair<string, string>("Barde", "Barde" ), | ||||
|             new KeyValuePair<string, string>("Clerc", "Clerc" ), | ||||
|             new KeyValuePair<string, string>("Druide", "Druide" ), | ||||
|             new KeyValuePair<string, string>("Ensorceleur", "Ensorceleur" ), | ||||
|             new KeyValuePair<string, string>("Magicien", "Magicien" ), | ||||
|             new KeyValuePair<string, string>("Paladin", "Paladin" ), | ||||
|             new KeyValuePair<string, string>("Rôdeur", "Rôdeur" ), | ||||
|             new KeyValuePair<string, string>("Sorcier", "Sorcier" ), | ||||
|         }; | ||||
| 
 | ||||
|         public override List<KeyValuePair<string, string>> Niveaux { get; } = new List<KeyValuePair<string, string>>() | ||||
|         { | ||||
|             new KeyValuePair<string, string>("0", "Sorts mineurs"), | ||||
|             new KeyValuePair<string, string>("1", "Niveau 1"), | ||||
|             new KeyValuePair<string, string>("2", "Niveau 2"), | ||||
|             new KeyValuePair<string, string>("3", "Niveau 3"), | ||||
|             new KeyValuePair<string, string>("4", "Niveau 4"), | ||||
|             new KeyValuePair<string, string>("5", "Niveau 5"), | ||||
|             new KeyValuePair<string, string>("6", "Niveau 6"), | ||||
|             new KeyValuePair<string, string>("7", "Niveau 7"), | ||||
|             new KeyValuePair<string, string>("8", "Niveau 8"), | ||||
|             new KeyValuePair<string, string>("9", "Niveau 9"), | ||||
|         }; | ||||
| 
 | ||||
|         public override List<KeyValuePair<string, string>> Ecoles { get; } = 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>("évocation", "Évocation"), | ||||
|             new KeyValuePair<string, string>("illusion", "Illusion"), | ||||
|             new KeyValuePair<string, string>("invocation", "Invocation"), | ||||
|             new KeyValuePair<string, string>("cromancie", "Nécromancie"), | ||||
|             new KeyValuePair<string, string>("transmutation", "Transmutation"), | ||||
|         }; | ||||
| 
 | ||||
|         public override List<KeyValuePair<string, string>> Rituels { get; } = new List<KeyValuePair<string, string>>() | ||||
|         { | ||||
|             new KeyValuePair<string, string>("", "Tous"), | ||||
|             new KeyValuePair<string, string>("(rituel)", "Rituel"), | ||||
|         }; | ||||
| 
 | ||||
|         public override List<KeyValuePair<string, string>> Sources { get; } = new List<KeyValuePair<string, string>>() | ||||
|         { | ||||
|             new KeyValuePair<string, string>("", "Toutes"), | ||||
|             new KeyValuePair<string, string>("(SRD)", "SRD"), | ||||
|         }; | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     public class VOSpellFilterViewModel : SpellFilterViewModel | ||||
|     { | ||||
|         public override List<KeyValuePair<string, string>> Classes { get; } = new List<KeyValuePair<string, string>>() | ||||
|         { | ||||
|             new KeyValuePair<string, string>("", "All" ), | ||||
|             new KeyValuePair<string, string>("Bard", "Bard" ), | ||||
|             new KeyValuePair<string, string>("Cleric", "Cleric" ), | ||||
|             new KeyValuePair<string, string>("Druid", "Druid" ), | ||||
|             new KeyValuePair<string, string>("Ensorceleur", "Ensorceleur" ), | ||||
|             new KeyValuePair<string, string>("Wizard", "Wizard" ), | ||||
|             new KeyValuePair<string, string>("Paladin", "Paladin" ), | ||||
|             new KeyValuePair<string, string>("Rôdeur", "Rôdeur" ), | ||||
|             new KeyValuePair<string, string>("Sorcier", "Sorcier" ), | ||||
|         }; | ||||
| 
 | ||||
|         public override List<KeyValuePair<string, string>> Niveaux { get; } = new List<KeyValuePair<string, string>>() | ||||
|         { | ||||
|             new KeyValuePair<string, string>("0", "Sorts mineurs"), | ||||
|             new KeyValuePair<string, string>("1", "Level 1"), | ||||
|             new KeyValuePair<string, string>("2", "Level 2"), | ||||
|             new KeyValuePair<string, string>("3", "Level 3"), | ||||
|             new KeyValuePair<string, string>("4", "Level 4"), | ||||
|             new KeyValuePair<string, string>("5", "Level 5"), | ||||
|             new KeyValuePair<string, string>("6", "Level 6"), | ||||
|             new KeyValuePair<string, string>("7", "Level 7"), | ||||
|             new KeyValuePair<string, string>("8", "Level 8"), | ||||
|             new KeyValuePair<string, string>("9", "Level 9"), | ||||
|         }; | ||||
| 
 | ||||
|         public override List<KeyValuePair<string, string>> Ecoles { get; } = new List<KeyValuePair<string, string>>() | ||||
|         { | ||||
|             new KeyValuePair<string, string>("", "All"), | ||||
|             new KeyValuePair<string, string>("abjuration", "Abjuration"), | ||||
|             new KeyValuePair<string, string>("divination", "Divination"), | ||||
|             new KeyValuePair<string, string>("enchantement", "Enchantement"), | ||||
|             new KeyValuePair<string, string>("évocation", "Evocation"), | ||||
|             new KeyValuePair<string, string>("illusion", "Illusion"), | ||||
|             new KeyValuePair<string, string>("invocation", "Invocation"), | ||||
|             new KeyValuePair<string, string>("necromancie", "Necromancie"), | ||||
|             new KeyValuePair<string, string>("transmutation", "Transmutation"), | ||||
|         }; | ||||
| 
 | ||||
|         public override List<KeyValuePair<string, string>> Rituels { get; } = new List<KeyValuePair<string, string>>() | ||||
|         { | ||||
|             new KeyValuePair<string, string>("", "All"), | ||||
|             new KeyValuePair<string, string>("(rituel)", "Rituel"), | ||||
|         }; | ||||
| 
 | ||||
|         public override List<KeyValuePair<string, string>> Sources { get; } = new List<KeyValuePair<string, string>>() | ||||
|         { | ||||
|             new KeyValuePair<string, string>("", "All"), | ||||
|             new KeyValuePair<string, string>("(SRD)", "SRD"), | ||||
|         }; | ||||
|     } | ||||
| 
 | ||||
|     public class HDSpellFilterViewModel : SpellFilterViewModel | ||||
|     { | ||||
|         public override List<KeyValuePair<string, string>> Classes { get; } = new List<KeyValuePair<string, string>>() | ||||
|         { | ||||
|             new KeyValuePair<string, string>("", "Toutes" ), | ||||
|             new KeyValuePair<string, string>("Barde", "Barde" ), | ||||
|             new KeyValuePair<string, string>("Clerc", "Clerc" ), | ||||
|             new KeyValuePair<string, string>("Druide", "Druide" ), | ||||
|             new KeyValuePair<string, string>("Ensorceleur", "Ensorceleur" ), | ||||
|             new KeyValuePair<string, string>("Magicien", "Magicien" ), | ||||
|             new KeyValuePair<string, string>("Ombrelame", "Ombrelame" ), | ||||
|             new KeyValuePair<string, string>("Paladin", "Paladin" ), | ||||
|             new KeyValuePair<string, string>("Rôdeur", "Rôdeur" ), | ||||
|             new KeyValuePair<string, string>("Sorcier", "Sorcier" ), | ||||
|         }; | ||||
| 
 | ||||
|         public override List<KeyValuePair<string, string>> Niveaux { get; } = new List<KeyValuePair<string, string>>() | ||||
|         { | ||||
|             new KeyValuePair<string, string>("0", "Sorts mineurs"), | ||||
|             new KeyValuePair<string, string>("1", "Niveau 1"), | ||||
|             new KeyValuePair<string, string>("2", "Niveau 2"), | ||||
|             new KeyValuePair<string, string>("3", "Niveau 3"), | ||||
|             new KeyValuePair<string, string>("4", "Niveau 4"), | ||||
|             new KeyValuePair<string, string>("5", "Niveau 5"), | ||||
|             new KeyValuePair<string, string>("6", "Niveau 6"), | ||||
|             new KeyValuePair<string, string>("7", "Niveau 7"), | ||||
|             new KeyValuePair<string, string>("8", "Niveau 8"), | ||||
|             new KeyValuePair<string, string>("9", "Niveau 9"), | ||||
|         }; | ||||
| 
 | ||||
|         public override List<KeyValuePair<string, string>> Ecoles { get; } = 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>("évocation", "Évocation"), | ||||
|             new KeyValuePair<string, string>("illusion", "Illusion"), | ||||
|             new KeyValuePair<string, string>("invocation", "Invocation"), | ||||
|             new KeyValuePair<string, string>("cromancie", "Nécromancie"), | ||||
|             new KeyValuePair<string, string>("transmutation", "Transmutation"), | ||||
|         }; | ||||
| 
 | ||||
|         public override List<KeyValuePair<string, string>> Rituels { get; } = new List<KeyValuePair<string, string>>() | ||||
|         { | ||||
|             new KeyValuePair<string, string>("", "Tous"), | ||||
|             new KeyValuePair<string, string>("(rituel)", "Rituel"), | ||||
|         }; | ||||
| 
 | ||||
|         public override List<KeyValuePair<string, string>> Sources { get; } = new List<KeyValuePair<string, string>>() | ||||
|         { | ||||
|             new KeyValuePair<string, string>("", "Toutes"), | ||||
|             new KeyValuePair<string, string>("(SRD)", "SRD"), | ||||
|             new KeyValuePair<string, string>("(HD)", "H&D"), | ||||
|         }; | ||||
|     } | ||||
|     #endregion Spells | ||||
| 
 | ||||
|     #region Monsters | ||||
|     public class MonsterFilterViewModel : FilterViewModel | ||||
|     { | ||||
| 
 | ||||
|     } | ||||
|     #endregion Monsters | ||||
| } | ||||
|  | @ -8,44 +8,41 @@ namespace AideDeJeu.ViewModels | |||
| { | ||||
|     public abstract class ItemsViewModel : BaseViewModel | ||||
|     { | ||||
|         public ItemsViewModel(INavigator navigator, ObservableCollection<Item> items) | ||||
|         public ItemsViewModel() | ||||
|         { | ||||
|             Navigator = navigator; | ||||
|             Items = items; | ||||
|             LoadItemsCommand = new Command(async () => await ExecuteLoadItemsCommandAsync()); | ||||
|             LoadItemsCommand = new Command(() => ExecuteLoadItemsCommand(null)); | ||||
|         } | ||||
|         protected ObservableCollection<Item> AllItems { get; set; } = new ObservableCollection<Item>(); | ||||
|         public ObservableCollection<Item> Items { get; protected set; } | ||||
|         public ICommand LoadItemsCommand { get; protected set; } | ||||
|         public abstract Task ExecuteLoadItemsCommandAsync(); | ||||
|         public abstract void ExecuteLoadItemsCommand(FilterViewModel filterViewModel); | ||||
|         public abstract Task ExecuteGotoItemCommandAsync(Item item); | ||||
|         protected INavigator Navigator { get; set; } | ||||
| 
 | ||||
|         private string _SearchText = ""; | ||||
|         public string SearchText | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return _SearchText; | ||||
|             } | ||||
|             set | ||||
|             { | ||||
|                 SetProperty(ref _SearchText, value); | ||||
|                 FilterItems(); | ||||
|             } | ||||
|         } | ||||
|         //private string _SearchText = ""; | ||||
|         //public string SearchText | ||||
|         //{ | ||||
|         //    get | ||||
|         //    { | ||||
|         //        return _SearchText; | ||||
|         //    } | ||||
|         //    set | ||||
|         //    { | ||||
|         //        SetProperty(ref _SearchText, value); | ||||
|         //        FilterItems(); | ||||
|         //    } | ||||
|         //} | ||||
| 
 | ||||
|         public void FilterItems() | ||||
|         { | ||||
|             Items.Clear(); | ||||
|             foreach (var item in AllItems) | ||||
|             { | ||||
|                 if (item.NamePHB.ToLower().Contains(SearchText.ToLower())) | ||||
|                 { | ||||
|                     Items.Add(item); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         //public void FilterItems() | ||||
|         //{ | ||||
|         //    Items.Clear(); | ||||
|         //    foreach (var item in AllItems) | ||||
|         //    { | ||||
|         //        if (item.NamePHB.ToLower().Contains(SearchText.ToLower())) | ||||
|         //        { | ||||
|         //            Items.Add(item); | ||||
|         //        } | ||||
|         //    } | ||||
|         //} | ||||
| 
 | ||||
| 
 | ||||
|     } | ||||
|  |  | |||
|  | @ -1,51 +1,118 @@ | |||
| using AideDeJeuLib; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Collections.ObjectModel; | ||||
| using Xamarin.Forms; | ||||
| 
 | ||||
| namespace AideDeJeu.ViewModels | ||||
| { | ||||
|     public class MainViewModel : BaseViewModel | ||||
| { | ||||
|     public enum ItemType | ||||
|     { | ||||
|         Spell, | ||||
|         Monster, | ||||
|     } | ||||
|         public SpellsViewModel Spells { get; private set; } | ||||
|         public MonstersViewModel Monsters { get; private set; } | ||||
| 
 | ||||
|         private ItemType _ItemsType = ItemType.Spell; | ||||
|         public ItemType ItemsType | ||||
|     public enum ItemSource | ||||
|     { | ||||
|         VF, | ||||
|         VO, | ||||
|         HD | ||||
|     } | ||||
| 
 | ||||
|     [Flags] | ||||
|     public enum ItemSourceType | ||||
|     { | ||||
|         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, | ||||
|     } | ||||
| 
 | ||||
|     public class MainViewModel : BaseViewModel | ||||
|     { | ||||
|         private ItemSourceType _ItemSourceType = ItemSourceType.SpellVF; | ||||
|         public ItemSourceType ItemSourceType | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return _ItemsType; | ||||
|                 return _ItemSourceType; | ||||
|             } | ||||
|             set | ||||
|             { | ||||
|                 CurrentViewModel.SearchText = ""; | ||||
|                 SetProperty(ref _ItemsType, value); | ||||
|                 CurrentViewModel.SearchText = ""; | ||||
|                 OnPropertyChanged(nameof(CurrentViewModel)); | ||||
|                 LoadItemsCommand.Execute(null); | ||||
|                 //CurrentViewModel.SearchText = ""; | ||||
|                 SetProperty(ref _ItemSourceType, value); | ||||
|                 //CurrentViewModel.SearchText = ""; | ||||
|                 OnPropertyChanged(nameof(Items)); | ||||
|                 //LoadItemsCommand.Execute(null); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         public ItemsViewModel CurrentViewModel | ||||
|         //private ItemSource _ItemsSource = ItemSource.VF; | ||||
|         //public ItemSource ItemsSource | ||||
|         //{ | ||||
|         //    get | ||||
|         //    { | ||||
|         //        return _ItemsSource; | ||||
|         //    } | ||||
|         //    set | ||||
|         //    { | ||||
|         //        //CurrentViewModel.SearchText = ""; | ||||
|         //        SetProperty(ref _ItemsSource, value); | ||||
|         //        //CurrentViewModel.SearchText = ""; | ||||
|         //        //OnPropertyChanged(nameof(CurrentViewModel)); | ||||
|         //        LoadItemsCommand.Execute(null); | ||||
|         //    } | ||||
|         //} | ||||
| 
 | ||||
|         public Dictionary<ItemSourceType, Lazy<ItemsViewModel>> AllItemsViewModel = new Dictionary<ItemSourceType, Lazy<ItemsViewModel>>() | ||||
|         { | ||||
|             get | ||||
|             { ItemSourceType.SpellVF, new Lazy<ItemsViewModel>(() => new SpellsViewModel()) }, | ||||
|         }; | ||||
| 
 | ||||
|         public ItemsViewModel GetItemsViewModel(ItemSourceType itemSourceType) | ||||
|         { | ||||
|                 if (ItemsType == ItemType.Spell) | ||||
|             return AllItemsViewModel[itemSourceType].Value; | ||||
|         } | ||||
| 
 | ||||
|         public Dictionary<ItemSourceType, Lazy<FilterViewModel>> AllFiltersViewModel = new Dictionary<ItemSourceType, Lazy<FilterViewModel>>() | ||||
|         { | ||||
|                     return Spells; | ||||
|                 } | ||||
|                 if (ItemsType == ItemType.Monster) | ||||
|             { ItemSourceType.SpellVF, new Lazy<FilterViewModel>(() => new VFSpellFilterViewModel()) }, | ||||
|         }; | ||||
| 
 | ||||
|         public FilterViewModel GetFilterViewModel(ItemSourceType itemSourceType) | ||||
|         { | ||||
|                     return Monsters; | ||||
|                 } | ||||
|                 return null; | ||||
|             } | ||||
|             return AllFiltersViewModel[itemSourceType].Value; | ||||
|         } | ||||
| 
 | ||||
|         //public ItemsViewModel SpellsVF | ||||
|         //{ | ||||
|         //    get | ||||
|         //    { | ||||
|         //        return AllItemsViewModel[ItemSourceType.SpellVF].Value; | ||||
|         //    } | ||||
|         //} | ||||
|         //public ItemsViewModel CurrentViewModel | ||||
|         //{ | ||||
|         //    get | ||||
|         //    { | ||||
|         //        if (ItemsType == ItemType.Spell) | ||||
|         //        { | ||||
|         //            return Spells; | ||||
|         //        } | ||||
|         //        if (ItemsType == ItemType.Monster) | ||||
|         //        { | ||||
|         //            return Monsters; | ||||
|         //        } | ||||
|         //        return null; | ||||
|         //    } | ||||
|         //} | ||||
|         public ObservableCollection<Item> Items { get; private set; } = new ObservableCollection<Item>(); | ||||
| 
 | ||||
|         private Item _SelectedItem; | ||||
|  | @ -58,9 +125,12 @@ namespace AideDeJeu.ViewModels | |||
|             set | ||||
|             { | ||||
|                 SetProperty(ref _SelectedItem, value); | ||||
|                 if (_SelectedItem != null) | ||||
|                 { | ||||
|                     GotoItemCommand.Execute(_SelectedItem); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         public Command LoadItemsCommand { get; private set; } | ||||
|         public Command<Item> GotoItemCommand { get; private set; } | ||||
|  | @ -70,16 +140,17 @@ namespace AideDeJeu.ViewModels | |||
|         public Command AboutCommand { get; private set; } | ||||
|         public Command<string> SearchCommand { get; private set; } | ||||
| 
 | ||||
|         public MainViewModel(INavigator navigator) | ||||
|         public Navigator Navigator { get; set; } | ||||
|         public MainViewModel() | ||||
|         { | ||||
|             Spells = new SpellsViewModel(navigator, Items); | ||||
|             Monsters = new MonstersViewModel(navigator, Items); | ||||
|             LoadItemsCommand = new Command(async () => await CurrentViewModel.ExecuteLoadItemsCommandAsync()); | ||||
|             GotoItemCommand = new Command<Item>(async (item) => await CurrentViewModel.ExecuteGotoItemCommandAsync(item)); | ||||
|             SwitchToSpells = new Command(() => ItemsType = ItemType.Spell); | ||||
|             SwitchToMonsters = new Command(() => ItemsType = ItemType.Monster); | ||||
|             AboutCommand = new Command(async() => await navigator.GotoAboutPageAsync()); | ||||
|             SearchCommand = new Command<string>((text) => CurrentViewModel.SearchText = text); | ||||
|             //Spells = new SpellsViewModel(navigator, Items); | ||||
|             //Monsters = new MonstersViewModel(navigator, Items); | ||||
|             LoadItemsCommand = new Command(async () => GetItemsViewModel(ItemSourceType).ExecuteLoadItemsCommand(GetFilterViewModel(ItemSourceType))); | ||||
|             GotoItemCommand = new Command<Item>(async (item) => await GetItemsViewModel(ItemSourceType).ExecuteGotoItemCommandAsync(item)); | ||||
|             SwitchToSpells = new Command(() => ItemSourceType = (ItemSourceType & ~ ItemSourceType.Monster) | ItemSourceType.Spell); | ||||
|             SwitchToMonsters = new Command(() => ItemSourceType = (ItemSourceType & ~ItemSourceType.Spell) | ItemSourceType.Monster); | ||||
|             //AboutCommand = new Command(async() => await navigator.GotoAboutPageAsync()); | ||||
|             //SearchCommand = new Command<string>((text) => GetItemsViewModel(ItemSourceType).SearchText = text); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | @ -224,14 +224,6 @@ namespace AideDeJeu.ViewModels | |||
|         } | ||||
| 
 | ||||
| 
 | ||||
|         public MonstersViewModel(INavigator navigator, ObservableCollection<Item> items) | ||||
|             : base(navigator, items) | ||||
|         { | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|         private IEnumerable<Monster> _AllMonsters = null; | ||||
|         private IEnumerable<Monster> AllMonsters | ||||
|  | @ -267,7 +259,7 @@ namespace AideDeJeu.ViewModels | |||
|         } | ||||
| 
 | ||||
| 
 | ||||
|         public override async Task ExecuteLoadItemsCommandAsync() | ||||
|         public override void ExecuteLoadItemsCommand(FilterViewModel filterViewModel) | ||||
|         { | ||||
|             if (IsBusy) | ||||
|                 return; | ||||
|  | @ -289,7 +281,7 @@ namespace AideDeJeu.ViewModels | |||
|                 { | ||||
|                     AllItems.Add(item); | ||||
|                 } | ||||
|                 FilterItems(); | ||||
|                 //FilterItems(); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|  |  | |||
|  | @ -14,171 +14,6 @@ namespace AideDeJeu.ViewModels | |||
| { | ||||
|     public class SpellsViewModel : ItemsViewModel | ||||
|     { | ||||
|         public List<KeyValuePair<string, string>> Classes { get; set; } = new List<KeyValuePair<string, string>>() | ||||
|         { | ||||
|             new KeyValuePair<string, string>("", "Toutes" ), | ||||
|             new KeyValuePair<string, string>("Barde", "Barde" ), | ||||
|             new KeyValuePair<string, string>("Clerc", "Clerc" ), | ||||
|             new KeyValuePair<string, string>("Druide", "Druide" ), | ||||
|             new KeyValuePair<string, string>("Ensorceleur", "Ensorceleur" ), | ||||
|             new KeyValuePair<string, string>("Magicien", "Magicien" ), | ||||
|             new KeyValuePair<string, string>("Paladin", "Paladin" ), | ||||
|             new KeyValuePair<string, string>("Rôdeur", "Rôdeur" ), | ||||
|             new KeyValuePair<string, string>("Sorcier", "Sorcier" ), | ||||
|         }; | ||||
| 
 | ||||
|         public List<KeyValuePair<string, string>> Niveaux { get; set; } = new List<KeyValuePair<string, string>>() | ||||
|         { | ||||
|             new KeyValuePair<string, string>("0", "Sorts mineurs"), | ||||
|             new KeyValuePair<string, string>("1", "Niveau 1"), | ||||
|             new KeyValuePair<string, string>("2", "Niveau 2"), | ||||
|             new KeyValuePair<string, string>("3", "Niveau 3"), | ||||
|             new KeyValuePair<string, string>("4", "Niveau 4"), | ||||
|             new KeyValuePair<string, string>("5", "Niveau 5"), | ||||
|             new KeyValuePair<string, string>("6", "Niveau 6"), | ||||
|             new KeyValuePair<string, string>("7", "Niveau 7"), | ||||
|             new KeyValuePair<string, string>("8", "Niveau 8"), | ||||
|             new KeyValuePair<string, 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>("évocation", "Évocation"), | ||||
|             new KeyValuePair<string, string>("illusion", "Illusion"), | ||||
|             new KeyValuePair<string, string>("invocation", "Invocation"), | ||||
|             new KeyValuePair<string, string>("cromancie", "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>("(rituel)", "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>("Player's Handbook", "PHB"), | ||||
|             new KeyValuePair<string, string>("sup", "SCAG, XGtE"), | ||||
|         }; | ||||
| 
 | ||||
|         private int _Classe = 0; | ||||
|         public int Classe | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return _Classe; | ||||
|             } | ||||
|             set | ||||
|             { | ||||
|                 if (_Classe != value) | ||||
|                 { | ||||
|                     SetProperty(ref _Classe, value); | ||||
|                     LoadItemsCommand.Execute(null); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         private int _NiveauMin = 0; | ||||
|         public int NiveauMin | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return _NiveauMin; | ||||
|             } | ||||
|             set | ||||
|             { | ||||
|                 if (_NiveauMin != value) | ||||
|                 { | ||||
|                     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 | ||||
|             { | ||||
|                 if (_NiveauMax != value) | ||||
|                 { | ||||
|                     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 | ||||
|             { | ||||
|                 if (_Ecole != value) | ||||
|                 { | ||||
|                     SetProperty(ref _Ecole, value); | ||||
|                     LoadItemsCommand.Execute(null); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         private int _Rituel = 0; | ||||
|         public int Rituel | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return _Rituel; | ||||
|             } | ||||
|             set | ||||
|             { | ||||
|                 if (_Rituel != value) | ||||
|                 { | ||||
|                     SetProperty(ref _Rituel, value); | ||||
|                     LoadItemsCommand.Execute(null); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         private int _Source = 1; | ||||
|         public int Source | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return _Source; | ||||
|             } | ||||
|             set | ||||
|             { | ||||
|                 if (_Source != value) | ||||
|                 { | ||||
|                     SetProperty(ref _Source, value); | ||||
|                     LoadItemsCommand.Execute(null); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|         public SpellsViewModel(INavigator navigator, ObservableCollection<Item> items) | ||||
|             : base(navigator, items) | ||||
|         { | ||||
|         } | ||||
| 
 | ||||
|         private IEnumerable<Spell> _AllSpells = null; | ||||
|         private IEnumerable<Spell> AllSpells | ||||
|         { | ||||
|  | @ -186,15 +21,16 @@ namespace AideDeJeu.ViewModels | |||
|             { | ||||
|                 if(_AllSpells == null) | ||||
|                 { | ||||
|                     var serializer = new DataContractJsonSerializer(typeof(IEnumerable<Spell>)); | ||||
|                     var assembly = typeof(AboutViewModel).GetTypeInfo().Assembly; | ||||
|                     //var names = assembly.GetManifestResourceNames(); | ||||
|                     //using (var stream = assembly.GetManifestResourceStream("AideDeJeu.Data.spells_hd.json")) | ||||
|                     using (var stream = assembly.GetManifestResourceStream("AideDeJeu.Data.spells_vf.json")) | ||||
|                     //using (var stream = assembly.GetManifestResourceStream("AideDeJeu.Data.spells_vo.json")) | ||||
|                     { | ||||
|                         _AllSpells = serializer.ReadObject(stream) as IEnumerable<Spell>; | ||||
|                     } | ||||
|                     _AllSpells = Tools.Helpers.GetResourceObject<IEnumerable<Spell>>("AideDeJeu.Data.spells_vf.json"); | ||||
|                     //var serializer = new DataContractJsonSerializer(typeof(IEnumerable<Spell>)); | ||||
|                     //var assembly = typeof(AboutViewModel).GetTypeInfo().Assembly; | ||||
|                     ////var names = assembly.GetManifestResourceNames(); | ||||
|                     ////using (var stream = assembly.GetManifestResourceStream("AideDeJeu.Data.spells_hd.json")) | ||||
|                     //using (var stream = assembly.GetManifestResourceStream("AideDeJeu.Data.spells_vf.json")) | ||||
|                     ////using (var stream = assembly.GetManifestResourceStream("AideDeJeu.Data.spells_vo.json")) | ||||
|                     //{ | ||||
|                     //    _AllSpells = serializer.ReadObject(stream) as IEnumerable<Spell>; | ||||
|                     //} | ||||
|                 } | ||||
|                 return _AllSpells; | ||||
|             } | ||||
|  | @ -216,7 +52,7 @@ namespace AideDeJeu.ViewModels | |||
|         } | ||||
| 
 | ||||
| 
 | ||||
|         public override async Task ExecuteLoadItemsCommandAsync() | ||||
|         public override void ExecuteLoadItemsCommand(FilterViewModel filterViewModel) | ||||
|         { | ||||
|             if (IsBusy) | ||||
|                 return; | ||||
|  | @ -225,35 +61,15 @@ namespace AideDeJeu.ViewModels | |||
| 
 | ||||
|             try | ||||
|             { | ||||
|                 AllItems.Clear(); | ||||
|                 Main.Items.Clear(); | ||||
|                 IEnumerable<Spell> items = null; | ||||
|                 //using (var spellsScrappers = new SpellsScrappers()) | ||||
|                 //{ | ||||
|                 //    items = await spellsScrappers.GetSpells(classe: Classes[Classe].Key, niveauMin: Niveaux[NiveauMin].Key, niveauMax: Niveaux[NiveauMax].Key, ecole: Ecoles[Ecole].Key, rituel: Rituels[Rituel].Key, source: Sources[Source].Key); | ||||
|                 //} | ||||
| 
 | ||||
|                 //ItemDatabaseHelper helper = new ItemDatabaseHelper(); | ||||
|                 //items = await helper.GetSpellsAsync(classe: Classes[Classe].Key, niveauMin: Niveaux[NiveauMin].Key, niveauMax: Niveaux[NiveauMax].Key, ecole: Ecoles[Ecole].Key, rituel: Rituels[Rituel].Key, source: Sources[Source].Key); | ||||
|                 items = GetSpells(classe: Classes[Classe].Key, niveauMin: Niveaux[NiveauMin].Key, niveauMax: Niveaux[NiveauMax].Key, ecole: Ecoles[Ecole].Key, rituel: Rituels[Rituel].Key, source: Sources[Source].Key); | ||||
|                 //items = Spells; | ||||
| 
 | ||||
|                 //try | ||||
|                 //{ | ||||
|                 //ItemDatabaseHelper<ItemDatabaseContext> helper = new ItemDatabaseHelper<ItemDatabaseContext>(); | ||||
|                 //await helper.AddOrUpdateSpellsAsync(items); | ||||
|                 //var items2 = await helper.GetSpellsAsync(); | ||||
|                 //} | ||||
|                 //catch(Exception ex) | ||||
|                 //{ | ||||
|                 //    Debug.WriteLine(ex); | ||||
|                 //} | ||||
|                 //var aitems = items.ToArray(); | ||||
|                 //Array.Sort(aitems, new ItemComparer()); | ||||
|                 SpellFilterViewModel filters = filterViewModel as SpellFilterViewModel; | ||||
|                 items = GetSpells(classe: filters.Classes[filters.Classe].Key, niveauMin: filters.Niveaux[filters.NiveauMin].Key, niveauMax: filters.Niveaux[filters.NiveauMax].Key, ecole: filters.Ecoles[filters.Ecole].Key, rituel: filters.Rituels[filters.Rituel].Key, source: filters.Sources[filters.Source].Key); | ||||
|                 foreach (var item in items) | ||||
|                 { | ||||
|                     AllItems.Add(item); | ||||
|                     Main.Items.Add(item); | ||||
|                 } | ||||
|                 FilterItems(); | ||||
|                 //FilterItems(); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|  | @ -267,7 +83,7 @@ namespace AideDeJeu.ViewModels | |||
| 
 | ||||
|         public override async Task ExecuteGotoItemCommandAsync(Item item) | ||||
|         { | ||||
|             await Navigator.GotoSpellDetailPageAsync(item as Spell); | ||||
|             await Main.Navigator.GotoSpellDetailPageAsync(item as Spell); | ||||
|         } | ||||
| 
 | ||||
|     } | ||||
|  |  | |||
|  | @ -37,9 +37,6 @@ | |||
|                 <ScrollView Orientation="Vertical"> | ||||
|                     <StackLayout Orientation="Vertical" Padding="15"> | ||||
| 
 | ||||
|                         <!--<Label Text="Catégorie" Style="{StaticResource Key=subsubsection}" /> | ||||
|                         <Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Categories, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.Category}" />--> | ||||
| 
 | ||||
|                         <Label Text="Type" Style="{StaticResource Key=subsubsection}" /> | ||||
|                         <Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Types, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.Type}" /> | ||||
| 
 | ||||
|  | @ -58,9 +55,6 @@ | |||
|                         <Label Text="Taille" Style="{StaticResource Key=subsubsection}" /> | ||||
|                         <Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Sizes, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.Size}" /> | ||||
| 
 | ||||
|                         <!--<Label Text="Légendaire" Style="{StaticResource Key=subsubsection}" /> | ||||
|                         <Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Legendaries, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.Legendary}" />--> | ||||
| 
 | ||||
|                         <Label Text="Source" Style="{StaticResource Key=subsubsection}" /> | ||||
|                         <Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Sources, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.Source}" IsEnabled="False"/> | ||||
|                     </StackLayout> | ||||
|  | @ -74,6 +68,10 @@ | |||
|                 x:Key="ItemsTypeTemplateConverter"  | ||||
|                 SpellsTemplate="{StaticResource SpellsMasterDataTemplate}"  | ||||
|                 MonstersTemplate="{StaticResource MonstersMasterDataTemplate}" /> | ||||
|             <tools:ItemSourceTypeToItemsConverter  | ||||
|                 x:Key="ItemSourceTypeToItemsConverter" /> | ||||
|             <tools:ItemSourceTypeToFilterConverter  | ||||
|                 x:Key="ItemSourceTypeToFilterConverter" /> | ||||
|         </ResourceDictionary> | ||||
|     </MasterDetailPage.Resources> | ||||
|     <MasterDetailPage.Master> | ||||
|  | @ -96,8 +94,9 @@ | |||
|                                 <tools:TextChangedBehavior /> | ||||
|                             </SearchBar.Behaviors> | ||||
|                         </SearchBar> | ||||
| 
 | ||||
|                         <ListView x:Name="ItemsListView"  | ||||
|                         <!--, Converter={StaticResource ItemSourceTypeToItemsConverter}, ConverterParameter={Binding ItemSourceType, Converter={StaticResource ItemSourceTypeToFilterConverter}}}"--> | ||||
|                         <ListView  | ||||
|                             x:Name="ItemsListView"  | ||||
|                             ItemsSource="{Binding Items}"  | ||||
|                             VerticalOptions="FillAndExpand" | ||||
|                             HasUnevenRows="true" | ||||
|  | @ -105,14 +104,13 @@ | |||
|                             CachingStrategy="RecycleElement" | ||||
|                             SelectedItem="{Binding SelectedItem}" | ||||
|                             ItemTapped="ItemsListView_ItemTapped"> | ||||
|                             <!--RefreshCommand="{Binding LoadItemsCommand}" | ||||
|                     IsPullToRefreshEnabled="true"--> | ||||
| 
 | ||||
|                             <ListView.ItemTemplate> | ||||
|                                 <DataTemplate> | ||||
|                                     <ViewCell> | ||||
|                                         <StackLayout Padding="10"> | ||||
|                                             <Label Text="{Binding NamePHB}"  | ||||
|                                             <Label  | ||||
|                                                 Text="{Binding NamePHB}"  | ||||
|                                                 LineBreakMode="NoWrap"  | ||||
|                                                 Style="{DynamicResource subsubsection}"  | ||||
|                                                 FontSize="16" /> | ||||
|  |  | |||
|  | @ -11,22 +11,32 @@ namespace AideDeJeu.Views | |||
|     [XamlCompilation(XamlCompilationOptions.Compile)] | ||||
| 	public partial class MainPage : MasterDetailPage | ||||
|     { | ||||
|         MainViewModel viewModel; | ||||
|         INavigator Navigator; | ||||
|         MainViewModel Main | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return DependencyService.Get<MainViewModel>(); | ||||
|             } | ||||
|         } | ||||
|         //INavig//ator Navigator; | ||||
| 
 | ||||
|         public MainPage () | ||||
| 		{ | ||||
| 			InitializeComponent (); | ||||
|             Navigator = new Navigator((Detail as NavigationPage).Navigation); | ||||
|             BindingContext = viewModel = new MainViewModel(Navigator); | ||||
| 
 | ||||
|             //DependencyService.Register<INavigator>(new Navigator((Detail as NavigationPage).Navigation)); | ||||
|              | ||||
|             //Navigator = new Navigator((Detail as NavigationPage).Navigation); | ||||
|             //BindingContext = viewModel = new MainViewModel(Navigator); | ||||
|             BindingContext = Main; | ||||
|         } | ||||
| 
 | ||||
|         protected override void OnAppearing() | ||||
|         { | ||||
|             base.OnAppearing(); | ||||
| 
 | ||||
|             if (viewModel.Items.Count == 0) | ||||
|                 viewModel.LoadItemsCommand.Execute(null); | ||||
|             if (Main.Items.Count == 0) | ||||
|                 Main.LoadItemsCommand.Execute(null); | ||||
|         } | ||||
| 
 | ||||
|         private void ItemsListView_ItemTapped(object sender, ItemTappedEventArgs e) | ||||
|  |  | |||
|  | @ -16,4 +16,8 @@ | |||
|     <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.3" /> | ||||
|   </ItemGroup> | ||||
| 
 | ||||
|   <ItemGroup> | ||||
|     <ProjectReference Include="..\AideDeJeu\AideDeJeu.csproj" /> | ||||
|   </ItemGroup> | ||||
| 
 | ||||
| </Project> | ||||
|  |  | |||
|  | @ -1,6 +1,4 @@ | |||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Collections.Generic; | ||||
| using System.Threading.Tasks; | ||||
| using AideDeJeuLib.Cards; | ||||
| using AideDeJeuLib.Spells; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yan Maniez
						Yan Maniez