Skip to content

Commit 24e96cc

Browse files
authored
Code Quality: Bring back WinUIEx (#16227)
1 parent 0548373 commit 24e96cc

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/Files.App/Files.App.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls" Version="7.1.2" />
8686
<PackageReference Include="TagLibSharp" Version="2.3.0" />
8787
<PackageReference Include="Tulpep.ActiveDirectoryObjectPicker" Version="3.0.11" />
88+
<PackageReference Include="WinUIEx" Version="2.3.4" />
8889
<PackageReference Include="Vanara.Windows.Extensions" Version="4.0.1" />
8990
<PackageReference Include="Vanara.Windows.Shell" Version="4.0.1" />
9091
<PackageReference Include="Microsoft.Management.Infrastructure" Version="3.0.0" />

src/Files.App/MainWindow.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<!-- Copyright (c) 2024 Files Community. Licensed under the MIT License. See the LICENSE. -->
2-
<items:WindowEx
2+
<winuiex:WindowEx
33
x:Class="Files.App.MainWindow"
44
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
55
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
66
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
77
xmlns:items="using:Files.App.Data.Items"
88
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
xmlns:winuiex="using:WinUIEx"
910
mc:Ignorable="d" />

src/Files.App/MainWindow.xaml.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,20 @@
1313

1414
namespace Files.App
1515
{
16-
public sealed partial class MainWindow : WindowEx
16+
public sealed partial class MainWindow : WinUIEx.WindowEx
1717
{
1818
private static MainWindow? _Instance;
1919
public static MainWindow Instance => _Instance ??= new();
2020

21-
public MainWindow() : base(minWidth: 516, minHeight: 416)
21+
public nint WindowHandle { get; }
22+
23+
public MainWindow()
2224
{
2325
InitializeComponent();
2426

27+
WindowHandle = WinUIEx.WindowExtensions.GetWindowHandle(this);
28+
MinHeight = 416;
29+
MinWidth = 516;
2530
ExtendsContentIntoTitleBar = true;
2631
Title = "Files";
2732
AppWindow.TitleBar.ButtonBackgroundColor = Colors.Transparent;
@@ -188,9 +193,8 @@ public async Task InitializeApplicationAsync(object activatedEventArgs)
188193
Win32Helper.BringToForegroundEx(new(WindowHandle));
189194
}
190195

191-
if (Windows.Win32.PInvoke.IsIconic(new(WindowHandle)) &&
192-
AppWindow.Presenter is OverlappedPresenter presenter)
193-
presenter.Restore(); // Restore window if minimized
196+
if (Windows.Win32.PInvoke.IsIconic(new(WindowHandle)))
197+
WinUIEx.WindowExtensions.Restore(Instance); // Restore window if minimized
194198
}
195199

196200
private Frame? EnsureWindowIsInitialized()

0 commit comments

Comments
 (0)