1e21e33ade
Move SecureStoreManager project and tests to Deprecated folder and remove from solution. SecureStore functionality is now integrated into ConfigManager.
71 lines
2.2 KiB
C#
71 lines
2.2 KiB
C#
using Avalonia.Controls;
|
|
using Avalonia.Interactivity;
|
|
using Avalonia.Platform.Storage;
|
|
using JdeScoping.SecureStoreManager.Constants;
|
|
using JdeScoping.SecureStoreManager.ViewModels;
|
|
using MsBox.Avalonia;
|
|
using MsBox.Avalonia.Enums;
|
|
|
|
namespace JdeScoping.SecureStoreManager.Views;
|
|
|
|
public partial class OpenStoreDialog : Window
|
|
{
|
|
/// <summary>
|
|
/// Gets the view model for this dialog.
|
|
/// </summary>
|
|
public OpenStoreDialogViewModel ViewModel => (OpenStoreDialogViewModel)DataContext!;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="OpenStoreDialog"/> class.
|
|
/// </summary>
|
|
public OpenStoreDialog()
|
|
{
|
|
InitializeComponent();
|
|
DataContext = new OpenStoreDialogViewModel();
|
|
Loaded += OpenStoreDialog_Loaded;
|
|
}
|
|
|
|
private void OpenStoreDialog_Loaded(object? sender, RoutedEventArgs e)
|
|
{
|
|
ViewModel.OnShowOpenFileDialog += ShowOpenFileDialogAsync;
|
|
}
|
|
|
|
private async Task<string?> ShowOpenFileDialogAsync(string title, string fileTypeName, string pattern)
|
|
{
|
|
var files = await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
|
{
|
|
Title = title,
|
|
AllowMultiple = false,
|
|
FileTypeFilter = new[]
|
|
{
|
|
new FilePickerFileType(fileTypeName) { Patterns = new[] { pattern } },
|
|
new FilePickerFileType(FileExtensions.AllFilesTypeName) { Patterns = new[] { FileExtensions.AllFilesPattern } }
|
|
}
|
|
});
|
|
|
|
return files.Count > 0 ? files[0].Path.LocalPath : null;
|
|
}
|
|
|
|
private async void OpenButton_Click(object? sender, RoutedEventArgs e)
|
|
{
|
|
if (!ViewModel.IsValid)
|
|
{
|
|
var box = MessageBoxManager
|
|
.GetMessageBoxStandard(
|
|
DialogStrings.ValidationErrorTitle,
|
|
ViewModel.ValidationError ?? DialogStrings.DefaultValidationError,
|
|
ButtonEnum.Ok,
|
|
MsBox.Avalonia.Enums.Icon.Warning);
|
|
await box.ShowWindowDialogAsync(this);
|
|
return;
|
|
}
|
|
|
|
Close(true);
|
|
}
|
|
|
|
private void CancelButton_Click(object? sender, RoutedEventArgs e)
|
|
{
|
|
Close(false);
|
|
}
|
|
}
|