mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-30 15:06:06 +00:00
Prepa pdfview uwp
This commit is contained in:
parent
de005f362d
commit
e31e956b98
2 changed files with 50 additions and 0 deletions
|
|
@ -104,6 +104,7 @@
|
|||
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="NativeAPI.cs" />
|
||||
<Compile Include="PdfViewRenderer.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
|||
49
AideDeJeu/AideDeJeu.UWP/PdfViewRenderer.cs
Normal file
49
AideDeJeu/AideDeJeu.UWP/PdfViewRenderer.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
using AideDeJeu.UWP;
|
||||
using AideDeJeu.Views;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Platform.UWP;
|
||||
|
||||
[assembly: ExportRenderer(typeof(PdfView), typeof(PdfViewRenderer))]
|
||||
namespace AideDeJeu.UWP
|
||||
{
|
||||
public class PdfViewRenderer : WebViewRenderer
|
||||
{
|
||||
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
base.OnElementPropertyChanged(sender, e);
|
||||
if (e.PropertyName == "Uri")
|
||||
{
|
||||
var pdfView = Element as PdfView;
|
||||
if (pdfView.Uri != null)
|
||||
{
|
||||
Control.Source = new Uri(
|
||||
string.Format("ms-appx-web:///Assets/pdfjs/web/viewer.html?file={0}", string.Format("file://{0}", WebUtility.UrlEncode(pdfView.Uri))));
|
||||
//string.Format("ms-appx-web:///Assets/Content/{0}", WebUtility.UrlEncode(customWebView.Uri))));
|
||||
//Control.Settings.AllowFileAccess = true;
|
||||
//Control.Settings.AllowFileAccessFromFileURLs = true;
|
||||
//Control.Settings.AllowUniversalAccessFromFileURLs = true;
|
||||
//Control.LoadUrl(string.Format("file:///android_asset/pdfjs/web/viewer.html?file={0}", string.Format("file:///android_asset/Content/{0}", WebUtility.UrlEncode(customWebView.Uri))));
|
||||
//Control.LoadUrl(string.Format("file:///android_asset/pdfjs/web/viewer.html?file={0}", string.Format("file://{0}", WebUtility.UrlEncode(pdfView.Uri))));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
protected override void OnElementChanged(ElementChangedEventArgs<WebView> e)
|
||||
{
|
||||
base.OnElementChanged(e);
|
||||
|
||||
if (e.NewElement != null)
|
||||
{
|
||||
var customWebView = Element as PdfView;
|
||||
Control.Source = new Uri(string.Format("ms-appx-web:///Assets/pdfjs/web/viewer.html?file={0}", string.Format("ms-appx-web:///Assets/Content/{0}", WebUtility.UrlEncode(customWebView.Uri))));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue