mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-11 17:59:17 +00:00
42 lines
1.0 KiB
C#
42 lines
1.0 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Text;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Threading;
|
|
|
|
namespace QuickLook.Plugin.HtmlViewer
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for UserControl1.xaml
|
|
/// </summary>
|
|
public partial class WebpagePanel : UserControl, IDisposable
|
|
{
|
|
public WebpagePanel()
|
|
{
|
|
InitializeComponent();
|
|
|
|
Helper.SetBrowserFeatureControl();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
browser?.Dispose();
|
|
browser = null;
|
|
}
|
|
|
|
public void Navigate(string path)
|
|
{
|
|
if (Path.IsPathRooted(path))
|
|
path = Helper.FilePathToFileUrl(path);
|
|
|
|
browser.Dispatcher.Invoke(() => { browser.Navigate(path); }, DispatcherPriority.Loaded);
|
|
}
|
|
|
|
public void LoadHtml(string html)
|
|
{
|
|
var s = new MemoryStream(Encoding.UTF8.GetBytes(html ?? ""));
|
|
|
|
browser.Dispatcher.Invoke(() => { browser.Navigate(s); }, DispatcherPriority.Loaded);
|
|
}
|
|
}
|
|
} |