1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-31 07:26:09 +00:00

Ajustements

This commit is contained in:
Yan Maniez 2018-07-13 15:07:25 +02:00
parent 80105428a2
commit 72587c773a
6 changed files with 140 additions and 131 deletions

View file

@ -1,4 +1,7 @@
using System; using AideDeJeu.Tools;
using Markdig.Syntax;
using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@ -21,5 +24,123 @@ namespace AideDeJeuLib
public string Source { get; set; } public string Source { get; set; }
public abstract string LevelType { get; set; } public abstract string LevelType { get; set; }
public override void Parse(ref ContainerBlock.Enumerator enumerator)
{
enumerator.MoveNext();
while (enumerator.Current != null)
{
var block = enumerator.Current;
if (block is Markdig.Syntax.HeadingBlock)
{
var headingBlock = block as Markdig.Syntax.HeadingBlock;
//DumpHeadingBlock(headingBlock);
if (headingBlock.HeaderChar == '#' && headingBlock.Level == 1)
{
if (this.Name != null)
{
return;
}
this.Name = headingBlock.Inline.ToMarkdownString();
//Console.WriteLine(spell.Name);
}
}
if (block is Markdig.Syntax.ParagraphBlock)
{
if (block.IsNewItem())
{
return;
}
var paragraphBlock = block as Markdig.Syntax.ParagraphBlock;
this.DescriptionHtml += MarkdownExtensions.MarkdownToHtml(paragraphBlock.ToMarkdownString()) + "\n";
////DumpParagraphBlock(paragraphBlock);
//Console.WriteLine(paragraphBlock.IsBreakable);
//spell.DescriptionHtml += paragraphBlock.Inline.ToContainerString();
//if(paragraphBlock.IsBreakable)
//{
// spell.DescriptionHtml += "\n";
//}
}
if (block is Markdig.Syntax.ListBlock)
{
var listBlock = block as Markdig.Syntax.ListBlock;
//DumpListBlock(listBlock);
if (listBlock.BulletType == '-')
{
this.Source = "";
foreach (var inblock in listBlock)
{
//DumpBlock(inblock);
var regex = new Regex("(?<key>.*?): (?<value>.*)");
if (inblock is Markdig.Syntax.ListItemBlock)
{
var listItemBlock = inblock as Markdig.Syntax.ListItemBlock;
foreach (var ininblock in listItemBlock)
{
//DumpBlock(ininblock);
if (ininblock is Markdig.Syntax.ParagraphBlock)
{
var paragraphBlock = ininblock as Markdig.Syntax.ParagraphBlock;
//DumpParagraphBlock(paragraphBlock);
var str = paragraphBlock.Inline.ToMarkdownString();
var properties = new List<Tuple<string, Action<Spell, string>>>()
{
new Tuple<string, Action<Spell, string>>("NameVO: ", (m, s) => m.NameVO = s),
new Tuple<string, Action<Spell, string>>("CastingTime: ", (m, s) => m.CastingTime = s),
new Tuple<string, Action<Spell, string>>("Components: ", (m, s) => m.Components = s),
new Tuple<string, Action<Spell, string>>("Duration: ", (m, s) => m.Duration = s),
new Tuple<string, Action<Spell, string>>("LevelType: ", (m, s) => m.LevelType = s),
new Tuple<string, Action<Spell, string>>("Range: ", (m, s) => m.Range = s),
new Tuple<string, Action<Spell, string>>("Source: ", (m, s) => m.Source = s),
new Tuple<string, Action<Spell, string>>("Classes: ", (m, s) => m.Source += s),
new Tuple<string, Action<Spell, string>>("", (m,s) =>
{
})
};
foreach (var property in properties)
{
if (str.StartsWith(property.Item1))
{
property.Item2.Invoke(this, str.Substring(property.Item1.Length));
break;
}
}
}
}
}
}
}
else
{
foreach (var inblock in listBlock)
{
if (inblock is Markdig.Syntax.ListItemBlock)
{
var listItemBlock = inblock as Markdig.Syntax.ListItemBlock;
foreach (var ininblock in listItemBlock)
{
//DumpBlock(ininblock);
if (ininblock is Markdig.Syntax.ParagraphBlock)
{
var paragraphBlock = ininblock as Markdig.Syntax.ParagraphBlock;
this.DescriptionHtml += listBlock.BulletType + " " + MarkdownExtensions.MarkdownToHtml(paragraphBlock.ToMarkdownString()) + "\n";
}
}
}
}
}
}
else if (block is Markdig.Extensions.Tables.Table)
{
var tableBlock = block as Markdig.Extensions.Tables.Table;
this.DescriptionHtml += "\n\n" + tableBlock.ToMarkdownString() + "\n\n";
}
enumerator.MoveNext();
}
}
} }
} }

View file

