Skip to content

Commit 1a67dc9

Browse files
committed
Init
1 parent d0d6195 commit 1a67dc9

File tree

4 files changed

+247
-107
lines changed

4 files changed

+247
-107
lines changed

src/Files.App/NativeMethods.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,17 @@ DesktopWallpaper
9494
SHCreateShellItemArrayFromIDLists
9595
ILCreateFromPath
9696
CLSIDFromString
97+
E_FAIL
98+
S_OK
99+
S_FALSE
100+
MSG
101+
E_NOTIMPL
102+
LOGFONTW
103+
AssocCreate
104+
IQueryAssociations
105+
UnregisterClass
106+
SetWindowLong
107+
GetModuleHandle
108+
RegisterClassEx
109+
CREATESTRUCTW
110+
AssocQueryString

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
// Copyright (c) 2024 Files Community
2+
// Licensed under the MIT License. See the LICENSE.
3+
14
using Files.App.ViewModels.Previews;
25
using Microsoft.UI.Xaml;
36
using Microsoft.UI.Xaml.Controls;
4-
using Vanara.PInvoke;
57
using Windows.Foundation;
8+
using Windows.Win32.Foundation;
69

710
namespace Files.App.UserControls.FilePreviews
811
{
@@ -13,13 +16,15 @@ public sealed partial class ShellPreview : UserControl
1316
public ShellPreview(ShellPreviewViewModel model)
1417
{
1518
ViewModel = model;
16-
this.InitializeComponent();
19+
20+
InitializeComponent();
1721
}
1822

1923
private void PreviewHost_Loaded(object sender, RoutedEventArgs e)
2024
{
2125
ViewModel.LoadPreview(contentPresenter);
2226
ViewModel.SizeChanged(GetPreviewSize());
27+
2328
if (XamlRoot.Content is FrameworkElement element)
2429
{
2530
element.SizeChanged += PreviewHost_SizeChanged;
@@ -38,11 +43,13 @@ private RECT GetPreviewSize()
3843
var physicalSize = contentPresenter.RenderSize;
3944
var physicalPos = source.TransformPoint(new Point(0, 0));
4045
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);
44-
result.Width = (int)(physicalSize.Width * scale + 0.5);
45-
result.Height = (int)(physicalSize.Height * scale + 0.5);
46+
47+
var result = RECT.FromXYWH(
48+
(int)(physicalPos.X * scale + 0.5),
49+
(int)(physicalPos.Y * scale + 0.5),
50+
(int)(physicalSize.Width * scale + 0.5),
51+
(int)(physicalSize.Height * scale + 0.5));
52+
4653
return result;
4754
}
4855

@@ -53,6 +60,7 @@ private void PreviewHost_Unloaded(object sender, RoutedEventArgs e)
5360
element.SizeChanged -= PreviewHost_SizeChanged;
5461
element.PointerEntered -= PreviewHost_PointerEntered;
5562
}
63+
5664
ViewModel.UnloadPreview();
5765
}
5866

0 commit comments

Comments
 (0)