mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-11-04 01:00:23 +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)
 | 
					        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var node = value as HtmlNode;
 | 
					            var str = value as string;
 | 
				
			||||||
            if (node != null)
 | 
					            if (str != null)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 | 
					                var doc = new HtmlDocument();
 | 
				
			||||||
 | 
					                doc.LoadHtml(str);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                var fs = new FormattedString();
 | 
					                var fs = new FormattedString();
 | 
				
			||||||
                FormatedTextHelpers.HtmlNodeToFormatedString(node, fs);
 | 
					                FormatedTextHelpers.HtmlNodeToFormatedString(doc.DocumentNode, fs);
 | 
				
			||||||
                return fs;
 | 
					                return fs;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else
 | 
					            else
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -36,7 +36,7 @@ namespace AideDeJeu.ViewModels
 | 
				
			||||||
                var fs = new FormattedString();
 | 
					                var fs = new FormattedString();
 | 
				
			||||||
                if (Item?.DescriptionDiv != null)
 | 
					                if (Item?.DescriptionDiv != null)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    FormatedTextHelpers.HtmlNodeToFormatedString(Item?.DescriptionDiv, fs, FontAttributes.None);
 | 
					                    FormatedTextHelpers.HtmlNodeToFormatedString(global::AideDeJeuLib.Item.StringToNode(Item?.DescriptionHtml), fs, FontAttributes.None);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                return fs;
 | 
					                return fs;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,16 @@
 | 
				
			||||||
<?xml version="1.0" encoding="utf-8" ?>
 | 
					<?xml version="1.0" encoding="utf-8" ?>
 | 
				
			||||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
 | 
					<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
 | 
				
			||||||
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
 | 
					             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
 | 
				
			||||||
 | 
					             xmlns:tools="clr-namespace:AideDeJeu.Tools"
 | 
				
			||||||
             x:Class="AideDeJeu.Views.SpellDetailPage"
 | 
					             x:Class="AideDeJeu.Views.SpellDetailPage"
 | 
				
			||||||
             Title="{Binding Title}">
 | 
					             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>
 | 
					    <ScrollView>
 | 
				
			||||||
        <StackLayout Orientation="Vertical" Padding="15">
 | 
					        <StackLayout Orientation="Vertical" Padding="15">
 | 
				
			||||||
            <Label Text="{Binding Item.NamePHB}" Style="{StaticResource Key=subsection}" />
 | 
					            <Label Text="{Binding Item.NamePHB}" Style="{StaticResource Key=subsection}" />
 | 
				
			||||||
| 
						 | 
					@ -55,7 +63,8 @@
 | 
				
			||||||
                    </DataTemplate>
 | 
					                    </DataTemplate>
 | 
				
			||||||
                </ListView.ItemTemplate>
 | 
					                </ListView.ItemTemplate>
 | 
				
			||||||
            </ListView>-->
 | 
					            </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}" />
 | 
					            <Label Text="{Binding Item.Source}" Style="{StaticResource Key=content}" />
 | 
				
			||||||
        </StackLayout>
 | 
					        </StackLayout>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,6 +24,14 @@ namespace AideDeJeuLib
 | 
				
			||||||
            return strings;
 | 
					            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)
 | 
					        //public static IEnumerable<HtmlNode> StringListToNodeList(IEnumerable<string> strings)
 | 
				
			||||||
        //{
 | 
					        //{
 | 
				
			||||||
        //    if (strings == null) return null;
 | 
					        //    if (strings == null) return null;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue