Use TempPath for WebView
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user