mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-29 22:45:44 +00:00
Factorisation, converters, etc...
This commit is contained in:
parent
59e142e79f
commit
810de23885
4 changed files with 25 additions and 5 deletions
|
|
@ -37,11 +37,14 @@ namespace AideDeJeu.Tools
|
|||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var node = value as HtmlNode;
|
||||
if (node != null)
|
||||
var str = value as string;
|
||||
if (str != null)
|
||||
{
|
||||
var doc = new HtmlDocument();
|
||||
doc.LoadHtml(str);
|
||||
|
||||
var fs = new FormattedString();
|
||||
FormatedTextHelpers.HtmlNodeToFormatedString(node, fs);
|
||||
FormatedTextHelpers.HtmlNodeToFormatedString(doc.DocumentNode, fs);
|
||||
return fs;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace AideDeJeu.ViewModels
|
|||
var fs = new FormattedString();
|
||||
if (Item?.DescriptionDiv != null)
|
||||
{
|
||||
FormatedTextHelpers.HtmlNodeToFormatedString(Item?.DescriptionDiv, fs, FontAttributes.None);
|
||||
FormatedTextHelpers.HtmlNodeToFormatedString(global::AideDeJeuLib.Item.StringToNode(Item?.DescriptionHtml), fs, FontAttributes.None);
|
||||
}
|
||||
return fs;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:tools="clr-namespace:AideDeJeu.Tools"
|
||||
x:Class="AideDeJeu.Views.SpellDetailPage"
|
||||
Title="{Binding Title}">
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<tools:NullToFalseConverter x:Key="NullToFalseConverter" />
|
||||
<tools:HtmlNodeToFormattedStringConverter x:Key="HtmlNodeToFormattedStringConverter" />
|
||||
<tools:HtmlNodesToFormattedStringConverter x:Key="HtmlNodesToFormattedStringConverter" />
|
||||
</ResourceDictionary>
|
||||
</ContentPage.Resources>
|
||||
<ScrollView>
|
||||
<StackLayout Orientation="Vertical" Padding="15">
|
||||
<Label Text="{Binding Item.NamePHB}" Style="{StaticResource Key=subsection}" />
|
||||
|
|
@ -55,7 +63,8 @@
|
|||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>-->
|
||||
<Label FormattedText="{Binding Description}" Style="{StaticResource Key=content}" />
|
||||
<!--<Label FormattedText="{Binding Description}" Style="{StaticResource Key=content}" />-->
|
||||
<Label FormattedText="{Binding Item.DescriptionHtml, Converter={StaticResource HtmlNodeToFormattedStringConverter}}" IsVisible="{Binding Item.DescriptionHtml, Converter={StaticResource NullToFalseConverter}}" Style="{StaticResource Key=content}" />
|
||||
|
||||
<Label Text="{Binding Item.Source}" Style="{StaticResource Key=content}" />
|
||||
</StackLayout>
|
||||
|
|
|
|||
|
|
@ -24,6 +24,14 @@ namespace AideDeJeuLib
|
|||
return strings;
|
||||
}
|
||||
|
||||
public static HtmlNode StringToNode(string str)
|
||||
{
|
||||
if (str == null) return null;
|
||||
var doc = new HtmlDocument();
|
||||
doc.LoadHtml(str);
|
||||
return doc.DocumentNode;
|
||||
}
|
||||
|
||||
//public static IEnumerable<HtmlNode> StringListToNodeList(IEnumerable<string> strings)
|
||||
//{
|
||||
// if (strings == null) return null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue