Replace deprecated file dialogs

This commit is contained in:
Michael Bucari-Tovo 2022-12-16 21:07:22 -07:00
parent 03f44b4e9c
commit 36efbcb812
6 changed files with 105 additions and 73 deletions

View file

@ -5,6 +5,7 @@ using Dinah.Core;
using LibationFileManager;
using System.Collections.Generic;
using ReactiveUI;
using System.Linq;
namespace LibationAvalonia.Controls
{
@ -16,7 +17,6 @@ namespace LibationAvalonia.Controls
public static readonly StyledProperty<string> SubDirectoryProperty =
AvaloniaProperty.Register<DirectorySelectControl, string>(nameof(SubDirectory));
public static readonly StyledProperty<string> DirectoryProperty =
AvaloniaProperty.Register<DirectorySelectControl, string>(nameof(Directory));
@ -90,8 +90,19 @@ namespace LibationAvalonia.Controls
private async void CustomDirBrowseBtn_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
{
OpenFolderDialog ofd = new();
customStates.CustomDir = await ofd.ShowAsync(VisualRoot as Window);
var options = new Avalonia.Platform.Storage.FolderPickerOpenOptions
{
AllowMultiple = false
};
var selectedFolders = await (VisualRoot as Window).StorageProvider.OpenFolderPickerAsync(options);
customStates.CustomDir =
selectedFolders
.SingleOrDefault()?.
TryGetUri(out var uri) is true
? uri.LocalPath
: customStates.CustomDir;
}
private void CheckStates_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
@ -125,7 +136,6 @@ namespace LibationAvalonia.Controls
Directory = customStates.CustomChecked ? selectedDir : System.IO.Path.Combine(selectedDir, SubDirectory);
}
private void DirectoryOrCustomSelectControl_PropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e)
{
if (e.Property.Name == nameof(Directory) && e.OldValue is null)