mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-30 15:06:06 +00:00
Réorg liens markdown
This commit is contained in:
parent
5f6422bc3e
commit
0f19bc9195
5 changed files with 44 additions and 48 deletions
|
|
@ -53,5 +53,16 @@ namespace AideDeJeu.Tools
|
||||||
return new string(chars).Normalize(NormalizationForm.FormC);
|
return new string(chars).Normalize(NormalizationForm.FormC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string Capitalize(string text)
|
||||||
|
{
|
||||||
|
return string.Concat(text.Take(1)).ToUpper() + string.Concat(text.Skip(1)).ToString().ToLower();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string IdFromName(string name)
|
||||||
|
{
|
||||||
|
return RemoveDiacritics(name.ToLower().Replace(" ", "-"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
|
|
||||||
namespace AideDeJeu.ViewModels
|
namespace AideDeJeu.ViewModels
|
||||||
|
|
@ -155,5 +158,26 @@ namespace AideDeJeu.ViewModels
|
||||||
await GetItemsViewModel(ItemSourceType).ExecuteLoadItemsCommandAsync();
|
await GetItemsViewModel(ItemSourceType).ExecuteLoadItemsCommandAsync();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task NavigateToLink(string s)
|
||||||
|
{
|
||||||
|
var regex = new Regex("/(?<file>.*)\\.md#(?<anchor>.*)");
|
||||||
|
var match = regex.Match(s);
|
||||||
|
var file = match.Groups["file"].Value;
|
||||||
|
var anchor = match.Groups["anchor"].Value;
|
||||||
|
if (file == "spells_hd")
|
||||||
|
{
|
||||||
|
var spells = await GetItemsViewModel(ItemSourceType.SpellHD).GetAllItemsAsync();
|
||||||
|
var spell = spells.Where(i => Tools.Helpers.IdFromName(i.Id) == anchor).FirstOrDefault();
|
||||||
|
await Navigator.GotoSpellDetailPageAsync(spell);
|
||||||
|
}
|
||||||
|
else if (file == "monsters_hd")
|
||||||
|
{
|
||||||
|
var monsters = await GetItemsViewModel(ItemSourceType.MonsterHD).GetAllItemsAsync();
|
||||||
|
var monster = monsters.Where(i => Tools.Helpers.IdFromName(i.Id) == anchor).FirstOrDefault();
|
||||||
|
await Navigator.GotoMonsterDetailPageAsync(monster);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5,6 +5,7 @@ using AideDeJeuLib.Spells;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
|
@ -51,5 +52,7 @@ namespace AideDeJeu.ViewModels
|
||||||
vm.LoadItemCommand.Execute(null);
|
vm.LoadItemCommand.Execute(null);
|
||||||
await Navigation.PushAsync(new SpellDetailPage(vm));
|
await Navigation.PushAsync(new SpellDetailPage(vm));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,11 +89,11 @@
|
||||||
|
|
||||||
<Label Text="Réactions" Style="{StaticResource Key=subsubsection}" IsVisible="{Binding Item.Reactions, Converter={StaticResource NullToFalseConverter}}" />
|
<Label Text="Réactions" Style="{StaticResource Key=subsubsection}" IsVisible="{Binding Item.Reactions, Converter={StaticResource NullToFalseConverter}}" />
|
||||||
<!--<Label FormattedText="{Binding Item.Reactions, Converter={StaticResource HtmlNodesToFormattedStringConverter}}" IsVisible="{Binding Item.Reactions, Converter={StaticResource NullToFalseConverter}}" />-->
|
<!--<Label FormattedText="{Binding Item.Reactions, Converter={StaticResource HtmlNodesToFormattedStringConverter}}" IsVisible="{Binding Item.Reactions, Converter={StaticResource NullToFalseConverter}}" />-->
|
||||||
<mdview:MarkdownView 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 HtmlNodesToFormattedStringConverter}}" IsVisible="{Binding Item.Reactions, 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.LegendaryActions, 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}}" />-->
|
||||||
<mdview:MarkdownView 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 HtmlNodesToFormattedStringConverter}}" IsVisible="{Binding Item.LegendaryActions, Converter={StaticResource NullToFalseConverter}}" />
|
||||||
|
|
||||||
<!--<ListView ItemsSource="{Binding Item.SpecialFeaturesNodes}">
|
<!--<ListView ItemsSource="{Binding Item.SpecialFeaturesNodes}">
|
||||||
<ListView.ItemTemplate>
|
<ListView.ItemTemplate>
|
||||||
|
|
|
||||||
|
|
@ -26,54 +26,12 @@ namespace AideDeJeu.Views
|
||||||
|
|
||||||
BindingContext = this.viewModel = viewModel;
|
BindingContext = this.viewModel = viewModel;
|
||||||
|
|
||||||
mdSpecialFeatures.NavigateToLink = async(s) => await NavigateToLink(s);
|
mdSpecialFeatures.NavigateToLink = async(s) => await viewModel.Main.NavigateToLink(s);
|
||||||
mdActions.NavigateToLink = async (s) => await NavigateToLink(s);
|
mdActions.NavigateToLink = async (s) => await viewModel.Main.NavigateToLink(s);
|
||||||
|
mdReactions.NavigateToLink = async (s) => await viewModel.Main.NavigateToLink(s);
|
||||||
|
mdLegendaryActions.NavigateToLink = async (s) => await viewModel.Main.NavigateToLink(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task NavigateToLink(string s)
|
|
||||||
{
|
|
||||||
var regex = new Regex("/(?<file>.*)\\.md#(?<anchor>.*)");
|
|
||||||
var match = regex.Match(s);
|
|
||||||
var file = match.Groups["file"].Value;
|
|
||||||
var anchor = match.Groups["anchor"].Value;
|
|
||||||
if (file == "spells_hd")
|
|
||||||
{
|
|
||||||
var spells = await viewModel.Main.GetItemsViewModel(ItemSourceType.SpellHD).GetAllItemsAsync();
|
|
||||||
var spell = spells.Where(i => IdFromName(i.Id) == anchor).FirstOrDefault();
|
|
||||||
var page = new SpellDetailPage(new SpellDetailViewModel(spell as Spell));
|
|
||||||
await Navigation.PushAsync(page);
|
|
||||||
}
|
|
||||||
else if (file == "monsters_hd")
|
|
||||||
{
|
|
||||||
var monsters = await viewModel.Main.GetItemsViewModel(ItemSourceType.MonsterHD).GetAllItemsAsync();
|
|
||||||
var monster = monsters.Where(i => IdFromName(i.Id) == anchor).FirstOrDefault();
|
|
||||||
var page = new MonsterDetailPage(new MonsterDetailViewModel(monster as Monster));
|
|
||||||
await Navigation.PushAsync(page);
|
|
||||||
}
|
|
||||||
//Device.OpenUri(new Uri(s));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string Capitalize(string text)
|
|
||||||
{
|
|
||||||
return string.Concat(text.Take(1)).ToUpper() + string.Concat(text.Skip(1)).ToString().ToLower();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string RemoveDiacritics(string text)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(text))
|
|
||||||
return text;
|
|
||||||
|
|
||||||
text = text.Normalize(NormalizationForm.FormD);
|
|
||||||
var chars = text.Where(c => CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark).ToArray();
|
|
||||||
return new string(chars).Normalize(NormalizationForm.FormC);
|
|
||||||
}
|
|
||||||
|
|
||||||
static string IdFromName(string name)
|
|
||||||
{
|
|
||||||
return RemoveDiacritics(name.ToLower().Replace(" ", "-"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public MonsterDetailPage()
|
public MonsterDetailPage()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue