mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-10-31 15:36:07 +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) | ||||
|         { | ||||
|             var nodes = value as IEnumerable<HtmlNode>; | ||||
|             if (nodes != null) | ||||
|             var strings = value as IEnumerable<string>; | ||||
|             if (strings != null) | ||||
|             { | ||||
|                 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" }); | ||||
|                 } | ||||
|                 return fs; | ||||
|  |  | |||
|  | @ -77,13 +77,13 @@ | |||
| 
 | ||||
|             <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 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 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.ItemTemplate> | ||||
|                     <DataTemplate> | ||||
|  |  | |||
|  | @ -1,4 +1,7 @@ | |||
| namespace AideDeJeuLib | ||||
| using HtmlAgilityPack; | ||||
| using System.Collections.Generic; | ||||
| 
 | ||||
| namespace AideDeJeuLib | ||||
| { | ||||
|     public class Item | ||||
|     { | ||||
|  | @ -9,5 +12,30 @@ | |||
|         public string NameVO { get; set; } | ||||
|         public string NamePHB { 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; } | ||||
|         [IgnoreDataMember] | ||||
|         public IEnumerable<HtmlNode> SpecialFeaturesNodes | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return StringListToNodeList(SpecialFeatures); | ||||
|             } | ||||
|             set | ||||
|             { | ||||
|                 SpecialFeatures = NodeListToStringList(value); | ||||
|  | @ -92,10 +64,6 @@ namespace AideDeJeuLib.Monsters | |||
|         [IgnoreDataMember] | ||||
|         public IEnumerable<HtmlNode> ActionsNodes | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return StringListToNodeList(Actions); | ||||
|             } | ||||
|             set | ||||
|             { | ||||
|                 Actions = NodeListToStringList(value); | ||||
|  | @ -106,10 +74,6 @@ namespace AideDeJeuLib.Monsters | |||
|         [IgnoreDataMember] | ||||
|         public IEnumerable<HtmlNode> LegendaryActionsNodes | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return StringListToNodeList(LegendaryActions); | ||||
|             } | ||||
|             set | ||||
|             { | ||||
|                 LegendaryActions = NodeListToStringList(value); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yan Maniez
						Yan Maniez