mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-18 05:28:07 +08:00
property changed handle
This commit is contained in:
parent
07c4f683ac
commit
42d570b210
@ -45,7 +45,7 @@ namespace Peek.FilePreviewer.Controls
|
||||
nameof(IsDevFilePreview),
|
||||
typeof(bool),
|
||||
typeof(BrowserControl),
|
||||
new PropertyMetadata(null, new PropertyChangedCallback((d, e) => ((BrowserControl)d).SourcePropertyChanged())));
|
||||
new PropertyMetadata(null, new PropertyChangedCallback((d, e) => ((BrowserControl)d).OnIsDevFilePreviewChanged())));
|
||||
|
||||
public bool IsDevFilePreview
|
||||
{
|
||||
@ -57,15 +57,6 @@ namespace Peek.FilePreviewer.Controls
|
||||
set
|
||||
{
|
||||
SetValue(IsDevFilePreviewProperty, value);
|
||||
|
||||
if (PreviewBrowser.CoreWebView2 != null)
|
||||
{
|
||||
PreviewBrowser.CoreWebView2.Settings.IsScriptEnabled = value;
|
||||
if (value)
|
||||
{
|
||||
PreviewBrowser.CoreWebView2.SetVirtualHostNameToFolderMapping(Microsoft.PowerToys.FilePreviewCommon.MonacoHelper.VirtualHostName, Microsoft.PowerToys.FilePreviewCommon.MonacoHelper.MonacoDirectory, CoreWebView2HostResourceAccessKind.Allow);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,6 +100,18 @@ namespace Peek.FilePreviewer.Controls
|
||||
Navigate();
|
||||
}
|
||||
|
||||
private void OnIsDevFilePreviewChanged()
|
||||
{
|
||||
if (PreviewBrowser.CoreWebView2 != null)
|
||||
{
|
||||
PreviewBrowser.CoreWebView2.Settings.IsScriptEnabled = IsDevFilePreview;
|
||||
if (IsDevFilePreview)
|
||||
{
|
||||
PreviewBrowser.CoreWebView2.SetVirtualHostNameToFolderMapping(Microsoft.PowerToys.FilePreviewCommon.MonacoHelper.VirtualHostName, Microsoft.PowerToys.FilePreviewCommon.MonacoHelper.MonacoDirectory, CoreWebView2HostResourceAccessKind.Allow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void PreviewWV2_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
|
Loading…
Reference in New Issue
Block a user