Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Quality: Removed Vanara from shell preview handler #15911

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/Files.App.CsWin32/NativeMethods.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,25 @@ IFileOperation
IShellItem2
PSGetPropertyKeyFromName
ShellExecuteEx
E_FAIL
S_OK
S_FALSE
MSG
E_NOTIMPL
LOGFONTW
AssocCreate
IQueryAssociations
UnregisterClass
SetWindowLong
GetModuleHandle
RegisterClassEx
CREATESTRUCTW
AssocQueryString
IPreviewHandlerFrame
IPreviewHandlerVisuals
IObjectWithSite
IInitializeWithStream
IInitializeWithStreamNative
IInitializeWithFile
IInitializeWithItem
SHCreateStreamOnFileEx
22 changes: 15 additions & 7 deletions src/Files.App/UserControls/FilePreviews/ShellPreview.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.App.ViewModels.Previews;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Vanara.PInvoke;
using Windows.Foundation;
using Windows.Win32.Foundation;

namespace Files.App.UserControls.FilePreviews
{
Expand All @@ -13,13 +16,15 @@ public sealed partial class ShellPreview : UserControl
public ShellPreview(ShellPreviewViewModel model)
{
ViewModel = model;
this.InitializeComponent();

InitializeComponent();
}

private void PreviewHost_Loaded(object sender, RoutedEventArgs e)
{
ViewModel.LoadPreview(contentPresenter);
ViewModel.SizeChanged(GetPreviewSize());

if (XamlRoot.Content is FrameworkElement element)
{
element.SizeChanged += PreviewHost_SizeChanged;
Expand All @@ -38,11 +43,13 @@ private RECT GetPreviewSize()
var physicalSize = contentPresenter.RenderSize;
var physicalPos = source.TransformPoint(new Point(0, 0));
var scale = XamlRoot.RasterizationScale;
var result = new RECT();
result.Left = (int)(physicalPos.X * scale + 0.5);
result.Top = (int)(physicalPos.Y * scale + 0.5);
result.Width = (int)(physicalSize.Width * scale + 0.5);
result.Height = (int)(physicalSize.Height * scale + 0.5);

var result = RECT.FromXYWH(
(int)(physicalPos.X * scale + 0.5),
(int)(physicalPos.Y * scale + 0.5),
(int)(physicalSize.Width * scale + 0.5),
(int)(physicalSize.Height * scale + 0.5));

return result;
}

Expand All @@ -53,6 +60,7 @@ private void PreviewHost_Unloaded(object sender, RoutedEventArgs e)
element.SizeChanged -= PreviewHost_SizeChanged;
element.PointerEntered -= PreviewHost_PointerEntered;
}

ViewModel.UnloadPreview();
}

Expand Down
37 changes: 0 additions & 37 deletions src/Files.App/Utils/Shell/ItemStreamHelper.cs

This file was deleted.

Loading