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

Nettoyage

This commit is contained in:
Yan Maniez 2018-06-30 23:51:42 +02:00
parent ef20e795c5
commit 4649c8f7b7
4 changed files with 7 additions and 75 deletions

View file

@ -34,33 +34,7 @@ namespace AideDeJeu.Tools
}
}
public class HtmlNodeToFormattedStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var str = value as string;
if (str != null)
{
var doc = new XmlDocument();
doc.LoadXml("<div>" + str + "</div>");
var fs = new FormattedString();
FormatedTextHelpers.HtmlNodeToFormatedString(doc.DocumentElement, fs);
return fs;
}
else
{
return null;
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
public class HtmlNodesToFormattedStringConverter : IValueConverter
public class StringListToStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
@ -73,20 +47,6 @@ namespace AideDeJeu.Tools
cstring += str + "\n\n";
}
return cstring;
// var fs = new FormattedString();
// foreach (var str in strings)
// {
// var doc = new XmlDocument();
// doc.LoadXml("<div>" + str + "</div>");
// FormatedTextHelpers.HtmlNodeToFormatedString(doc.DocumentElement, fs);
// fs.Spans.Add(new Span() { Text = "\n" });
// }
// return fs;
//}
//else
//{
// return null;
}
return null;
}
@ -100,20 +60,14 @@ namespace AideDeJeu.Tools
public class ItemSourceTypeConverter<T> : IValueConverter
{
//public T SpellVF { get; set; }
public T SpellVO { get; set; }
public T SpellHD { get; set; }
//public T MonsterVF { get; set; }
public T MonsterVO { get; set; }
public T MonsterHD { get; set; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var itemType = value as ItemSourceType?;
//if (itemType == ItemSourceType.SpellVF)
//{
// return SpellVF;
//}
if (itemType == ItemSourceType.SpellVO)
{
return SpellVO;
@ -122,10 +76,6 @@ namespace AideDeJeu.Tools
{
return SpellHD;
}
//if (itemType == ItemSourceType.MonsterVF)
//{
// return MonsterVF;
//}
if (itemType == ItemSourceType.MonsterVO)
{
return MonsterVO;
@ -145,21 +95,6 @@ namespace AideDeJeu.Tools
public class ItemSourceTypeToStringConverter : ItemSourceTypeConverter<string> { }
public class ItemSourceTypeToItemsConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var vm = DependencyService.Get<MainViewModel>();
var itemSourceType = vm.ItemSourceType;
return vm.GetItemsViewModel(itemSourceType);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
public class ItemSourceTypeToFilterConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)

View file

@ -3,7 +3,6 @@
<MasterDetailPage.Resources>
<ResourceDictionary>
<tools:ItemSourceTypeToStringConverter x:Key="ItemSourceTypeToTitleConverter" SpellVO="Spells" SpellHD="Sorts (H&amp;D)" MonsterVO="Monsters" MonsterHD="Créatures (H&amp;D)" />
<tools:ItemSourceTypeToItemsConverter x:Key="ItemSourceTypeToItemsConverter" />
<tools:ItemSourceTypeToFilterConverter x:Key="ItemSourceTypeToFilterConverter" />
</ResourceDictionary>
</MasterDetailPage.Resources>

View file

@ -10,8 +10,7 @@
<ResourceDictionary>
<tools:MonsterMarkdownTheme x:Key="MonsterMarkdownTheme" />
<tools:NullToFalseConverter x:Key="NullToFalseConverter" />
<tools:HtmlNodeToFormattedStringConverter x:Key="HtmlNodeToFormattedStringConverter" />
<tools:HtmlNodesToFormattedStringConverter x:Key="HtmlNodesToFormattedStringConverter" />
<tools:StringListToStringConverter x:Key="StringListToStringConverter" />
</ResourceDictionary>
</ContentPage.Resources>
<ScrollView Orientation="Vertical" BackgroundColor="#fdf1dc">
@ -74,16 +73,16 @@
<skia:SKCanvasView PaintSurface="PaintRedBar" HorizontalOptions="FillAndExpand" HeightRequest="8"/>
<Label Text="Capacités" Style="{StaticResource Key=subsubsection}" IsVisible="{Binding Item.SpecialFeatures, Converter={StaticResource NullToFalseConverter}}" />
<mdview:MarkdownView x:Name="mdSpecialFeatures" Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding Item.SpecialFeatures, Converter={StaticResource HtmlNodesToFormattedStringConverter}}" IsVisible="{Binding Item.SpecialFeatures, Converter={StaticResource NullToFalseConverter}}" />
<mdview:MarkdownView x:Name="mdSpecialFeatures" Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding Item.SpecialFeatures, Converter={StaticResource StringListToStringConverter}}" IsVisible="{Binding Item.SpecialFeatures, Converter={StaticResource NullToFalseConverter}}" />
<Label Text="Actions" Style="{StaticResource Key=subsubsection}" IsVisible="{Binding Item.Actions, Converter={StaticResource NullToFalseConverter}}" />
<mdview:MarkdownView x:Name="mdActions" Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding Item.Actions, Converter={StaticResource HtmlNodesToFormattedStringConverter}}" IsVisible="{Binding Item.Actions, Converter={StaticResource NullToFalseConverter}}" />
<mdview:MarkdownView x:Name="mdActions" Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding Item.Actions, Converter={StaticResource StringListToStringConverter}}" IsVisible="{Binding Item.Actions, Converter={StaticResource NullToFalseConverter}}" />
<Label Text="Réactions" Style="{StaticResource Key=subsubsection}" IsVisible="{Binding Item.Reactions, Converter={StaticResource NullToFalseConverter}}" />
<mdview:MarkdownView x:Name="mdReactions" Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding Item.Reactions, Converter={StaticResource HtmlNodesToFormattedStringConverter}}" IsVisible="{Binding Item.Reactions, Converter={StaticResource NullToFalseConverter}}" />
<mdview:MarkdownView x:Name="mdReactions" Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding Item.Reactions, Converter={StaticResource StringListToStringConverter}}" IsVisible="{Binding Item.Reactions, Converter={StaticResource NullToFalseConverter}}" />
<Label Text="Actions légendaires" Style="{StaticResource Key=subsubsection}" IsVisible="{Binding Item.LegendaryActions, Converter={StaticResource NullToFalseConverter}}" />
<mdview:MarkdownView x:Name="mdLegendaryActions" Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding Item.LegendaryActions, Converter={StaticResource HtmlNodesToFormattedStringConverter}}" IsVisible="{Binding Item.LegendaryActions, Converter={StaticResource NullToFalseConverter}}" />
<mdview:MarkdownView x:Name="mdLegendaryActions" Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding Item.LegendaryActions, Converter={StaticResource StringListToStringConverter}}" IsVisible="{Binding Item.LegendaryActions, Converter={StaticResource NullToFalseConverter}}" />
<skia:SKCanvasView PaintSurface="PaintHeaderBar" HorizontalOptions="FillAndExpand" HeightRequest="8" />

View file

@ -9,8 +9,7 @@
<ResourceDictionary>
<tools:MonsterMarkdownTheme x:Key="MonsterMarkdownTheme" />
<tools:NullToFalseConverter x:Key="NullToFalseConverter" />
<tools:HtmlNodeToFormattedStringConverter x:Key="HtmlNodeToFormattedStringConverter" />
<tools:HtmlNodesToFormattedStringConverter x:Key="HtmlNodesToFormattedStringConverter" />
<tools:StringListToStringConverter x:Key="StringListToStringConverter" />
</ResourceDictionary>
</ContentPage.Resources>
<ScrollView VerticalScrollBarVisibility="Default" HorizontalScrollBarVisibility="Default">