mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-30 15:06:06 +00:00
Bidouille pour compat bookmarks, à revoir
This commit is contained in:
parent
f4deb95771
commit
851ad3e4af
5 changed files with 40 additions and 16 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
using AideDeJeu.ViewModels;
|
using AideDeJeu.ViewModels;
|
||||||
using AideDeJeu.Views;
|
using AideDeJeu.Views;
|
||||||
using AideDeJeuLib;
|
using AideDeJeuLib;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
using Xamarin.Forms.Xaml;
|
using Xamarin.Forms.Xaml;
|
||||||
|
|
||||||
|
|
@ -27,6 +29,7 @@ namespace AideDeJeu
|
||||||
var navigationPage = tabbeddPage.MainNavigationPage;
|
var navigationPage = tabbeddPage.MainNavigationPage;
|
||||||
vm.Navigator = new Navigator(navigationPage.Navigation);
|
vm.Navigator = new Navigator(navigationPage.Navigation);
|
||||||
MainPage = tabbeddPage;
|
MainPage = tabbeddPage;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnStart ()
|
protected override void OnStart ()
|
||||||
|
|
|
||||||
|
|
@ -265,7 +265,7 @@ namespace AideDeJeu.ViewModels
|
||||||
|
|
||||||
public async Task<IEnumerable<Item>> ToItems(string md)
|
public async Task<IEnumerable<Item>> ToItems(string md)
|
||||||
{
|
{
|
||||||
var item = Store.ToItem(null, md);
|
var item = Store.ToItem(null, md, null);
|
||||||
//if(item is Items)
|
//if(item is Items)
|
||||||
//{
|
//{
|
||||||
var items = item; // as Items;
|
var items = item; // as Items;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace AideDeJeu.ViewModels
|
||||||
{
|
{
|
||||||
public class StoreViewModel : BaseViewModel
|
public class StoreViewModel : BaseViewModel
|
||||||
{
|
{
|
||||||
public Item ToItem(string source, string md)
|
public Item ToItem(string source, string md, Dictionary<string, Item> allItems)
|
||||||
{
|
{
|
||||||
var pipeline = new MarkdownPipelineBuilder().UsePipeTables().Build();
|
var pipeline = new MarkdownPipelineBuilder().UsePipeTables().Build();
|
||||||
var document = MarkdownParser.Parse(md, pipeline);
|
var document = MarkdownParser.Parse(md, pipeline);
|
||||||
|
|
@ -35,7 +35,7 @@ namespace AideDeJeu.ViewModels
|
||||||
{
|
{
|
||||||
if (IsNewItem(block))
|
if (IsNewItem(block))
|
||||||
{
|
{
|
||||||
var item = ParseItem(source, ref enumerator);
|
var item = ParseItem(source, ref enumerator, allItems);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -50,7 +50,7 @@ namespace AideDeJeu.ViewModels
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item ParseItem(string source, ref ContainerBlock.Enumerator enumerator)
|
public Item ParseItem(string source, ref ContainerBlock.Enumerator enumerator, Dictionary<string, Item> allItems)
|
||||||
{
|
{
|
||||||
var currentItem = GetNewItem(enumerator.Current);
|
var currentItem = GetNewItem(enumerator.Current);
|
||||||
|
|
||||||
|
|
@ -65,16 +65,16 @@ namespace AideDeJeu.ViewModels
|
||||||
{
|
{
|
||||||
if (IsClosingItem(block))
|
if (IsClosingItem(block))
|
||||||
{
|
{
|
||||||
currentItem.Id = GetNewAnchorId(source, currentItem.Name);
|
currentItem.Id = GetNewAnchorId(source, currentItem.Name, allItems);
|
||||||
if (currentItem.Id != null)
|
if (currentItem.Id != null && allItems != null)
|
||||||
{
|
{
|
||||||
_AllItems[currentItem.Id] = currentItem;
|
allItems[currentItem.Id] = currentItem;
|
||||||
}
|
}
|
||||||
return currentItem;
|
return currentItem;
|
||||||
}
|
}
|
||||||
else if (IsNewItem(block))
|
else if (IsNewItem(block))
|
||||||
{
|
{
|
||||||
var subItem = ParseItem(source, ref enumerator);
|
var subItem = ParseItem(source, ref enumerator, allItems);
|
||||||
|
|
||||||
var propertyName = subItem.GetType().Name;
|
var propertyName = subItem.GetType().Name;
|
||||||
|
|
||||||
|
|
@ -88,7 +88,7 @@ namespace AideDeJeu.ViewModels
|
||||||
}
|
}
|
||||||
else //if (currentItem is Items)
|
else //if (currentItem is Items)
|
||||||
{
|
{
|
||||||
if (currentItem.GetNewFilterViewModel() == null)
|
if (allItems != null && currentItem.GetNewFilterViewModel() == null)
|
||||||
{
|
{
|
||||||
var name = subItem.Name;
|
var name = subItem.Name;
|
||||||
var level = Math.Max(1, Math.Min(6, subItem.NameLevel));
|
var level = Math.Max(1, Math.Min(6, subItem.NameLevel));
|
||||||
|
|
@ -123,8 +123,11 @@ namespace AideDeJeu.ViewModels
|
||||||
enumerator.MoveNext();
|
enumerator.MoveNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentItem.Id = GetNewAnchorId(source, currentItem.Name);
|
currentItem.Id = GetNewAnchorId(source, currentItem.Name, allItems);
|
||||||
_AllItems[currentItem.Id] = currentItem;
|
if (allItems != null)
|
||||||
|
{
|
||||||
|
allItems[currentItem.Id] = currentItem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return currentItem;
|
return currentItem;
|
||||||
|
|
@ -273,7 +276,7 @@ namespace AideDeJeu.ViewModels
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public string GetNewAnchorId(string source, string name)
|
public string GetNewAnchorId(string source, string name, Dictionary<string, Item> allItems)
|
||||||
{
|
{
|
||||||
if (name != null)
|
if (name != null)
|
||||||
{
|
{
|
||||||
|
|
@ -282,7 +285,7 @@ namespace AideDeJeu.ViewModels
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (!_AllItems.ContainsKey(name))
|
if (allItems == null || !allItems.ContainsKey(name))
|
||||||
{
|
{
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
@ -349,7 +352,7 @@ namespace AideDeJeu.ViewModels
|
||||||
var md = await Tools.Helpers.GetResourceStringAsync(resourceName);
|
var md = await Tools.Helpers.GetResourceStringAsync(resourceName);
|
||||||
if (md != null)
|
if (md != null)
|
||||||
{
|
{
|
||||||
var item = ToItem(source, md);
|
var item = ToItem(source, md, _AllItems);
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
var anchors = new Dictionary<string, Item>();
|
var anchors = new Dictionary<string, Item>();
|
||||||
|
|
@ -428,7 +431,7 @@ namespace AideDeJeu.ViewModels
|
||||||
var md = await Tools.Helpers.GetResourceStringAsync($"AideDeJeu.Data.{source}.md");
|
var md = await Tools.Helpers.GetResourceStringAsync($"AideDeJeu.Data.{source}.md");
|
||||||
if (md != null)
|
if (md != null)
|
||||||
{
|
{
|
||||||
var item = ToItem(source, md);
|
var item = ToItem(source, md, _AllItems);
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
var anchors = new Dictionary<string, Item>();
|
var anchors = new Dictionary<string, Item>();
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ using AideDeJeu.ViewModels;
|
||||||
using AideDeJeuLib;
|
using AideDeJeuLib;
|
||||||
using SkiaSharp;
|
using SkiaSharp;
|
||||||
using SkiaSharp.Views.Forms;
|
using SkiaSharp.Views.Forms;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
using Xamarin.Forms.Xaml;
|
using Xamarin.Forms.Xaml;
|
||||||
|
|
||||||
|
|
@ -42,6 +44,10 @@ namespace AideDeJeu.Views
|
||||||
Markdown = AideDeJeu.Tools.Helpers.GetResourceString($"AideDeJeu.Data.index.md"),
|
Markdown = AideDeJeu.Tools.Helpers.GetResourceString($"AideDeJeu.Data.index.md"),
|
||||||
}
|
}
|
||||||
) { Title = "Bibliothèque" };
|
) { Title = "Bibliothèque" };
|
||||||
|
|
||||||
|
|
||||||
|
//Task.Run(async () => await InitDBEngineAsync().ConfigureAwait(false));
|
||||||
|
|
||||||
//var item = new Item
|
//var item = new Item
|
||||||
//{
|
//{
|
||||||
// Name = "",
|
// Name = "",
|
||||||
|
|
@ -53,6 +59,16 @@ namespace AideDeJeu.Views
|
||||||
//BindingContext = viewModel;
|
//BindingContext = viewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async Task InitDBEngineAsync()
|
||||||
|
{
|
||||||
|
await Task.Delay(1000).ConfigureAwait(false);
|
||||||
|
using (var context = await StoreViewModel.GetDatabaseContextAsync().ConfigureAwait(false))
|
||||||
|
{
|
||||||
|
var item = context.Items.FirstOrDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PaintHeaderBar(object sender, SKPaintSurfaceEventArgs args)
|
void PaintHeaderBar(object sender, SKPaintSurfaceEventArgs args)
|
||||||
{
|
{
|
||||||
SKImageInfo info = args.Info;
|
SKImageInfo info = args.Info;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using AideDeJeu.ViewModels;
|
using AideDeJeu.ViewModels;
|
||||||
using AideDeJeuLib;
|
using AideDeJeuLib;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace AideDeJeuUnitTest
|
namespace AideDeJeuUnitTest
|
||||||
|
|
@ -11,8 +12,9 @@ namespace AideDeJeuUnitTest
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public async Task TestMethod1()
|
public async Task TestMethod1()
|
||||||
{
|
{
|
||||||
|
var allItems = new Dictionary<string, Item>();
|
||||||
var store = new StoreViewModel();
|
var store = new StoreViewModel();
|
||||||
var item = store.ToItem(null, AideDeJeu.Tools.Helpers.GetResourceString($"AideDeJeu.Data.sandbox.md"));
|
var item = store.ToItem(null, AideDeJeu.Tools.Helpers.GetResourceString($"AideDeJeu.Data.sandbox.md"), allItems);
|
||||||
var md = item.Markdown;
|
var md = item.Markdown;
|
||||||
var children = await item.GetChildrenAsync();
|
var children = await item.GetChildrenAsync();
|
||||||
foreach(var iitem in children)
|
foreach(var iitem in children)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue