mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-20 06:47:56 +08:00
Merge remote-tracking branch 'origin/main' into dev/snickler/net8-upgrade
This commit is contained in:
commit
19289ceac2
@ -131,7 +131,10 @@ void ReparentCropAndLockWindow::CropAndLock(HWND windowToCrop, RECT cropRect)
|
|||||||
SetWindowLongPtrW(m_currentTarget, GWL_STYLE, targetStyle);
|
SetWindowLongPtrW(m_currentTarget, GWL_STYLE, targetStyle);
|
||||||
auto x = -cropRect.left;
|
auto x = -cropRect.left;
|
||||||
auto y = -cropRect.top;
|
auto y = -cropRect.top;
|
||||||
winrt::check_bool(SetWindowPos(m_currentTarget, nullptr, x, y, 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED | SWP_NOZORDER));
|
if (0 == SetWindowPos(m_currentTarget, nullptr, x, y, 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED | SWP_NOZORDER))
|
||||||
|
{
|
||||||
|
MessageBoxW(nullptr, L"CropAndLock couldn't properly reparent the target window. It might not handle reparenting well.", L"CropAndLock", MB_ICONERROR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReparentCropAndLockWindow::Hide()
|
void ReparentCropAndLockWindow::Hide()
|
||||||
|
@ -1240,7 +1240,15 @@
|
|||||||
"Name": "WindowsUpdateCheckForUpdates",
|
"Name": "WindowsUpdateCheckForUpdates",
|
||||||
"Areas": [ "AreaUpdateAndSecurity" ],
|
"Areas": [ "AreaUpdateAndSecurity" ],
|
||||||
"Type": "AppSettingsApp",
|
"Type": "AppSettingsApp",
|
||||||
"Command": "ms-settings:windowsupdate-action"
|
"Command": "ms-settings:windowsupdate-action",
|
||||||
|
"DeprecatedInBuild": 22000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "WindowsUpdateCheckForUpdates",
|
||||||
|
"Areas": [ "AreaUpdateAndSecurity" ],
|
||||||
|
"Type": "AppSettingsApp",
|
||||||
|
"Command": "ms-settings:windowsupdate",
|
||||||
|
"IntroducedInBuild": 22000
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "WindowsUpdateAdvancedOptions",
|
"Name": "WindowsUpdateAdvancedOptions",
|
||||||
|
@ -24,7 +24,7 @@ namespace Peek.FilePreviewer.Controls
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private Uri? _navigatedUri;
|
private Uri? _navigatedUri;
|
||||||
|
|
||||||
private Color originalBackgroundColor;
|
private Color? _originalBackgroundColor;
|
||||||
|
|
||||||
public delegate void NavigationCompletedHandler(WebView2? sender, CoreWebView2NavigationCompletedEventArgs? args);
|
public delegate void NavigationCompletedHandler(WebView2? sender, CoreWebView2NavigationCompletedEventArgs? args);
|
||||||
|
|
||||||
@ -52,6 +52,7 @@ namespace Peek.FilePreviewer.Controls
|
|||||||
typeof(BrowserControl),
|
typeof(BrowserControl),
|
||||||
new PropertyMetadata(null, new PropertyChangedCallback((d, e) => ((BrowserControl)d).OnIsDevFilePreviewChanged())));
|
new PropertyMetadata(null, new PropertyChangedCallback((d, e) => ((BrowserControl)d).OnIsDevFilePreviewChanged())));
|
||||||
|
|
||||||
|
// Will actually be true for Markdown files as well.
|
||||||
public bool IsDevFilePreview
|
public bool IsDevFilePreview
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -101,6 +102,11 @@ namespace Peek.FilePreviewer.Controls
|
|||||||
private void SourcePropertyChanged()
|
private void SourcePropertyChanged()
|
||||||
{
|
{
|
||||||
OpenUriDialog.Hide();
|
OpenUriDialog.Hide();
|
||||||
|
|
||||||
|
// Setting the background color to transparent.
|
||||||
|
// This ensures that non-HTML files are displayed with a transparent background.
|
||||||
|
PreviewBrowser.DefaultBackgroundColor = Color.FromArgb(0, 0, 0, 0);
|
||||||
|
|
||||||
Navigate();
|
Navigate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,6 +119,10 @@ namespace Peek.FilePreviewer.Controls
|
|||||||
{
|
{
|
||||||
PreviewBrowser.CoreWebView2.SetVirtualHostNameToFolderMapping(Microsoft.PowerToys.FilePreviewCommon.MonacoHelper.VirtualHostName, Microsoft.PowerToys.FilePreviewCommon.MonacoHelper.MonacoDirectory, CoreWebView2HostResourceAccessKind.Allow);
|
PreviewBrowser.CoreWebView2.SetVirtualHostNameToFolderMapping(Microsoft.PowerToys.FilePreviewCommon.MonacoHelper.VirtualHostName, Microsoft.PowerToys.FilePreviewCommon.MonacoHelper.MonacoDirectory, CoreWebView2HostResourceAccessKind.Allow);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PreviewBrowser.CoreWebView2.ClearVirtualHostNameToFolderMapping(Microsoft.PowerToys.FilePreviewCommon.MonacoHelper.VirtualHostName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +133,10 @@ namespace Peek.FilePreviewer.Controls
|
|||||||
await PreviewBrowser.EnsureCoreWebView2Async();
|
await PreviewBrowser.EnsureCoreWebView2Async();
|
||||||
|
|
||||||
// Storing the original background color so it can be reset later for specific file types like HTML.
|
// Storing the original background color so it can be reset later for specific file types like HTML.
|
||||||
originalBackgroundColor = PreviewBrowser.DefaultBackgroundColor;
|
if (!_originalBackgroundColor.HasValue)
|
||||||
|
{
|
||||||
|
_originalBackgroundColor = PreviewBrowser.DefaultBackgroundColor;
|
||||||
|
}
|
||||||
|
|
||||||
// Setting the background color to transparent when initially loading the WebView2 component.
|
// Setting the background color to transparent when initially loading the WebView2 component.
|
||||||
// This ensures that non-HTML files are displayed with a transparent background.
|
// This ensures that non-HTML files are displayed with a transparent background.
|
||||||
@ -142,6 +155,10 @@ namespace Peek.FilePreviewer.Controls
|
|||||||
{
|
{
|
||||||
PreviewBrowser.CoreWebView2.SetVirtualHostNameToFolderMapping(Microsoft.PowerToys.FilePreviewCommon.MonacoHelper.VirtualHostName, Microsoft.PowerToys.FilePreviewCommon.MonacoHelper.MonacoDirectory, CoreWebView2HostResourceAccessKind.Allow);
|
PreviewBrowser.CoreWebView2.SetVirtualHostNameToFolderMapping(Microsoft.PowerToys.FilePreviewCommon.MonacoHelper.VirtualHostName, Microsoft.PowerToys.FilePreviewCommon.MonacoHelper.MonacoDirectory, CoreWebView2HostResourceAccessKind.Allow);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PreviewBrowser.CoreWebView2.ClearVirtualHostNameToFolderMapping(Microsoft.PowerToys.FilePreviewCommon.MonacoHelper.VirtualHostName);
|
||||||
|
}
|
||||||
|
|
||||||
PreviewBrowser.CoreWebView2.DOMContentLoaded += CoreWebView2_DOMContentLoaded;
|
PreviewBrowser.CoreWebView2.DOMContentLoaded += CoreWebView2_DOMContentLoaded;
|
||||||
PreviewBrowser.CoreWebView2.NewWindowRequested += CoreWebView2_NewWindowRequested;
|
PreviewBrowser.CoreWebView2.NewWindowRequested += CoreWebView2_NewWindowRequested;
|
||||||
@ -158,11 +175,16 @@ namespace Peek.FilePreviewer.Controls
|
|||||||
{
|
{
|
||||||
// If the file being previewed is HTML or HTM, reset the background color to its original state.
|
// If the file being previewed is HTML or HTM, reset the background color to its original state.
|
||||||
// This is done to ensure that HTML and HTM files are displayed as intended, with their own background settings.
|
// This is done to ensure that HTML and HTM files are displayed as intended, with their own background settings.
|
||||||
if (Source?.ToString().EndsWith(".html", StringComparison.OrdinalIgnoreCase) == true ||
|
// This shouldn't be done for dev file previewer.
|
||||||
Source?.ToString().EndsWith(".htm", StringComparison.OrdinalIgnoreCase) == true)
|
if (!IsDevFilePreview &&
|
||||||
|
(Source?.ToString().EndsWith(".html", StringComparison.OrdinalIgnoreCase) == true ||
|
||||||
|
Source?.ToString().EndsWith(".htm", StringComparison.OrdinalIgnoreCase) == true))
|
||||||
{
|
{
|
||||||
// Reset to default behavior for HTML files
|
// Reset to default behavior for HTML files
|
||||||
PreviewBrowser.DefaultBackgroundColor = originalBackgroundColor;
|
if (_originalBackgroundColor.HasValue)
|
||||||
|
{
|
||||||
|
PreviewBrowser.DefaultBackgroundColor = _originalBackgroundColor.Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DOMContentLoaded?.Invoke(sender, args);
|
DOMContentLoaded?.Invoke(sender, args);
|
||||||
|
@ -118,6 +118,8 @@ namespace Peek.FilePreviewer.Previewers
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Simple html file to preview. Shouldn't do things like enabling scripts or using a virtual mapped directory.
|
||||||
|
IsDevFilePreview = false;
|
||||||
Preview = new Uri(File.Path);
|
Preview = new Uri(File.Path);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -210,7 +210,7 @@ namespace Common.Utilities
|
|||||||
|
|
||||||
// max-width and max-height not supported. Extra CSS is needed for it to work.
|
// max-width and max-height not supported. Extra CSS is needed for it to work.
|
||||||
string scaling = $"max-width: {width} ; max-height: {height} ;";
|
string scaling = $"max-width: {width} ; max-height: {height} ;";
|
||||||
scaling += $" _height:expression(this.scrollHeight > {heightR} ? \" {height}\" : \"auto\"); _width:expression(this.scrollWidth > {widthR} ? \"{width}\" : \"auto\");";
|
scaling += $" _height:expression(this.scrollHeight > {heightR} ? " {height}" : "auto"); _width:expression(this.scrollWidth > {widthR} ? "{width}" : "auto");";
|
||||||
|
|
||||||
string newStyle = $"style=\"{scaling}{centering}{oldStyle}\"";
|
string newStyle = $"style=\"{scaling}{centering}{oldStyle}\"";
|
||||||
int insertAt = stringSvgData.IndexOf(">", StringComparison.InvariantCultureIgnoreCase);
|
int insertAt = stringSvgData.IndexOf(">", StringComparison.InvariantCultureIgnoreCase);
|
||||||
|
Loading…
Reference in New Issue
Block a user