mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-10-31 07:26:09 +00:00 
			
		
		
		
	Tests assistant
This commit is contained in:
		
							parent
							
								
									bf01af25ee
								
							
						
					
					
						commit
						1ecf4afdc6
					
				
					 7 changed files with 147 additions and 45 deletions
				
			
		|  | @ -67,7 +67,7 @@ namespace AideDeJeu.Droid | ||||||
|                 string search = Intent.Extras.GetString("search"); |                 string search = Intent.Extras.GetString("search"); | ||||||
|                 if (!string.IsNullOrEmpty(search)) |                 if (!string.IsNullOrEmpty(search)) | ||||||
|                 { |                 { | ||||||
|                     Xamarin.Forms.Shell.Current.Navigation.PushAsync(new Views.Library.DeepSearchPage(search)); |                     Xamarin.Forms.Shell.Current.Navigation.PushAsync(new Views.Library.DeepSearchPage(search), true); | ||||||
|                 } |                 } | ||||||
|                 Intent.RemoveExtra("search"); |                 Intent.RemoveExtra("search"); | ||||||
|             } |             } | ||||||
|  | @ -157,6 +157,34 @@ namespace AideDeJeu.Droid | ||||||
|                 .Show(); |                 .Show(); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         public override void OnProvideAssistContent(Android.App.Assist.AssistContent outContent) | ||||||
|  |         { | ||||||
|  |             base.OnProvideAssistContent(outContent); | ||||||
|  | 
 | ||||||
|  |             outContent.WebUri = Android.Net.Uri.Parse("https://heros-et-dragons.fr/"); | ||||||
|  |             // Provide some JSON  | ||||||
|  |             string structuredJson = new Org.Json.JSONObject() | ||||||
|  |                 .Put("@type", "Book") | ||||||
|  |                 .Put("author", "Lewis Carroll") | ||||||
|  |                 .Put("name", "Alice in Wonderland") | ||||||
|  |                 .Put("description", | ||||||
|  |                     "This is an 1865 novel about a girl named Alice, " + | ||||||
|  |                     "who falls through a rabbit hole and " + | ||||||
|  |                     "enters a fantasy world." | ||||||
|  |                 ).ToString(); | ||||||
|  |                 //.Put("@type", "MusicRecording") | ||||||
|  |                 //.Put("@id", "https://example.com/music/recording") | ||||||
|  |                 //.Put("name", "Album Title") | ||||||
|  |                 //.ToString(); | ||||||
|  | 
 | ||||||
|  |             outContent.StructuredData = structuredJson; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public override void OnProvideAssistData(Bundle data) | ||||||
|  |         { | ||||||
|  |             base.OnProvideAssistData(data); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     [IntentFilter(new[] { Android.Content.Intent.ActionAssist }, Categories = new[] { Android.Content.Intent.CategoryDefault })] |     [IntentFilter(new[] { Android.Content.Intent.ActionAssist }, Categories = new[] { Android.Content.Intent.CategoryDefault })] | ||||||
|  | @ -187,12 +215,12 @@ namespace AideDeJeu.Droid | ||||||
|             this.FinishActivity(0); |             this.FinishActivity(0); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     public class AndroidListener : Java.Lang.Object, Application.IOnProvideAssistDataListener |     //public class AndroidListener : Java.Lang.Object, Application.IOnProvideAssistDataListener | ||||||
|     { |     //{ | ||||||
|         public void OnProvideAssistData(Android.App.Activity activity, Bundle data)  |     //    public void OnProvideAssistData(Android.App.Activity activity, Bundle data)  | ||||||
|         { |     //    { | ||||||
|             System.Diagnostics.Debug.WriteLine("OnProvideAssistData"); |     //        System.Diagnostics.Debug.WriteLine("OnProvideAssistData"); | ||||||
|         } |     //    } | ||||||
|     } |     //} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -40,7 +40,7 @@ namespace AideDeJeu | ||||||
|             //mainNavigationPage.Navigation.PushAsync(new MainPage()); |             //mainNavigationPage.Navigation.PushAsync(new MainPage()); | ||||||
|             if (search != null) |             if (search != null) | ||||||
|             { |             { | ||||||
|                 Shell.Current.Navigation.PushAsync(new Views.Library.DeepSearchPage()); |                 Shell.Current.Navigation.PushAsync(new Views.Library.DeepSearchPage(), true); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | @ -4,6 +4,7 @@ using System.Collections.Generic; | ||||||
| using System.Diagnostics; | using System.Diagnostics; | ||||||
| using System.Linq; | using System.Linq; | ||||||
| using System.Text; | using System.Text; | ||||||
|  | using System.Text.RegularExpressions; | ||||||
| using System.Threading; | using System.Threading; | ||||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||||
| using System.Windows.Input; | using System.Windows.Input; | ||||||
|  | @ -158,5 +159,50 @@ namespace AideDeJeu.ViewModels.Library | ||||||
|             await LoadItemsAsync(cancellationTokenSource.Token); |             await LoadItemsAsync(cancellationTokenSource.Token); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  |         public async Task LoadPageAsync(string path) | ||||||
|  |         { | ||||||
|  |             var regex = new Regex("/?(?<file>.*?)(_with_(?<with>.*))?\\.md(#(?<anchor>.*))?"); | ||||||
|  |             var match = regex.Match(Uri.UnescapeDataString(path)); | ||||||
|  |             var file = match.Groups["file"].Value; | ||||||
|  |             var anchor = match.Groups["anchor"].Value; | ||||||
|  |             var with = match.Groups["with"].Value; | ||||||
|  |             Item item = null; | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 Main.IsBusy = true; | ||||||
|  |                 Main.IsLoading = true; | ||||||
|  |                 item = await Task.Run(async () => await Main.Store.GetItemFromDataAsync(file, anchor)); | ||||||
|  | 
 | ||||||
|  |                 if (item != null) | ||||||
|  |                 { | ||||||
|  |                     var filterViewModel = item.GetNewFilterViewModel(); | ||||||
|  |                     Item = item; | ||||||
|  |                     AllItems = item; | ||||||
|  |                     Filter = filterViewModel; | ||||||
|  |                     await ExecuteLoadItemsCommandAsync(); | ||||||
|  |                     if (!string.IsNullOrEmpty(with)) | ||||||
|  |                     { | ||||||
|  |                         var swith = with.Split('_'); | ||||||
|  |                         for (int i = 0; i < swith.Length / 2; i++) | ||||||
|  |                         { | ||||||
|  |                             var key = swith[i * 2 + 0]; | ||||||
|  |                             var val = swith[i * 2 + 1]; | ||||||
|  |                             filterViewModel.FilterWith(key, val); | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     //await App.Current.MainPage.DisplayAlert("Lien invalide", s, "OK"); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             finally | ||||||
|  |             { | ||||||
|  |                 Main.IsBusy = false; | ||||||
|  |                 Main.IsLoading = false; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -342,7 +342,7 @@ namespace AideDeJeu.ViewModels | ||||||
|                 }; |                 }; | ||||||
| 
 | 
 | ||||||
|             // Push the page to Navigation Stack |             // Push the page to Navigation Stack | ||||||
|             await PopupNavigation.Instance.PushAsync(popup); |             await PopupNavigation.Instance.PushAsync(popup, true); | ||||||
| 
 | 
 | ||||||
|             // await for the user to enter the text input |             // await for the user to enter the text input | ||||||
|             var result = await popup.PageClosedTask; |             var result = await popup.PageClosedTask; | ||||||
|  |  | ||||||
|  | @ -28,7 +28,7 @@ namespace AideDeJeu.Views.Library | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         private ItemViewModel _Item = null; |         private ItemViewModel _Item = new ItemViewModel(); | ||||||
|         public ItemViewModel Item |         public ItemViewModel Item | ||||||
|         { |         { | ||||||
|             get |             get | ||||||
|  | @ -71,7 +71,10 @@ namespace AideDeJeu.Views.Library | ||||||
|             set |             set | ||||||
|             { |             { | ||||||
|                 _Path = value; |                 _Path = value; | ||||||
|                 LoadPageAsync(); |                 if (Path != null) | ||||||
|  |                 { | ||||||
|  |                     Item?.LoadPageAsync(Path); | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -29,19 +29,23 @@ | ||||||
|         </ResourceDictionary> |         </ResourceDictionary> | ||||||
|     </Shell.Resources> |     </Shell.Resources> | ||||||
|     <Shell.FlyoutHeader> |     <Shell.FlyoutHeader> | ||||||
|         <Label Text="{Binding HeaderTitle}" /> |         <StackLayout> | ||||||
|  |             <Label Text="{Binding HeaderTitle}" /> | ||||||
|  |             <Label Text="{Binding CurrentItem.CurrentItem.CurrentItem.Route}" /> | ||||||
|  |             <Label Text="{Binding CurrentItem.CurrentItem.CurrentItem.Content.BindingContext.Item.Title}" /> | ||||||
|  |         </StackLayout> | ||||||
|     </Shell.FlyoutHeader> |     </Shell.FlyoutHeader> | ||||||
| 
 | 
 | ||||||
|     <ShellItem Title="Accueil"> |     <FlyoutItem Title="Accueil"> | ||||||
|         <ShellContent Title="Accueil"  ContentTemplate="{DataTemplate local:MainPage}" /> |         <ShellContent Title="Accueil"  ContentTemplate="{DataTemplate local:MainPage}" /> | ||||||
|     </ShellItem> |     </FlyoutItem> | ||||||
|     <ShellItem Title="Personnages" FlyoutIcon="battle_axe.png"> |     <FlyoutItem Title="Personnages" FlyoutIcon="battle_axe.png"> | ||||||
|         <ShellContent Title="Personnages"  ContentTemplate="{DataTemplate pc:PlayerCharacterEditorPage}" /> |         <ShellContent Title="Personnages"  ContentTemplate="{DataTemplate pc:PlayerCharacterEditorPage}" /> | ||||||
|     </ShellItem> |     </FlyoutItem> | ||||||
|     <ShellItem Title="Dés" FlyoutIcon="d20.png"> |     <FlyoutItem Title="Dés" FlyoutIcon="d20.png"> | ||||||
|         <ShellContent Title="Dés"  ContentTemplate="{DataTemplate local:DicesPage}" /> |         <ShellContent Title="Dés"  ContentTemplate="{DataTemplate local:DicesPage}" /> | ||||||
|     </ShellItem> |     </FlyoutItem> | ||||||
|     <ShellItem Title="Bibliothèque" FlyoutIcon="spell_book.png"> |     <FlyoutItem Title="Bibliothèque" FlyoutIcon="spell_book.png"> | ||||||
|         <!--<ShellContent Title="Bibliothèque" Icon="spell_book.png" ContentTemplate="{DataTemplate library:ItemPage}" />--> |         <!--<ShellContent Title="Bibliothèque" Icon="spell_book.png" ContentTemplate="{DataTemplate library:ItemPage}" />--> | ||||||
|         <ShellContent Title="Bibliothèque" Icon="spell_book.png"> |         <ShellContent Title="Bibliothèque" Icon="spell_book.png"> | ||||||
|             <ShellContent.ContentTemplate> |             <ShellContent.ContentTemplate> | ||||||
|  | @ -55,7 +59,7 @@ | ||||||
|             </ShellContent.ContentTemplate> |             </ShellContent.ContentTemplate> | ||||||
|         </ShellContent> |         </ShellContent> | ||||||
| 
 | 
 | ||||||
|     </ShellItem> |     </FlyoutItem> | ||||||
|     <!--<FlyoutItem Title="Héros & Dragons"> |     <!--<FlyoutItem Title="Héros & Dragons"> | ||||||
|         <ShellContent Title="Héros & Dragons" ContentTemplate="{DataTemplate library:ItemDetailPage}" /> |         <ShellContent Title="Héros & Dragons" ContentTemplate="{DataTemplate library:ItemDetailPage}" /> | ||||||
|     </FlyoutItem> |     </FlyoutItem> | ||||||
|  | @ -83,7 +87,7 @@ | ||||||
|     <FlyoutItem Title="SRD"> |     <FlyoutItem Title="SRD"> | ||||||
|         <ShellContent Title="SRD"  ContentTemplate="{DataTemplate library:ItemDetailPage}" /> |         <ShellContent Title="SRD"  ContentTemplate="{DataTemplate library:ItemDetailPage}" /> | ||||||
|     </FlyoutItem>--> |     </FlyoutItem>--> | ||||||
|     <ShellItem Title="Manuel des Règles"> |     <FlyoutItem Title="Manuel des Règles"> | ||||||
|         <ShellContent> |         <ShellContent> | ||||||
|             <ShellContent.ContentTemplate> |             <ShellContent.ContentTemplate> | ||||||
|                 <DataTemplate> |                 <DataTemplate> | ||||||
|  | @ -95,8 +99,8 @@ | ||||||
|                 </DataTemplate> |                 </DataTemplate> | ||||||
|             </ShellContent.ContentTemplate> |             </ShellContent.ContentTemplate> | ||||||
|         </ShellContent> |         </ShellContent> | ||||||
|     </ShellItem> |     </FlyoutItem> | ||||||
|     <ShellItem Title="Cadre de Campagne"> |     <FlyoutItem Title="Cadre de Campagne"> | ||||||
|         <ShellContent> |         <ShellContent> | ||||||
|             <ShellContent.ContentTemplate> |             <ShellContent.ContentTemplate> | ||||||
|                 <DataTemplate> |                 <DataTemplate> | ||||||
|  | @ -108,8 +112,8 @@ | ||||||
|                 </DataTemplate> |                 </DataTemplate> | ||||||
|             </ShellContent.ContentTemplate> |             </ShellContent.ContentTemplate> | ||||||
|         </ShellContent> |         </ShellContent> | ||||||
|     </ShellItem> |     </FlyoutItem> | ||||||
|     <ShellItem Title="Créatures et Oppositions"> |     <FlyoutItem Title="Créatures et Oppositions"> | ||||||
|         <ShellContent> |         <ShellContent> | ||||||
|             <ShellContent.ContentTemplate> |             <ShellContent.ContentTemplate> | ||||||
|                 <DataTemplate> |                 <DataTemplate> | ||||||
|  | @ -121,8 +125,8 @@ | ||||||
|                 </DataTemplate> |                 </DataTemplate> | ||||||
|             </ShellContent.ContentTemplate> |             </ShellContent.ContentTemplate> | ||||||
|         </ShellContent> |         </ShellContent> | ||||||
|     </ShellItem> |     </FlyoutItem> | ||||||
|     <ShellItem Title="Les Cinq Royaumes"> |     <FlyoutItem Title="Les Cinq Royaumes"> | ||||||
|         <ShellContent> |         <ShellContent> | ||||||
|             <ShellContent.ContentTemplate> |             <ShellContent.ContentTemplate> | ||||||
|                 <DataTemplate> |                 <DataTemplate> | ||||||
|  | @ -134,8 +138,8 @@ | ||||||
|                 </DataTemplate> |                 </DataTemplate> | ||||||
|             </ShellContent.ContentTemplate> |             </ShellContent.ContentTemplate> | ||||||
|         </ShellContent> |         </ShellContent> | ||||||
|     </ShellItem> |     </FlyoutItem> | ||||||
|     <ShellItem Title="Livre des Monstres"> |     <FlyoutItem Title="Livre des Monstres"> | ||||||
|         <ShellContent> |         <ShellContent> | ||||||
|             <ShellContent.ContentTemplate> |             <ShellContent.ContentTemplate> | ||||||
|                 <DataTemplate> |                 <DataTemplate> | ||||||
|  | @ -147,8 +151,8 @@ | ||||||
|                 </DataTemplate> |                 </DataTemplate> | ||||||
|             </ShellContent.ContentTemplate> |             </ShellContent.ContentTemplate> | ||||||
|         </ShellContent> |         </ShellContent> | ||||||
|     </ShellItem> |     </FlyoutItem> | ||||||
|     <ShellItem Title="Monstrueusement Mignons"> |     <FlyoutItem Title="Monstrueusement Mignons"> | ||||||
|         <ShellContent> |         <ShellContent> | ||||||
|             <ShellContent.ContentTemplate> |             <ShellContent.ContentTemplate> | ||||||
|                 <DataTemplate> |                 <DataTemplate> | ||||||
|  | @ -160,8 +164,8 @@ | ||||||
|                 </DataTemplate> |                 </DataTemplate> | ||||||
|             </ShellContent.ContentTemplate> |             </ShellContent.ContentTemplate> | ||||||
|         </ShellContent> |         </ShellContent> | ||||||
|     </ShellItem> |     </FlyoutItem> | ||||||
|     <ShellItem Title="SRD"> |     <FlyoutItem Title="SRD"> | ||||||
|         <ShellContent> |         <ShellContent> | ||||||
|             <ShellContent.ContentTemplate> |             <ShellContent.ContentTemplate> | ||||||
|                 <DataTemplate> |                 <DataTemplate> | ||||||
|  | @ -173,19 +177,19 @@ | ||||||
|                 </DataTemplate> |                 </DataTemplate> | ||||||
|             </ShellContent.ContentTemplate> |             </ShellContent.ContentTemplate> | ||||||
|         </ShellContent> |         </ShellContent> | ||||||
|     </ShellItem> |     </FlyoutItem> | ||||||
|     <ShellItem Title="Favoris"> |     <FlyoutItem Title="Favoris"> | ||||||
|         <ShellContent Title="Favoris"  ContentTemplate="{DataTemplate library:BookmarksPage}" FlyoutIcon="stars_stack.png" /> |         <ShellContent Title="Favoris"  ContentTemplate="{DataTemplate library:BookmarksPage}" FlyoutIcon="stars_stack.png" /> | ||||||
|     </ShellItem> |     </FlyoutItem> | ||||||
|     <ShellItem Title="Recherche"> |     <FlyoutItem Title="Recherche"> | ||||||
|         <ShellContent Title="Recherche"  ContentTemplate="{DataTemplate library:DeepSearchPage}"  FlyoutIcon="crystal_ball.png" /> |         <ShellContent Title="Recherche"  ContentTemplate="{DataTemplate library:DeepSearchPage}"  FlyoutIcon="crystal_ball.png" /> | ||||||
|     </ShellItem> |     </FlyoutItem> | ||||||
|     <!--Command="{Binding ShellNavigateCommand}" |     <!--Command="{Binding ShellNavigateCommand}" | ||||||
|               CommandParameter="//data/item?path=l5r_index_hd.md" |               CommandParameter="//data/item?path=l5r_index_hd.md" | ||||||
|               />--> |               />--> | ||||||
|     <ShellItem Title="A propos de..." FlyoutIcon="wooden_sign.png"> |     <FlyoutItem Title="A propos de..." FlyoutIcon="wooden_sign.png"> | ||||||
|         <ShellContent Title="A propos de..."  ContentTemplate="{DataTemplate local:AboutPage}" /> |         <ShellContent Title="A propos de..."  ContentTemplate="{DataTemplate local:AboutPage}" /> | ||||||
|     </ShellItem> |     </FlyoutItem> | ||||||
|     <!--<ShellItem Text="Test"> |     <!--<ShellItem Text="Test"> | ||||||
|          |          | ||||||
|     </ShellItem>--> |     </ShellItem>--> | ||||||
|  |  | ||||||
|  | @ -48,13 +48,34 @@ namespace AideDeJeu.Views | ||||||
|         protected override void OnNavigated(ShellNavigatedEventArgs args) |         protected override void OnNavigated(ShellNavigatedEventArgs args) | ||||||
|         { |         { | ||||||
|             base.OnNavigated(args); |             base.OnNavigated(args); | ||||||
|             Debug.WriteLine(this.CurrentItem.CurrentItem.CurrentItem); |             Debug.WriteLine(this.CurrentItem?.CurrentItem?.CurrentItem); | ||||||
|             HeaderTitle = this.CurrentItem.CurrentItem.CurrentItem.Route; |             HeaderTitle = this.CurrentItem?.CurrentItem?.CurrentItem?.Route; | ||||||
|  |             var content = this.CurrentItem?.CurrentItem?.CurrentItem?.Content; | ||||||
|  |             Debug.WriteLine(content); | ||||||
|  | 
 | ||||||
|  |             this.CurrentItem.CurrentItem.CurrentItem.PropertyChanged += CurrentItem_PropertyChanged; | ||||||
|  |             this.CurrentItem.CurrentItem.CurrentItem.Appearing += CurrentItem_Appearing; | ||||||
|  |             this.CurrentItem.CurrentItem.CurrentItem.BindingContextChanged += CurrentItem_BindingContextChanged; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         private void CurrentItem_BindingContextChanged(object sender, EventArgs e) | ||||||
|  |         { | ||||||
|  |             Debug.WriteLine(e.ToString()); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         private void CurrentItem_Appearing(object sender, EventArgs e) | ||||||
|  |         { | ||||||
|  |             Debug.WriteLine(e.ToString()); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         private void CurrentItem_PropertyChanged(object sender, PropertyChangedEventArgs e) | ||||||
|  |         { | ||||||
|  |             Debug.WriteLine(e.PropertyName); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         protected bool SetProperty<T>(ref T backingStore, T value, |         protected bool SetProperty<T>(ref T backingStore, T value, | ||||||
|     [CallerMemberName]string propertyName = "", |             [CallerMemberName]string propertyName = "", | ||||||
|     Action onChanged = null) |             Action onChanged = null) | ||||||
|         { |         { | ||||||
|             if (EqualityComparer<T>.Default.Equals(backingStore, value)) |             if (EqualityComparer<T>.Default.Equals(backingStore, value)) | ||||||
|                 return false; |                 return false; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yan Maniez
						Yan Maniez