Skip to content

Commit 2d2e891

Browse files
committed
Code Quality: Removed Vanara.PInvokeVanara.PInvoke.RECT import
1 parent 7c0197a commit 2d2e891

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/Files.App/UserControls/FilePreviews/ShellPreview.xaml.cs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Files.App.ViewModels.Previews;
22
using Microsoft.UI.Xaml;
33
using Microsoft.UI.Xaml.Controls;
4-
using Vanara.PInvoke;
54
using Windows.Foundation;
65

76
namespace Files.App.UserControls.FilePreviews
@@ -32,15 +31,15 @@ private void PreviewHost_SizeChanged(object sender, SizeChangedEventArgs e)
3231
ViewModel.SizeChanged(GetPreviewSize());
3332
}
3433

35-
private RECT GetPreviewSize()
34+
private Rect GetPreviewSize()
3635
{
3736
var source = contentPresenter.TransformToVisual(XamlRoot.Content);
3837
var physicalSize = contentPresenter.RenderSize;
3938
var physicalPos = source.TransformPoint(new Point(0, 0));
4039
var scale = XamlRoot.RasterizationScale;
41-
var result = new RECT();
42-
result.Left = (int)(physicalPos.X * scale + 0.5);
43-
result.Top = (int)(physicalPos.Y * scale + 0.5);
40+
var result = new Rect();
41+
result.X = (int)(physicalPos.X * scale + 0.5);
42+
result.Y = (int)(physicalPos.Y * scale + 0.5);
4443
result.Width = (int)(physicalSize.Width * scale + 0.5);
4544
result.Height = (int)(physicalSize.Height * scale + 0.5);
4645
return result;

src/Files.App/ViewModels/UserControls/Previews/ShellPreviewViewModel.cs

+7-4
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,18 @@ public async override Task<List<FileProperty>> LoadPreviewAndDetailsAsync()
7777
}
7878
}
7979

80-
public void SizeChanged(RECT size)
80+
public void SizeChanged(Windows.Foundation.Rect size)
8181
{
82+
var width = (int)size.Width;
83+
var height = (int)size.Height;
84+
8285
if (hwnd != HWND.NULL)
83-
SetWindowPos(hwnd, HWND.HWND_TOP, size.Left, size.Top, size.Width, size.Height, SetWindowPosFlags.SWP_NOACTIVATE);
86+
SetWindowPos(hwnd, HWND.HWND_TOP, (int)size.Left, (int)size.Top, width, height, SetWindowPosFlags.SWP_NOACTIVATE);
8487

85-
currentHandler?.ResetBounds(new(0, 0, size.Width, size.Height));
88+
currentHandler?.ResetBounds(new(0, 0, width, height));
8689

8790
if (outputLink is not null)
88-
outputLink.PlacementVisual.Size = new(size.Width, size.Height);
91+
outputLink.PlacementVisual.Size = new(width, height);
8992
}
9093

9194
private nint WndProc(HWND hwnd, uint msg, nint wParam, nint lParam)

0 commit comments

Comments
 (0)