@ -57,134 +57,18 @@ namespace AideDeJeuLib
{ {
return return
$"# {Name}\n" + $"# {Name}\n" +
$"- {NameVO}\n" + $"{NameVO}\n" +
$"- _{LevelType}_\n" + $"_{LevelType}_\n" +
$"- **Temps d'incantation :** {CastingTime}\n" + $"**Temps d'incantation :** {CastingTime}\n" +
$"- **Portée :** {Range}\n" + $"**Portée :** {Range}\n" +
$"- **Composantes :** {Components}\n" + $"**Composantes :** {Components}\n" +
$"- **Durée :** {Duration}\n\n" + $"**Durée :** {Duration}\n\n" +
$"{DescriptionHtml}\n\n" + $"{DescriptionHtml}\n\n" +
$"- **Source :** {Source}"; $"**Source :** {Source}";
} }
} }
public override void Parse(ref ContainerBlock.Enumerator enumerator)
{
enumerator.MoveNext();
while (enumerator.Current != null)
{
var block = enumerator.Current;
if (block is Markdig.Syntax.HeadingBlock)
{
var headingBlock = block as Markdig.Syntax.HeadingBlock;
//DumpHeadingBlock(headingBlock);
if (headingBlock.HeaderChar == '#' && headingBlock.Level == 1)
{
if(this.Name != null)
{
return;
}
this.Name = headingBlock.Inline.ToMarkdownString();
//Console.WriteLine(spell.Name);
}
}
if (block is Markdig.Syntax.ParagraphBlock)
{
if(block.IsNewItem())
{
return;
}
var paragraphBlock = block as Markdig.Syntax.ParagraphBlock;
this.DescriptionHtml += MarkdownExtensions.MarkdownToHtml(paragraphBlock.ToMarkdownString()) + "\n";
////DumpParagraphBlock(paragraphBlock);
//Console.WriteLine(paragraphBlock.IsBreakable);
//spell.DescriptionHtml += paragraphBlock.Inline.ToContainerString();
//if(paragraphBlock.IsBreakable)
//{
// spell.DescriptionHtml += "\n";
//}
}
if (block is Markdig.Syntax.ListBlock)
{
var listBlock = block as Markdig.Syntax.ListBlock;
//DumpListBlock(listBlock);
if (listBlock.BulletType == '-')
{
this.Source = "";
foreach (var inblock in listBlock)
{
//DumpBlock(inblock);
var regex = new Regex("(?<key>.*?): (?<value>.*)");
if (inblock is Markdig.Syntax.ListItemBlock)
{
var listItemBlock = inblock as Markdig.Syntax.ListItemBlock;
foreach (var ininblock in listItemBlock)
{
//DumpBlock(ininblock);
if (ininblock is Markdig.Syntax.ParagraphBlock)
{
var paragraphBlock = ininblock as Markdig.Syntax.ParagraphBlock;
//DumpParagraphBlock(paragraphBlock);
var str = paragraphBlock.Inline.ToMarkdownString();
var properties = new List<Tuple<string, Action<Spell, string>>>()
{
new Tuple<string, Action<Spell, string>>("NameVO: ", (m, s) => m.NameVO = s),
new Tuple<string, Action<Spell, string>>("CastingTime: ", (m, s) => m.CastingTime = s),
new Tuple<string, Action<Spell, string>>("Components: ", (m, s) => m.Components = s),
new Tuple<string, Action<Spell, string>>("Duration: ", (m, s) => m.Duration = s),
new Tuple<string, Action<Spell, string>>("LevelType: ", (m, s) => m.LevelType = s),
new Tuple<string, Action<Spell, string>>("Range: ", (m, s) => m.Range = s),
new Tuple<string, Action<Spell, string>>("Source: ", (m, s) => m.Source = s),
new Tuple<string, Action<Spell, string>>("Classes: ", (m, s) => m.Source += s),
new Tuple<string, Action<Spell, string>>("", (m,s) =>
{
})
};
foreach (var property in properties)
{
if (str.StartsWith(property.Item1))
{
property.Item2.Invoke(this, str.Substring(property.Item1.Length));
break;
}
}
}
}
}
}
}
else
{
foreach (var inblock in listBlock)
{
if (inblock is Markdig.Syntax.ListItemBlock)
{
var listItemBlock = inblock as Markdig.Syntax.ListItemBlock;
foreach (var ininblock in listItemBlock)
{
//DumpBlock(ininblock);
if (ininblock is Markdig.Syntax.ParagraphBlock)
{
var paragraphBlock = ininblock as Markdig.Syntax.ParagraphBlock;
this.DescriptionHtml += listBlock.BulletType + " " + MarkdownExtensions.MarkdownToHtml(paragraphBlock.ToMarkdownString()) + "\n";
}
}
}
}
}
}
else if (block is Markdig.Extensions.Tables.Table)
{
var tableBlock = block as Markdig.Extensions.Tables.Table;
this.DescriptionHtml += "\n\n" + tableBlock.ToMarkdownString() + "\n\n";
}
enumerator.MoveNext();
}
} }
} }
}

