using System;
using System.Windows;
using Elwig.Helpers;

namespace Elwig.Windows {
    public partial class DocumentViewerWindow : Window {

        private TempFile? PdfFile = null;

        public DocumentViewerWindow(string title, string path) {
            InitializeComponent();
            Title = $"{title} - {Title}";
            WebView.Source = new($"file://{path}#view=FitH");
        }

        public DocumentViewerWindow(string title, TempFile file) : this(title, file.FilePath) {
            PdfFile = file;
        }

        public void OnClosed(object sender, EventArgs evt) {
            WebView.Stop();
            WebView.Dispose();
            PdfFile?.Dispose();
            PdfFile = null;
        }
    }
}