Skip to content

Commit d64a4f8

Browse files
yaira2Lamparter
authored andcommitted
Use properties window hwnd
1 parent f83f534 commit d64a4f8

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

src/Files.App/Strings/en-US/Resources.resw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4122,7 +4122,7 @@
41224122
<comment>Appears when two compared hashes match, e.g. "Matches SHA256"</comment>
41234123
</data>
41244124
<data name="HashesDoNotMatch" xml:space="preserve">
4125-
<value>Hashes don't match</value>
4125+
<value>No matches found</value>
41264126
<comment>Appears when two compared hashes don't match</comment>
41274127
</data>
41284128
<data name="PathOrAlias" xml:space="preserve">

src/Files.App/ViewModels/Properties/HashesViewModel.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License.
33

44
using Files.Shared.Helpers;
5+
using Microsoft.UI.Windowing;
56
using Microsoft.UI.Xaml.Controls;
67
using System.IO;
78
using System.Security.Cryptography;
@@ -14,6 +15,8 @@ public sealed partial class HashesViewModel : ObservableObject, IDisposable
1415
private ICommonDialogService CommonDialogService { get; } = Ioc.Default.GetRequiredService<ICommonDialogService>();
1516
private IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetService<IUserSettingsService>()!;
1617

18+
private readonly AppWindow _appWindow;
19+
1720
private HashInfoItem _selectedItem;
1821
public HashInfoItem SelectedItem
1922
{
@@ -62,11 +65,12 @@ public string InfoBarTitle
6265
public bool IsInfoBarOpen
6366
=> !string.IsNullOrEmpty(HashInput);
6467

65-
public HashesViewModel(ListedItem item)
68+
public HashesViewModel(ListedItem item, AppWindow appWindow)
6669
{
6770
ToggleIsEnabledCommand = new RelayCommand<string>(ToggleIsEnabled);
6871

6972
_item = item;
73+
_appWindow = appWindow;
7074
_cancellationTokenSource = new();
7175

7276
Hashes =
@@ -189,8 +193,10 @@ private void OnHashInputTextChanged()
189193

190194
private async Task OnCompareFileAsync()
191195
{
196+
var hWnd = Microsoft.UI.Win32Interop.GetWindowFromWindowId(_appWindow.Id);
197+
192198
var result = CommonDialogService.Open_FileOpenDialog(
193-
MainWindow.Instance.WindowHandle,
199+
hWnd,
194200
false,
195201
[],
196202
Environment.SpecialFolder.Desktop,

src/Files.App/Views/Properties/HashesPage.xaml.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
// Copyright (c) Files Community
22
// Licensed under the MIT License.
33

4-
using Files.App.Data.Parameters;
5-
using Files.App.Utils;
64
using Files.App.ViewModels.Properties;
75
using Microsoft.UI.Xaml;
86
using Microsoft.UI.Xaml.Controls;
97
using Microsoft.UI.Xaml.Controls.Primitives;
108
using Microsoft.UI.Xaml.Navigation;
11-
using System.Threading.Tasks;
129

1310
namespace Files.App.Views.Properties
1411
{
@@ -25,9 +22,10 @@ public HashesPage()
2522

2623
protected override void OnNavigatedTo(NavigationEventArgs e)
2724
{
28-
var np = (PropertiesPageNavigationParameter)e.Parameter;
29-
if (np.Parameter is ListedItem listedItem)
30-
HashesViewModel = new(listedItem);
25+
var parameter = (PropertiesPageNavigationParameter)e.Parameter;
26+
27+
if (parameter.Parameter is ListedItem listedItem)
28+
HashesViewModel = new(listedItem, parameter.Window.AppWindow);
3129

3230
base.OnNavigatedTo(e);
3331
}

0 commit comments

Comments
 (0)