View file

@ -49,9 +49,5 @@ namespace AideDeJeuLib
} }
} }
public override void Parse(ref ContainerBlock.Enumerator enumerator)
{
throw new NotImplementedException();
}
} }
} }

View file

@ -54,7 +54,8 @@ namespace AideDeJeu.ViewModels
{ {
resourceName = "AideDeJeu.Data.spells_vo.md"; resourceName = "AideDeJeu.Data.spells_vo.md";
var md = await Tools.Helpers.GetResourceStringAsync(resourceName); var md = await Tools.Helpers.GetResourceStringAsync(resourceName);
_AllItems = Tools.MarkdownExtensions.MarkdownToSpells<SpellVO>(md); _AllItems = Tools.MarkdownExtensions.ToItem(md) as IEnumerable<Item>;
//_AllItems = Tools.MarkdownExtensions.MarkdownToSpells<SpellVO>(md);
} }
break; break;
case ItemSourceType.SpellHD: case ItemSourceType.SpellHD:

View file

@ -21,7 +21,7 @@
<ContentPage Title=" "> <ContentPage Title=" ">
<StackLayout Orientation="Vertical"> <StackLayout Orientation="Vertical">
<StackLayout Margin="10,5,10,0" Padding="0" Spacing="0"> <StackLayout Margin="10,5,10,0" Padding="0" Spacing="0">
<Label Text="Listes" Style="{StaticResource Key=subsubsection}" /> <Label Text="Listes" Style="{StaticResource Key=subsubsection}" AutomationProperties.IsInAccessibleTree="True" AutomationProperties.Name="test"/>
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding ItemsSources, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding ItemsSourcesIndex}" /> <Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding ItemsSources, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding ItemsSourcesIndex}" />
</StackLayout> </StackLayout>
<ListView SelectionMode="None" ItemsSource="{Binding ItemSourceType, Converter={StaticResource ItemSourceTypeToFilterConverter}}" HasUnevenRows="True" RowHeight="-1" SeparatorVisibility="None" IsPullToRefreshEnabled="False" HorizontalOptions="FillAndExpand" > <ListView SelectionMode="None" ItemsSource="{Binding ItemSourceType, Converter={StaticResource ItemSourceTypeToFilterConverter}}" HasUnevenRows="True" RowHeight="-1" SeparatorVisibility="None" IsPullToRefreshEnabled="False" HorizontalOptions="FillAndExpand" >
@ -64,7 +64,7 @@
<ListView Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" x:Name="ItemsListView" ItemsSource="{Binding Items}" VerticalOptions="FillAndExpand" HasUnevenRows="true" CachingStrategy="RecycleElement" SelectedItem="{Binding SelectedItem}" ItemTapped="ItemsListView_ItemTapped"> <ListView Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" x:Name="ItemsListView" ItemsSource="{Binding Items}" VerticalOptions="FillAndExpand" HasUnevenRows="true" CachingStrategy="RecycleElement" SelectedItem="{Binding SelectedItem}" ItemTapped="ItemsListView_ItemTapped">
<ListView.ItemTemplate> <ListView.ItemTemplate>
<DataTemplate> <DataTemplate>
<ViewCell> <ViewCell AutomationProperties.IsInAccessibleTree="True" AutomationId="machin" AutomationProperties.Name="hop">
<StackLayout Padding="10" Orientation="Vertical"> <StackLayout Padding="10" Orientation="Vertical">
<Label Text="{Binding Name}" LineBreakMode="NoWrap" Style="{DynamicResource subsubsection}" FontSize="16" /> <Label Text="{Binding Name}" LineBreakMode="NoWrap" Style="{DynamicResource subsubsection}" FontSize="16" />
<Label Text="{Binding NameVOText}" LineBreakMode="NoWrap" Style="{DynamicResource subsubsection}" FontSize="12" /> <Label Text="{Binding NameVOText}" LineBreakMode="NoWrap" Style="{DynamicResource subsubsection}" FontSize="12" />

View file

@ -27,6 +27,13 @@ namespace AideDeJeu.Views
//Navigator = new Navigator((Detail as NavigationPage).Navigation); //Navigator = new Navigator((Detail as NavigationPage).Navigation);
//BindingContext = viewModel = new MainViewModel(Navigator); //BindingContext = viewModel = new MainViewModel(Navigator);
BindingContext = Main; BindingContext = Main;
this.SizeChanged += (o, e) => {
if(this.Width > 0 && this.Height > 0)
{
this.IsPresented = this.Width > this.Height;
}
};
} }
protected override void OnAppearing() protected override void OnAppearing()