mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-10-30 23:16:09 +00:00 
			
		
		
		
	Cool
This commit is contained in:
		
							parent
							
								
									e8d2d62287
								
							
						
					
					
						commit
						78427093e4
					
				
					 3 changed files with 25 additions and 18 deletions
				
			
		|  | @ -195,29 +195,16 @@ namespace AideDeJeu.Droid | ||||||
|         //    return Task.CompletedTask; |         //    return Task.CompletedTask; | ||||||
|         //} |         //} | ||||||
| 
 | 
 | ||||||
|  |         // https://www.syncfusion.com/kb/8707/how-to-share-the-pdf-document-in-xamarin-forms-platform | ||||||
|         public async Task LaunchFileAsync(string title, string message, string filePath) |         public async Task LaunchFileAsync(string title, string message, string filePath) | ||||||
|         { |         { | ||||||
|             var context = Android.App.Application.Context; |             var context = Android.App.Application.Context; | ||||||
|             var uri = Android.Support.V4.Content.FileProvider.GetUriForFile(context, context.PackageName + ".fileprovider", new Java.IO.File(filePath)); |             var uri = Android.Support.V4.Content.FileProvider.GetUriForFile(context, context.PackageName + ".fileprovider", new Java.IO.File(filePath)); | ||||||
|             //var uri = Android.Net.Uri.Parse("file://" + filePath); |             //var uri = Android.Net.Uri.Parse("file://" + filePath); | ||||||
|             var contentType = "application/pdf"; |  | ||||||
|             var intent = new Intent(Intent.ActionView); |             var intent = new Intent(Intent.ActionView); | ||||||
|             /*intent.PutExtra(Intent.ExtraStream, uri); |  | ||||||
|             intent.PutExtra(Intent.ExtraText, string.Empty); |  | ||||||
|             intent.PutExtra(Intent.ExtraSubject, message ?? string.Empty); |  | ||||||
|             intent.SetType(contentType); |  | ||||||
|             var chooserIntent = Intent.CreateChooser(intent, title ?? string.Empty); |  | ||||||
|             //chooserIntent.SetDataAndType(uri, "application/pdf"); |  | ||||||
|             chooserIntent.SetFlags(ActivityFlags.ClearTop); |  | ||||||
|             chooserIntent.SetFlags(ActivityFlags.NewTask); |  | ||||||
|             chooserIntent.AddFlags(ActivityFlags.GrantReadUriPermission); |  | ||||||
|             chooserIntent.AddFlags(ActivityFlags.GrantWriteUriPermission); |  | ||||||
|             context.StartActivity(chooserIntent); |  | ||||||
|             */ |  | ||||||
|             intent.SetDataAndType(uri, "application/pdf"); |             intent.SetDataAndType(uri, "application/pdf"); | ||||||
|             intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.GrantReadUriPermission); |             intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.GrantReadUriPermission); | ||||||
|             context.StartActivity(intent); |             context.StartActivity(intent); | ||||||
|             //return Task.FromResult(true); |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -894,8 +894,8 @@ namespace AideDeJeu.ViewModels.PlayerCharacter | ||||||
|             Wisdom = PickAbility(random, ref mins, ref maxs, "Sagesse"); |             Wisdom = PickAbility(random, ref mins, ref maxs, "Sagesse"); | ||||||
|             Charisma = PickAbility(random, ref mins, ref maxs, "Charisme"); |             Charisma = PickAbility(random, ref mins, ref maxs, "Charisme"); | ||||||
| 
 | 
 | ||||||
|             await GeneratePdfAsync(); |             //await GeneratePdfAsync(); | ||||||
|             await OpenPdfAsync(); |             //await OpenPdfAsync(); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         public BaseFont findFontInForm(PdfReader reader, PdfName fontname) |         public BaseFont findFontInForm(PdfReader reader, PdfName fontname) | ||||||
|  | @ -1093,8 +1093,8 @@ namespace AideDeJeu.ViewModels.PlayerCharacter | ||||||
|         void DrawText(PdfContentByte cb, string text, iTextSharp.text.Font font, float x, float y, float width, float height, int alignment) |         void DrawText(PdfContentByte cb, string text, iTextSharp.text.Font font, float x, float y, float width, float height, int alignment) | ||||||
|         { |         { | ||||||
|             cb.SetRGBColorFill(127, 127, 127); |             cb.SetRGBColorFill(127, 127, 127); | ||||||
|             cb.Rectangle(x, y, width, height); |             //cb.Rectangle(x, y, width, height); | ||||||
|             cb.Stroke(); |             //cb.Stroke(); | ||||||
|             ColumnText ct = new ColumnText(cb); |             ColumnText ct = new ColumnText(cb); | ||||||
|             ct.SetSimpleColumn(x, y , x + width, y + height); |             ct.SetSimpleColumn(x, y , x + width, y + height); | ||||||
|             var p = new Paragraph(text, font); |             var p = new Paragraph(text, font); | ||||||
|  | @ -1103,6 +1103,22 @@ namespace AideDeJeu.ViewModels.PlayerCharacter | ||||||
|             ct.Go(); |             ct.Go(); | ||||||
| 
 | 
 | ||||||
|         } |         } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |         public ICommand GenerateAndOpenPdfCommand | ||||||
|  |         { | ||||||
|  |             get | ||||||
|  |             { | ||||||
|  |                 return new Command(async () => await ExecuteGenerateAndOpenPdfCommandAsync()); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         async Task ExecuteGenerateAndOpenPdfCommandAsync() | ||||||
|  |         { | ||||||
|  |             await GeneratePdfAsync(); | ||||||
|  |             await OpenPdfAsync(); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         async Task GeneratePdfAsync() |         async Task GeneratePdfAsync() | ||||||
|         { |         { | ||||||
|             //PdfDocument pdfDoc = new PdfDocument(new PdfReader(SRC), new PdfWriter(dest)); |             //PdfDocument pdfDoc = new PdfDocument(new PdfReader(SRC), new PdfWriter(dest)); | ||||||
|  | @ -1253,6 +1269,7 @@ namespace AideDeJeu.ViewModels.PlayerCharacter | ||||||
|             */ |             */ | ||||||
| 
 | 
 | ||||||
|         } |         } | ||||||
|  | 
 | ||||||
|         async Task OpenPdfAsync() |         async Task OpenPdfAsync() | ||||||
|         { |         { | ||||||
|             //DependencyService.Get<INativeAPI>().OpenFileByName("test.pdf"); |             //DependencyService.Get<INativeAPI>().OpenFileByName("test.pdf"); | ||||||
|  |  | ||||||
|  | @ -52,6 +52,9 @@ | ||||||
|             <tools:NullToFalseConverter x:Key="NullToFalseConverter" /> |             <tools:NullToFalseConverter x:Key="NullToFalseConverter" /> | ||||||
|         </ResourceDictionary> |         </ResourceDictionary> | ||||||
|     </TabbedPage.Resources> |     </TabbedPage.Resources> | ||||||
|  |     <TabbedPage.ToolbarItems> | ||||||
|  |         <ToolbarItem Text="Ouvrir en PDF avec..." Command="{Binding GenerateAndOpenPdfCommand}" Order="Secondary" /> | ||||||
|  |     </TabbedPage.ToolbarItems> | ||||||
|     <ContentPage Title="Race"> |     <ContentPage Title="Race"> | ||||||
|         <ScrollView Orientation="Vertical"> |         <ScrollView Orientation="Vertical"> | ||||||
|             <StackLayout> |             <StackLayout> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yan Maniez
						Yan Maniez