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

Retour du NameLevel

This commit is contained in:
Yan Maniez 2018-09-16 23:10:24 +02:00
parent 921546d3c2
commit 9719557d2c
5 changed files with 52 additions and 18 deletions

View file

@ -13,6 +13,7 @@
</ControlTemplate>
<Color x:Key="HDRed">#9B1C47</Color>
<Color x:Key="HDBlue">#5B61FF</Color>
<Color x:Key="HDGrey">#563F5A</Color>
<Color x:Key="HDMidGrey">#6F5B73</Color>
<Color x:Key="HDLightGrey">#7C7B7B</Color>
@ -225,7 +226,7 @@
<Style TargetType="Label" x:Key="link">
<Setter Property="FontSize" Value="14" />
<Setter Property="TextColor" Value="{StaticResource HDRed}" />
<Setter Property="TextColor" Value="{StaticResource HDBlue}" />
<Setter Property="FontFamily" Value="{DynamicResource LinuxLibertine}" />
</Style>

View file

@ -72,7 +72,18 @@ namespace AideDeJeu.Tools
var level = value as int?;
if(level.HasValue)
{
return Application.Current.Resources[$"heading{level.Value+1}"];
int finallevel = level.Value;
int baselevel = 1;
if(int.TryParse(parameter as string, out baselevel))
{
finallevel += baselevel;
}
finallevel = Math.Max(1, Math.Min(6, finallevel));
var heading = $"heading{finallevel}";
if (Application.Current.Resources.ContainsKey(heading))
{
return Application.Current.Resources[heading];
}
}
return Application.Current.Resources["paragraph"];
}

View file

@ -111,35 +111,45 @@ namespace AideDeJeu.ViewModels
return currentItem;
}
public void ParseItemProperties(string source, Item item, Block block)
public bool ParseItemProperties(string source, Item item, Block block)
{
switch (block)
{
case Markdig.Extensions.Tables.Table table:
ParseItemProperties(source, item, table);
break;
return ParseItemProperties(source, item, table);
case ContainerBlock blocks:
ParseItemProperties(source, item, blocks);
break;
return ParseItemProperties(source, item, blocks);
case LeafBlock leaf:
ParseItemProperties(source, item, leaf.Inline);
break;
bool isname = ParseItemProperties(source, item, leaf.Inline);
if(isname)
{
if(leaf is HeadingBlock)
{
var headingBlock = leaf as HeadingBlock;
item.NameLevel = headingBlock.Level;
}
}
return isname;
}
return false;
}
public void ParseItemProperties(string source, Item item, ContainerBlock blocks)
public bool ParseItemProperties(string source, Item item, ContainerBlock blocks)
{
bool isname = false;
foreach (var block in blocks)
{
ParseItemProperties(source, item, block);
isname |= ParseItemProperties(source, item, block);
}
return isname;
}
public void ParseItemProperties(string source, Item item, ContainerInline inlines)
public bool ParseItemProperties(string source, Item item, ContainerInline inlines)
{
bool isname = false;
if (inlines == null)
{
return;
return isname;
}
PropertyInfo prop = null;
foreach (var inline in inlines)
@ -158,6 +168,10 @@ namespace AideDeJeu.ViewModels
else if (tag.StartsWith("<!--") && !tag.StartsWith("<!--/"))
{
var propertyName = tag.Substring(4, tag.Length - 7);
if(propertyName == "Name")
{
isname = true;
}
prop = item.GetType().GetProperty(propertyName, BindingFlags.Public | BindingFlags.Instance);
}
}
@ -169,6 +183,7 @@ namespace AideDeJeu.ViewModels
}
}
}
return isname;
}

View file

@ -7,6 +7,13 @@
x:Class="AideDeJeu.Views.FilteredItemsPage"
x:Name="This"
Title="{Binding Title}">
<MasterDetailPage.Resources>
<ResourceDictionary>
<tools:MonsterMarkdownTheme x:Key="MonsterMarkdownTheme" />
<tools:NullToFalseConverter x:Key="NullToFalseConverter" />
<tools:HeaderLevelToStyleConverter x:Key="HeaderLevelToStyleConverter" />
</ResourceDictionary>
</MasterDetailPage.Resources>
<MasterDetailPage.ToolbarItems>
<ToolbarItem Name="Filter" Text="Filtrer" Order="Primary" Icon="funnel.png" Clicked="Button_Clicked" />
<ToolbarItem Name="AddToFavorites" Text="Ajouter aux favoris" Order="Primary" Icon="round_star.png" Command="{Binding Main.Navigator.AddToFavoritesCommand}" />
@ -49,10 +56,10 @@
<ListView Grid.Column="0" Grid.Row="1" x:Name="ItemsListView" ItemsSource="{Binding Children}" VerticalOptions="FillAndExpand" HasUnevenRows="true" CachingStrategy="RecycleElement" SelectedItem="{Binding SelectedItem}" ItemTapped="ItemsListView_ItemTapped">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell AutomationProperties.IsInAccessibleTree="True" AutomationId="machin" AutomationProperties.Name="hop">
<ViewCell>
<StackLayout Padding="10" Orientation="Vertical">
<Label Text="{Binding Name}" LineBreakMode="WordWrap" Style="{DynamicResource heading3}" FontSize="16" />
<Label Text="{Binding AltNameText}" LineBreakMode="WordWrap" Style="{DynamicResource heading3}" FontSize="12" />
<Label Text="{Binding Name}" LineBreakMode="WordWrap" TextColor="{StaticResource HDBlue}" Style="{Binding NameLevel,Converter={StaticResource HeaderLevelToStyleConverter}, ConverterParameter=1}" />
<Label Text="{Binding AltNameText}" LineBreakMode="WordWrap" TextColor="{StaticResource HDLightGrey}" Style="{Binding NameLevel,Converter={StaticResource HeaderLevelToStyleConverter}, ConverterParameter=4}" />
</StackLayout>
</ViewCell>
</DataTemplate>

View file

@ -31,8 +31,8 @@
<DataTemplate>
<ViewCell>
<StackLayout Padding="10" Orientation="Vertical">
<Label Text="{Binding Name}" LineBreakMode="WordWrap" TextColor="#0366d6" Style="{Binding NameLevel,Converter={StaticResource HeaderLevelToStyleConverter}}" />
<Label Text="{Binding AltNameText}" LineBreakMode="WordWrap" Style="{DynamicResource heading3}" FontSize="12" />
<Label Text="{Binding Name}" LineBreakMode="WordWrap" TextColor="{StaticResource HDBlue}" Style="{Binding NameLevel,Converter={StaticResource HeaderLevelToStyleConverter}, ConverterParameter=1}" />
<Label Text="{Binding AltNameText}" LineBreakMode="WordWrap" TextColor="{StaticResource HDLightGrey}" Style="{Binding NameLevel,Converter={StaticResource HeaderLevelToStyleConverter}, ConverterParameter=4}" />
</StackLayout>
</ViewCell>
</DataTemplate>