Skip to content

Commit

Permalink
Code Quality: Bring back WinUIEx (files-community#16227)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x5bfa authored Sep 25, 2024
1 parent 0548373 commit 24e96cc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/Files.App/Files.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls" Version="7.1.2" />
<PackageReference Include="TagLibSharp" Version="2.3.0" />
<PackageReference Include="Tulpep.ActiveDirectoryObjectPicker" Version="3.0.11" />
<PackageReference Include="WinUIEx" Version="2.3.4" />
<PackageReference Include="Vanara.Windows.Extensions" Version="4.0.1" />
<PackageReference Include="Vanara.Windows.Shell" Version="4.0.1" />
<PackageReference Include="Microsoft.Management.Infrastructure" Version="3.0.0" />
Expand Down
3 changes: 2 additions & 1 deletion src/Files.App/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<!-- Copyright (c) 2024 Files Community. Licensed under the MIT License. See the LICENSE. -->
<items:WindowEx
<winuiex:WindowEx
x:Class="Files.App.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:items="using:Files.App.Data.Items"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:winuiex="using:WinUIEx"
mc:Ignorable="d" />
14 changes: 9 additions & 5 deletions src/Files.App/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,20 @@

namespace Files.App
{
public sealed partial class MainWindow : WindowEx
public sealed partial class MainWindow : WinUIEx.WindowEx
{
private static MainWindow? _Instance;
public static MainWindow Instance => _Instance ??= new();

public MainWindow() : base(minWidth: 516, minHeight: 416)
public nint WindowHandle { get; }

public MainWindow()
{
InitializeComponent();

WindowHandle = WinUIEx.WindowExtensions.GetWindowHandle(this);
MinHeight = 416;
MinWidth = 516;
ExtendsContentIntoTitleBar = true;
Title = "Files";
AppWindow.TitleBar.ButtonBackgroundColor = Colors.Transparent;
Expand Down Expand Up @@ -188,9 +193,8 @@ public async Task InitializeApplicationAsync(object activatedEventArgs)
Win32Helper.BringToForegroundEx(new(WindowHandle));
}

if (Windows.Win32.PInvoke.IsIconic(new(WindowHandle)) &&
AppWindow.Presenter is OverlappedPresenter presenter)
presenter.Restore(); // Restore window if minimized
if (Windows.Win32.PInvoke.IsIconic(new(WindowHandle)))
WinUIEx.WindowExtensions.Restore(Instance); // Restore window if minimized
}

private Frame? EnsureWindowIsInitialized()
Expand Down

0 comments on commit 24e96cc

Please sign in to comment.