Use TempPath for WebView

This commit is contained in:
2023-08-10 12:57:00 +02:00
parent e1630e9919
commit 8290b57cd4
3 changed files with 15 additions and 3 deletions

View File

@ -6,11 +6,21 @@ namespace Elwig.Windows {
public partial class DocumentViewerWindow : Window {
private TempFile? PdfFile = null;
private string? PdfPath = null;
public DocumentViewerWindow(string title, string path) {
InitializeComponent();
Title = $"{title} - {Title}";
WebView.Source = new($"file://{path}#view=FitH");
PdfPath = path;
InitializeWebView();
}
public async void InitializeWebView() {
WebView.CreationProperties = new() {
UserDataFolder = App.TempPath,
};
await WebView.EnsureCoreWebView2Async();
WebView.Source = new($"file://{PdfPath}#view=FitH");
}
public DocumentViewerWindow(string title, TempFile file) : this(title, file.FilePath) {
@ -22,6 +32,7 @@ namespace Elwig.Windows {
WebView.Dispose();
PdfFile?.Dispose();
PdfFile = null;
PdfPath = null;
}
}
}