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

Préparation conditions

This commit is contained in:
Yan Maniez 2018-07-02 17:48:19 +02:00
parent cac8ea4fae
commit 6906ddbd32
3 changed files with 87 additions and 14 deletions

View file

@ -88,6 +88,45 @@ namespace AideDeJeu.ViewModels
} }
} }
public class SearchFilterViewModel : FilterViewModel
{
private IEnumerable<Filter> _Filters = null;
public override IEnumerable<Filter> Filters
{
get
{
if (_Filters == null)
{
_Filters = new List<Filter>()
{
};
}
return _Filters;
}
}
public override async Task<IEnumerable<Item>> FilterItems(IEnumerable<Item> items, CancellationToken token = default)
{
return await Task.Run(() =>
{
return items.Where(item =>
{
var spell = item as Spell;
return
(
(Helpers.RemoveDiacritics(spell.Name).ToLower().Contains(Helpers.RemoveDiacritics(SearchText ?? string.Empty).ToLower())) ||
(Helpers.RemoveDiacritics(spell.NameVOText ?? string.Empty).ToLower().Contains(Helpers.RemoveDiacritics(SearchText ?? string.Empty).ToLower()))
);
}).OrderBy(spell => spell.Name)
.AsEnumerable();
}, token);
}
}
#region Spells #region Spells
public abstract class SpellFilterViewModel : FilterViewModel public abstract class SpellFilterViewModel : FilterViewModel
{ {

View file

@ -44,12 +44,38 @@ namespace AideDeJeu.ViewModels
set => SetProperty(ref _isLoading, value); set => SetProperty(ref _isLoading, value);
} }
public List<KeyValuePair<ItemSourceType, string>> ItemsSources { get; set; } = new List<KeyValuePair<ItemSourceType, string>>()
{
new KeyValuePair<ItemSourceType, string>(ItemSourceType.SpellHD, "Sorts (H&D)"),
new KeyValuePair<ItemSourceType, string>(ItemSourceType.SpellVO, "Spells (VO)"),
new KeyValuePair<ItemSourceType, string>(ItemSourceType.MonsterHD, "Créatures (H&D)"),
new KeyValuePair<ItemSourceType, string>(ItemSourceType.MonsterVO, "Monsters (VO)"),
new KeyValuePair<ItemSourceType, string>(ItemSourceType.ConditionHD, "Etats spéciaux (H&D)"),
new KeyValuePair<ItemSourceType, string>(ItemSourceType.ConditionVO, "Conditions (VO)"),
};
private int _ItemsSourcesIndex = 0;
public int ItemsSourcesIndex
{
get
{
return _ItemsSourcesIndex;
}
set
{
SetProperty(ref _ItemsSourcesIndex, value);
ItemSourceType = ItemsSources[value].Key;
}
}
public Dictionary<ItemSourceType, Lazy<ItemsViewModel>> AllItemsViewModel = new Dictionary<ItemSourceType, Lazy<ItemsViewModel>>() public Dictionary<ItemSourceType, Lazy<ItemsViewModel>> AllItemsViewModel = new Dictionary<ItemSourceType, Lazy<ItemsViewModel>>()
{ {
{ ItemSourceType.SpellVO, new Lazy<ItemsViewModel>(() => new ItemsViewModel(ItemSourceType.SpellVO)) }, { ItemSourceType.SpellVO, new Lazy<ItemsViewModel>(() => new ItemsViewModel(ItemSourceType.SpellVO)) },
{ ItemSourceType.SpellHD, new Lazy<ItemsViewModel>(() => new ItemsViewModel(ItemSourceType.SpellHD)) }, { ItemSourceType.SpellHD, new Lazy<ItemsViewModel>(() => new ItemsViewModel(ItemSourceType.SpellHD)) },
{ ItemSourceType.MonsterVO, new Lazy<ItemsViewModel>(() => new ItemsViewModel(ItemSourceType.MonsterVO)) }, { ItemSourceType.MonsterVO, new Lazy<ItemsViewModel>(() => new ItemsViewModel(ItemSourceType.MonsterVO)) },
{ ItemSourceType.MonsterHD, new Lazy<ItemsViewModel>(() => new ItemsViewModel(ItemSourceType.MonsterHD)) }, { ItemSourceType.MonsterHD, new Lazy<ItemsViewModel>(() => new ItemsViewModel(ItemSourceType.MonsterHD)) },
{ ItemSourceType.ConditionHD, new Lazy<ItemsViewModel>(() => new ItemsViewModel(ItemSourceType.ConditionHD)) },
{ ItemSourceType.ConditionVO, new Lazy<ItemsViewModel>(() => new ItemsViewModel(ItemSourceType.ConditionVO)) },
}; };
public ItemsViewModel GetItemsViewModel(ItemSourceType itemSourceType) public ItemsViewModel GetItemsViewModel(ItemSourceType itemSourceType)
@ -63,6 +89,8 @@ namespace AideDeJeu.ViewModels
{ ItemSourceType.SpellHD, new Lazy<FilterViewModel>(() => new HDSpellFilterViewModel()) }, { ItemSourceType.SpellHD, new Lazy<FilterViewModel>(() => new HDSpellFilterViewModel()) },
{ ItemSourceType.MonsterVO, new Lazy<FilterViewModel>(() => new VOMonsterFilterViewModel()) }, { ItemSourceType.MonsterVO, new Lazy<FilterViewModel>(() => new VOMonsterFilterViewModel()) },
{ ItemSourceType.MonsterHD, new Lazy<FilterViewModel>(() => new HDMonsterFilterViewModel()) }, { ItemSourceType.MonsterHD, new Lazy<FilterViewModel>(() => new HDMonsterFilterViewModel()) },
{ ItemSourceType.ConditionHD, new Lazy<FilterViewModel>(() => new SearchFilterViewModel()) },
{ ItemSourceType.ConditionVO, new Lazy<FilterViewModel>(() => new SearchFilterViewModel()) },
}; };
public FilterViewModel GetFilterViewModel(ItemSourceType itemSourceType) public FilterViewModel GetFilterViewModel(ItemSourceType itemSourceType)

View file

@ -8,20 +8,26 @@
</MasterDetailPage.Resources> </MasterDetailPage.Resources>
<MasterDetailPage.Master> <MasterDetailPage.Master>
<ContentPage Title=" "> <ContentPage Title=" ">
<ListView SelectionMode="None" ItemsSource="{Binding ItemSourceType, Converter={StaticResource ItemSourceTypeToFilterConverter}}" HasUnevenRows="True" RowHeight="-1" SeparatorVisibility="None" IsPullToRefreshEnabled="False"> <StackLayout Orientation="Vertical">
<ListView.ItemTemplate> <StackLayout Margin="10,5,10,0" Padding="0" Spacing="0">
<DataTemplate> <Label Text="Listes" Style="{StaticResource Key=subsubsection}" />
<ViewCell> <Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding ItemsSources, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding ItemsSourcesIndex}" />
<ViewCell.View> </StackLayout>
<StackLayout Margin="10,5,10,0" Padding="0" Spacing="0"> <ListView SelectionMode="None" ItemsSource="{Binding ItemSourceType, Converter={StaticResource ItemSourceTypeToFilterConverter}}" HasUnevenRows="True" RowHeight="-1" SeparatorVisibility="None" IsPullToRefreshEnabled="False" HorizontalOptions="FillAndExpand" >
<Label BindingContext="{Binding}" Text="{Binding Name}" Style="{StaticResource Key=subsubsection}" /> <ListView.ItemTemplate>
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding KeyValues, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Index}" /> <DataTemplate>
</StackLayout> <ViewCell>
</ViewCell.View> <ViewCell.View>
</ViewCell> <StackLayout Margin="10,5,10,0" Padding="0" Spacing="0">
</DataTemplate> <Label BindingContext="{Binding}" Text="{Binding Name}" Style="{StaticResource Key=subsubsection}" />
</ListView.ItemTemplate> <Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding KeyValues, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Index}" />
</ListView> </StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage> </ContentPage>
</MasterDetailPage.Master> </MasterDetailPage.Master>
<MasterDetailPage.Detail> <MasterDetailPage.Detail>