mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-10-31 07:26:09 +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.Views; | ||||
| using AideDeJeuLib; | ||||
| using System.Linq; | ||||
| using System.Threading.Tasks; | ||||
| using Xamarin.Forms; | ||||
| using Xamarin.Forms.Xaml; | ||||
| 
 | ||||
|  | @ -27,6 +29,7 @@ namespace AideDeJeu | |||
|             var navigationPage = tabbeddPage.MainNavigationPage; | ||||
|             vm.Navigator = new Navigator(navigationPage.Navigation); | ||||
|             MainPage = tabbeddPage; | ||||
| 
 | ||||
|         } | ||||
| 
 | ||||
|         protected override void OnStart () | ||||
|  |  | |||
|  | @ -265,7 +265,7 @@ namespace AideDeJeu.ViewModels | |||
| 
 | ||||
|         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) | ||||
|             //{ | ||||
|             var items = item; // as Items; | ||||
|  |  | |||
|  | @ -18,7 +18,7 @@ namespace AideDeJeu.ViewModels | |||
| { | ||||
|     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 document = MarkdownParser.Parse(md, pipeline); | ||||
|  | @ -35,7 +35,7 @@ namespace AideDeJeu.ViewModels | |||
|                     { | ||||
|                         if (IsNewItem(block)) | ||||
|                         { | ||||
|                             var item = ParseItem(source, ref enumerator); | ||||
|                             var item = ParseItem(source, ref enumerator, allItems); | ||||
|                             return item; | ||||
|                         } | ||||
|                     } | ||||
|  | @ -50,7 +50,7 @@ namespace AideDeJeu.ViewModels | |||
|             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); | ||||
| 
 | ||||
|  | @ -65,16 +65,16 @@ namespace AideDeJeu.ViewModels | |||
|                     { | ||||
|                         if (IsClosingItem(block)) | ||||
|                         { | ||||
|                             currentItem.Id = GetNewAnchorId(source, currentItem.Name); | ||||
|                             if (currentItem.Id != null) | ||||
|                             currentItem.Id = GetNewAnchorId(source, currentItem.Name, allItems); | ||||
|                             if (currentItem.Id != null && allItems != null) | ||||
|                             { | ||||
|                                 _AllItems[currentItem.Id] = currentItem; | ||||
|                                 allItems[currentItem.Id] = currentItem; | ||||
|                             } | ||||
|                             return currentItem; | ||||
|                         } | ||||
|                         else if (IsNewItem(block)) | ||||
|                         { | ||||
|                             var subItem = ParseItem(source, ref enumerator); | ||||
|                             var subItem = ParseItem(source, ref enumerator, allItems); | ||||
| 
 | ||||
|                             var propertyName = subItem.GetType().Name; | ||||
| 
 | ||||
|  | @ -88,7 +88,7 @@ namespace AideDeJeu.ViewModels | |||
|                             } | ||||
|                             else //if (currentItem is Items) | ||||
|                             { | ||||
|                                 if (currentItem.GetNewFilterViewModel() == null) | ||||
|                                 if (allItems != null && currentItem.GetNewFilterViewModel() == null) | ||||
|                                 { | ||||
|                                     var name = subItem.Name; | ||||
|                                     var level = Math.Max(1, Math.Min(6, subItem.NameLevel)); | ||||
|  | @ -123,8 +123,11 @@ namespace AideDeJeu.ViewModels | |||
|                         enumerator.MoveNext(); | ||||
|                     } | ||||
|                 } | ||||
|                 currentItem.Id = GetNewAnchorId(source, currentItem.Name); | ||||
|                 _AllItems[currentItem.Id] = currentItem; | ||||
|                 currentItem.Id = GetNewAnchorId(source, currentItem.Name, allItems); | ||||
|                 if (allItems != null) | ||||
|                 { | ||||
|                     allItems[currentItem.Id] = 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) | ||||
|             { | ||||
|  | @ -282,7 +285,7 @@ namespace AideDeJeu.ViewModels | |||
|                 int index = 0; | ||||
|                 while (true) | ||||
|                 { | ||||
|                     if (!_AllItems.ContainsKey(name)) | ||||
|                     if (allItems == null || !allItems.ContainsKey(name)) | ||||
|                     { | ||||
|                         return id; | ||||
|                     } | ||||
|  | @ -349,7 +352,7 @@ namespace AideDeJeu.ViewModels | |||
|                         var md = await Tools.Helpers.GetResourceStringAsync(resourceName); | ||||
|                         if (md != null) | ||||
|                         { | ||||
|                             var item = ToItem(source, md); | ||||
|                             var item = ToItem(source, md, _AllItems); | ||||
|                             if (item != null) | ||||
|                             { | ||||
|                                 var anchors = new Dictionary<string, Item>(); | ||||
|  | @ -428,7 +431,7 @@ namespace AideDeJeu.ViewModels | |||
|                 var md = await Tools.Helpers.GetResourceStringAsync($"AideDeJeu.Data.{source}.md"); | ||||
|                 if (md != null) | ||||
|                 { | ||||
|                     var item = ToItem(source, md); | ||||
|                     var item = ToItem(source, md, _AllItems); | ||||
|                     if (item != null) | ||||
|                     { | ||||
|                         var anchors = new Dictionary<string, Item>(); | ||||
|  |  | |||
|  | @ -3,6 +3,8 @@ using AideDeJeu.ViewModels; | |||
| using AideDeJeuLib; | ||||
| using SkiaSharp; | ||||
| using SkiaSharp.Views.Forms; | ||||
| using System.Linq; | ||||
| using System.Threading.Tasks; | ||||
| using Xamarin.Forms; | ||||
| using Xamarin.Forms.Xaml; | ||||
| 
 | ||||
|  | @ -42,6 +44,10 @@ namespace AideDeJeu.Views | |||
|                 Markdown = AideDeJeu.Tools.Helpers.GetResourceString($"AideDeJeu.Data.index.md"), | ||||
|             } | ||||
|             ) { Title = "Bibliothèque" }; | ||||
| 
 | ||||
| 
 | ||||
|             //Task.Run(async () => await InitDBEngineAsync().ConfigureAwait(false)); | ||||
| 
 | ||||
|             //var item = new Item | ||||
|             //{ | ||||
|             //    Name = "", | ||||
|  | @ -53,6 +59,16 @@ namespace AideDeJeu.Views | |||
|             //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) | ||||
|         { | ||||
|             SKImageInfo info = args.Info; | ||||
|  |  | |||
|  | @ -1,6 +1,7 @@ | |||
| using AideDeJeu.ViewModels; | ||||
| using AideDeJeuLib; | ||||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | ||||
| using System.Collections.Generic; | ||||
| using System.Threading.Tasks; | ||||
| 
 | ||||
| namespace AideDeJeuUnitTest | ||||
|  | @ -11,8 +12,9 @@ namespace AideDeJeuUnitTest | |||
|         [TestMethod] | ||||
|         public async Task TestMethod1() | ||||
|         { | ||||
|             var allItems = new Dictionary<string, Item>(); | ||||
|             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 children = await item.GetChildrenAsync(); | ||||
|             foreach(var iitem in children) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yan Maniez
						Yan Maniez