From 5675539b37f8746c6bcbec789672d31dfcb91918 Mon Sep 17 00:00:00 2001 From: dosymep Date: Tue, 14 Oct 2025 11:37:17 +0300 Subject: [PATCH 1/2] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=D0=B0=D1=87=D1=83=20=D1=80?= =?UTF-8?q?=D0=BE=D0=B4=D0=B8=D1=82=D0=B5=D0=BB=D1=8C=D1=81=D0=BA=D0=BE?= =?UTF-8?q?=D0=B3=D0=BE=20=D0=BE=D0=BA=D0=BD=D0=B0=20=D0=B2=20=D0=B4=D0=B8?= =?UTF-8?q?=D0=B0=D0=BB=D0=BE=D0=B3=D0=B8=20=D0=B2=D1=8B=D0=B1=D0=BE=D1=80?= =?UTF-8?q?=D0=B0=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2=20=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=B0=D0=BF=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SimpleServices/WpfOpenFileDialogService.cs | 8 ++++---- .../SimpleServices/WpfOpenFolderDialogService.cs | 7 ++++++- .../SimpleServices/WpfSaveFileDialogService.cs | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/dosymep.WpfCore/SimpleServices/WpfOpenFileDialogService.cs b/src/dosymep.WpfCore/SimpleServices/WpfOpenFileDialogService.cs index e184896..09e127e 100644 --- a/src/dosymep.WpfCore/SimpleServices/WpfOpenFileDialogService.cs +++ b/src/dosymep.WpfCore/SimpleServices/WpfOpenFileDialogService.cs @@ -77,18 +77,18 @@ public bool ShowDialog(string directoryName) { FilterIndex = FilterIndex, Title = Title ?? string.Empty, Filter = Filter ?? string.Empty, - InitialDirectory = directoryName + InitialDirectory = directoryName, }; - bool? result = dialog.ShowDialog(); - if(result==true) { + bool? result = dialog.ShowDialog(GetAssociatedWindow()); + if(result == true) { File = new FileInfo(dialog.SafeFileName); Files = dialog.SafeFileNames.Select(item => new FileInfo(item)).ToArray(); } else { File = null; Files = null; } - + return result == true; } diff --git a/src/dosymep.WpfCore/SimpleServices/WpfOpenFolderDialogService.cs b/src/dosymep.WpfCore/SimpleServices/WpfOpenFolderDialogService.cs index ec3ac66..852af42 100644 --- a/src/dosymep.WpfCore/SimpleServices/WpfOpenFolderDialogService.cs +++ b/src/dosymep.WpfCore/SimpleServices/WpfOpenFolderDialogService.cs @@ -1,4 +1,6 @@ +using System.Diagnostics; using System.IO; +using System.Windows; using dosymep.SimpleServices; @@ -76,7 +78,10 @@ public bool ShowDialog(string directoryName) { dialog.Title = Title ?? string.Empty; dialog.InitialDirectory = directoryName; - CommonFileDialogResult? result = dialog.ShowDialog(); + Window? associatedWindow = GetAssociatedWindow(); + CommonFileDialogResult? result = associatedWindow is null + ? dialog.ShowDialog(associatedWindow) + : dialog.ShowDialog(Process.GetCurrentProcess().MainWindowHandle); if(result == CommonFileDialogResult.Ok) { Folder = new DirectoryInfo(dialog.FileName); diff --git a/src/dosymep.WpfCore/SimpleServices/WpfSaveFileDialogService.cs b/src/dosymep.WpfCore/SimpleServices/WpfSaveFileDialogService.cs index c2ac462..4c095df 100644 --- a/src/dosymep.WpfCore/SimpleServices/WpfSaveFileDialogService.cs +++ b/src/dosymep.WpfCore/SimpleServices/WpfSaveFileDialogService.cs @@ -76,7 +76,7 @@ public bool ShowDialog(string? directoryName, string? fileName) { FileName = fileName ?? DefaultFileName ?? string.Empty }; - bool? result = dialog.ShowDialog(); + bool? result = dialog.ShowDialog(GetAssociatedWindow()); if(result == true) { File = new FileInfo(dialog.SafeFileName); } else { From ed1af1c19471cf795d30d7253d5b5560de3cac82 Mon Sep 17 00:00:00 2001 From: dosymep Date: Tue, 14 Oct 2025 11:41:11 +0300 Subject: [PATCH 2/2] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D1=83=20=D0=B2=20=D1=83?= =?UTF-8?q?=D1=81=D0=BB=D0=BE=D0=B2=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SimpleServices/WpfOpenFolderDialogService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dosymep.WpfCore/SimpleServices/WpfOpenFolderDialogService.cs b/src/dosymep.WpfCore/SimpleServices/WpfOpenFolderDialogService.cs index 852af42..6ce9670 100644 --- a/src/dosymep.WpfCore/SimpleServices/WpfOpenFolderDialogService.cs +++ b/src/dosymep.WpfCore/SimpleServices/WpfOpenFolderDialogService.cs @@ -79,7 +79,7 @@ public bool ShowDialog(string directoryName) { dialog.InitialDirectory = directoryName; Window? associatedWindow = GetAssociatedWindow(); - CommonFileDialogResult? result = associatedWindow is null + CommonFileDialogResult? result = associatedWindow is not null ? dialog.ShowDialog(associatedWindow) : dialog.ShowDialog(Process.GetCurrentProcess().MainWindowHandle);