-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7544845
commit 7e9109d
Showing
4 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/RolandK.AvaloniaExtensions/ViewServices/FileDialogs/OpenDirectoryDialogService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System.Web; | ||
using Avalonia.Controls; | ||
using Avalonia.Platform.Storage; | ||
using RolandK.AvaloniaExtensions.ViewServices.Base; | ||
|
||
namespace RolandK.AvaloniaExtensions.ViewServices.FileDialogs; | ||
|
||
public class OpenDirectoryDialogService : ViewServiceBase, IOpenDirectoryViewService | ||
{ | ||
private Window _parent; | ||
|
||
public OpenDirectoryDialogService(Window parent) | ||
{ | ||
_parent = parent; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public async Task<string?> ShowOpenDirectoryDialogAsync(string title) | ||
{ | ||
var options = new FolderPickerOpenOptions(); | ||
options.AllowMultiple = false; | ||
options.Title = title; | ||
|
||
var selectedFolders = await _parent.StorageProvider.OpenFolderPickerAsync(options); | ||
if ((selectedFolders == null) || | ||
(selectedFolders.Count == 0)) | ||
{ | ||
return null; | ||
} | ||
|
||
return HttpUtility.UrlDecode(selectedFolders[0].Path.AbsolutePath); | ||
} | ||
} |