mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-30 15:06:06 +00:00
Simplifications
This commit is contained in:
parent
fd82b9fa51
commit
59e142e79f
4 changed files with 39 additions and 44 deletions
|
|
@ -60,13 +60,16 @@ namespace AideDeJeu.Tools
|
||||||
{
|
{
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
var nodes = value as IEnumerable<HtmlNode>;
|
var strings = value as IEnumerable<string>;
|
||||||
if (nodes != null)
|
if (strings != null)
|
||||||
{
|
{
|
||||||
var fs = new FormattedString();
|
var fs = new FormattedString();
|
||||||
foreach (var node in nodes)
|
foreach (var str in strings)
|
||||||
{
|
{
|
||||||
FormatedTextHelpers.HtmlNodeToFormatedString(node, fs);
|
var doc = new HtmlDocument();
|
||||||
|
doc.LoadHtml(str);
|
||||||
|
|
||||||
|
FormatedTextHelpers.HtmlNodeToFormatedString(doc.DocumentNode, fs);
|
||||||
fs.Spans.Add(new Span() { Text = "\r\n" });
|
fs.Spans.Add(new Span() { Text = "\r\n" });
|
||||||
}
|
}
|
||||||
return fs;
|
return fs;
|
||||||
|
|
|
||||||
|
|
@ -77,13 +77,13 @@
|
||||||
|
|
||||||
<skia:SKCanvasView PaintSurface="PaintRedBar" HorizontalOptions="FillAndExpand" HeightRequest="8"/>
|
<skia:SKCanvasView PaintSurface="PaintRedBar" HorizontalOptions="FillAndExpand" HeightRequest="8"/>
|
||||||
|
|
||||||
<Label FormattedText="{Binding Item.SpecialFeaturesNodes, Converter={StaticResource HtmlNodesToFormattedStringConverter}}" IsVisible="{Binding Item.SpecialFeatures, Converter={StaticResource NullToFalseConverter}}" />
|
<Label FormattedText="{Binding Item.SpecialFeatures, Converter={StaticResource HtmlNodesToFormattedStringConverter}}" IsVisible="{Binding Item.SpecialFeatures, Converter={StaticResource NullToFalseConverter}}" />
|
||||||
|
|
||||||
<Label Text="Actions" Style="{StaticResource Key=subsubsection}" IsVisible="{Binding Item.Actions, Converter={StaticResource NullToFalseConverter}}" />
|
<Label Text="Actions" Style="{StaticResource Key=subsubsection}" IsVisible="{Binding Item.Actions, Converter={StaticResource NullToFalseConverter}}" />
|
||||||
<Label FormattedText="{Binding Item.ActionsNodes, Converter={StaticResource HtmlNodesToFormattedStringConverter}}" IsVisible="{Binding Item.Actions, Converter={StaticResource NullToFalseConverter}}" />
|
<Label FormattedText="{Binding Item.Actions, Converter={StaticResource HtmlNodesToFormattedStringConverter}}" IsVisible="{Binding Item.Actions, Converter={StaticResource NullToFalseConverter}}" />
|
||||||
|
|
||||||
<Label Text="Actions légendaires" Style="{StaticResource Key=subsubsection}" IsVisible="{Binding Item.LegendaryActions, Converter={StaticResource NullToFalseConverter}}" />
|
<Label Text="Actions légendaires" Style="{StaticResource Key=subsubsection}" IsVisible="{Binding Item.LegendaryActions, Converter={StaticResource NullToFalseConverter}}" />
|
||||||
<Label FormattedText="{Binding Item.LegendaryActionsNodes, Converter={StaticResource HtmlNodesToFormattedStringConverter}}" IsVisible="{Binding Item.LegendaryActions, Converter={StaticResource NullToFalseConverter}}" />
|
<Label FormattedText="{Binding Item.LegendaryActions, Converter={StaticResource HtmlNodesToFormattedStringConverter}}" IsVisible="{Binding Item.LegendaryActions, Converter={StaticResource NullToFalseConverter}}" />
|
||||||
<!--<ListView ItemsSource="{Binding Item.SpecialFeaturesNodes}">
|
<!--<ListView ItemsSource="{Binding Item.SpecialFeaturesNodes}">
|
||||||
<ListView.ItemTemplate>
|
<ListView.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
namespace AideDeJeuLib
|
using HtmlAgilityPack;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace AideDeJeuLib
|
||||||
{
|
{
|
||||||
public class Item
|
public class Item
|
||||||
{
|
{
|
||||||
|
|
@ -9,5 +12,30 @@
|
||||||
public string NameVO { get; set; }
|
public string NameVO { get; set; }
|
||||||
public string NamePHB { get; set; }
|
public string NamePHB { get; set; }
|
||||||
public string Html { get; set; }
|
public string Html { get; set; }
|
||||||
|
|
||||||
|
public static IEnumerable<string> NodeListToStringList(IEnumerable<HtmlNode> nodes)
|
||||||
|
{
|
||||||
|
if (nodes == null) return null;
|
||||||
|
var strings = new List<string>();
|
||||||
|
foreach (var node in nodes)
|
||||||
|
{
|
||||||
|
strings.Add(node.OuterHtml);
|
||||||
|
}
|
||||||
|
return strings;
|
||||||
|
}
|
||||||
|
|
||||||
|
//public static IEnumerable<HtmlNode> StringListToNodeList(IEnumerable<string> strings)
|
||||||
|
//{
|
||||||
|
// if (strings == null) return null;
|
||||||
|
// var nodes = new List<HtmlNode>();
|
||||||
|
// foreach (var str in strings)
|
||||||
|
// {
|
||||||
|
// var doc = new HtmlDocument();
|
||||||
|
// doc.LoadHtml(str);
|
||||||
|
// nodes.Add(doc.DocumentNode);
|
||||||
|
// }
|
||||||
|
// return nodes;
|
||||||
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,38 +50,10 @@ namespace AideDeJeuLib.Monsters
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<string> NodeListToStringList(IEnumerable<HtmlNode> nodes)
|
|
||||||
{
|
|
||||||
if (nodes == null) return null;
|
|
||||||
var strings = new List<string>();
|
|
||||||
foreach (var node in nodes)
|
|
||||||
{
|
|
||||||
strings.Add(node.OuterHtml);
|
|
||||||
}
|
|
||||||
return strings;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IEnumerable<HtmlNode> StringListToNodeList(IEnumerable<string> strings)
|
|
||||||
{
|
|
||||||
if (strings == null) return null;
|
|
||||||
var nodes = new List<HtmlNode>();
|
|
||||||
foreach (var str in strings)
|
|
||||||
{
|
|
||||||
var doc = new HtmlDocument();
|
|
||||||
doc.LoadHtml(str);
|
|
||||||
nodes.Add(doc.DocumentNode);
|
|
||||||
}
|
|
||||||
return nodes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<string> SpecialFeatures { get; set; }
|
public IEnumerable<string> SpecialFeatures { get; set; }
|
||||||
[IgnoreDataMember]
|
[IgnoreDataMember]
|
||||||
public IEnumerable<HtmlNode> SpecialFeaturesNodes
|
public IEnumerable<HtmlNode> SpecialFeaturesNodes
|
||||||
{
|
{
|
||||||
get
|
|
||||||
{
|
|
||||||
return StringListToNodeList(SpecialFeatures);
|
|
||||||
}
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
SpecialFeatures = NodeListToStringList(value);
|
SpecialFeatures = NodeListToStringList(value);
|
||||||
|
|
@ -92,10 +64,6 @@ namespace AideDeJeuLib.Monsters
|
||||||
[IgnoreDataMember]
|
[IgnoreDataMember]
|
||||||
public IEnumerable<HtmlNode> ActionsNodes
|
public IEnumerable<HtmlNode> ActionsNodes
|
||||||
{
|
{
|
||||||
get
|
|
||||||
{
|
|
||||||
return StringListToNodeList(Actions);
|
|
||||||
}
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
Actions = NodeListToStringList(value);
|
Actions = NodeListToStringList(value);
|
||||||
|
|
@ -106,10 +74,6 @@ namespace AideDeJeuLib.Monsters
|
||||||
[IgnoreDataMember]
|
[IgnoreDataMember]
|
||||||
public IEnumerable<HtmlNode> LegendaryActionsNodes
|
public IEnumerable<HtmlNode> LegendaryActionsNodes
|
||||||
{
|
{
|
||||||
get
|
|
||||||
{
|
|
||||||
return StringListToNodeList(LegendaryActions);
|
|
||||||
}
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
LegendaryActions = NodeListToStringList(value);
|
LegendaryActions = NodeListToStringList(value);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue