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: Bring back WinUIEx #16227

Merged
merged 7 commits into from
Sep 25, 2024
Merged
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
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0x5bfa I think we need to add back the persistence id.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omg I missed that, let me make a PR for it shortly.

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