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 NewStoreDialog : Window
|
|
{
|
|
/// <summary>
|
|
/// Gets the view model for this dialog.
|
|
/// </summary>
|
|
public NewStoreDialogViewModel ViewModel => (NewStoreDialogViewModel)DataContext!;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the NewStoreDialog.
|
|
/// </summary>
|
|
public NewStoreDialog()
|
|
{
|
|
InitializeComponent();
|
|
DataContext = new NewStoreDialogViewModel();
|
|
Loaded += NewStoreDialog_Loaded;
|
|
}
|
|
|
|
private void NewStoreDialog_Loaded(object? sender, RoutedEventArgs e)
|
|
{
|
|
ViewModel.OnShowSaveFileDialog += ShowSaveFileDialogAsync;
|
|
}
|
|
|
|
private async Task<string?> ShowSaveFileDialogAsync(string title, string fileTypeName, string pattern, string defaultExtension)
|
|
{
|
|
var file = await StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
|
{
|
|
Title = title,
|
|
DefaultExtension = defaultExtension,
|
|
FileTypeChoices = new[]
|
|
{
|
|
new FilePickerFileType(fileTypeName) { Patterns = new[] { pattern } },
|
|
new FilePickerFileType(FileExtensions.AllFilesTypeName) { Patterns = new[] { FileExtensions.AllFilesPattern } }
|
|
}
|
|
});
|
|
|
|
return file?.Path.LocalPath;
|
|
}
|
|
|
|
private async void CreateButton_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);
|
|
}
|
|
}
|