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;
|
if(SelectedRomSet == null) return;
|
||||||
|
|
||||||
var dlgSave = new SaveFileDialog
|
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||||
{
|
{
|
||||||
InitialFileName = SelectedRomSet.Filename
|
SuggestedFileName = SelectedRomSet.Filename,
|
||||||
};
|
SuggestedStartLocation = await _view.StorageProvider.TryGetWellKnownFolderAsync(WellKnownFolder.Documents)
|
||||||
|
});
|
||||||
string result = await dlgSave.ShowAsync(_view);
|
|
||||||
|
|
||||||
if(result == null) return;
|
if(result == null) return;
|
||||||
|
|
||||||
var dialog = new ExportDat();
|
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.DataContext = viewModel;
|
||||||
_ = dialog.ShowDialog(_view);
|
_ = dialog.ShowDialog(_view);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Platform.Storage;
|
using Avalonia.Platform.Storage;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
@@ -216,16 +215,17 @@ public sealed class SettingsViewModel : ViewModelBase
|
|||||||
|
|
||||||
async Task ExecuteDatabaseCommandAsync()
|
async Task ExecuteDatabaseCommandAsync()
|
||||||
{
|
{
|
||||||
var dlgFile = new SaveFileDialog
|
IStorageFile resultFile = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||||
{
|
{
|
||||||
InitialFileName = "romrepo.db",
|
SuggestedFileName = "romrepo.db",
|
||||||
Directory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
|
SuggestedStartLocation = await _view.StorageProvider.TryGetWellKnownFolderAsync(WellKnownFolder.Documents),
|
||||||
Title = Localization.ChooseDatabaseFile
|
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))
|
if(File.Exists(result))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user