mirror of
https://github.com/claunia/romrepomgr.git
synced 2025-12-16 19:24:51 +00:00
[Refactor] Replace SaveFileDialog with StorageProvider for file saving
This commit is contained in:
@@ -275,17 +275,16 @@ public class MainWindowViewModel : ViewModelBase
|
||||
{
|
||||
if(SelectedRomSet == null) return;
|
||||
|
||||
var dlgSave = new SaveFileDialog
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
InitialFileName = SelectedRomSet.Filename
|
||||
};
|
||||
|
||||
string result = await dlgSave.ShowAsync(_view);
|
||||
SuggestedFileName = SelectedRomSet.Filename,
|
||||
SuggestedStartLocation = await _view.StorageProvider.TryGetWellKnownFolderAsync(WellKnownFolder.Documents)
|
||||
});
|
||||
|
||||
if(result == null) return;
|
||||
|
||||
var dialog = new ExportDat();
|
||||
var viewModel = new ExportDatViewModel(dialog, SelectedRomSet.Sha384, result);
|
||||
var viewModel = new ExportDatViewModel(dialog, SelectedRomSet.Sha384, result.Path.LocalPath);
|
||||
dialog.DataContext = viewModel;
|
||||
_ = dialog.ShowDialog(_view);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reactive;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Avalonia.Threading;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -216,16 +215,17 @@ public sealed class SettingsViewModel : ViewModelBase
|
||||
|
||||
async Task ExecuteDatabaseCommandAsync()
|
||||
{
|
||||
var dlgFile = new SaveFileDialog
|
||||
IStorageFile resultFile = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
InitialFileName = "romrepo.db",
|
||||
Directory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
|
||||
Title = Localization.ChooseDatabaseFile
|
||||
};
|
||||
SuggestedFileName = "romrepo.db",
|
||||
SuggestedStartLocation = await _view.StorageProvider.TryGetWellKnownFolderAsync(WellKnownFolder.Documents),
|
||||
Title = Localization.ChooseDatabaseFile,
|
||||
ShowOverwritePrompt = true
|
||||
});
|
||||
|
||||
string result = await dlgFile.ShowAsync(_view);
|
||||
if(resultFile == null) return;
|
||||
|
||||
if(result == null) return;
|
||||
string result = resultFile.Path.LocalPath;
|
||||
|
||||
if(File.Exists(result))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user