mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[GUI] Replace file dialogs with file pickers.
This commit is contained in:
82
Aaru.Gui/FilePickerFileTypes.cs
Normal file
82
Aaru.Gui/FilePickerFileTypes.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : FilePickerFileTypes.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : GUI.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Common file types to use with Avalonia file pickers.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2024 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using Aaru.Localization;
|
||||
using Avalonia.Platform.Storage;
|
||||
|
||||
namespace Aaru.Gui;
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary of well known file types.
|
||||
/// </summary>
|
||||
public static class FilePickerFileTypes
|
||||
{
|
||||
public static FilePickerFileType All { get; } = new(UI.Dialog_All_files)
|
||||
{
|
||||
Patterns = ["*.*"],
|
||||
MimeTypes = ["*/*"]
|
||||
};
|
||||
|
||||
public static FilePickerFileType PlainText { get; } = new(UI.Dialog_Text_files)
|
||||
{
|
||||
Patterns = ["*.txt"],
|
||||
AppleUniformTypeIdentifiers = ["public.plain-text"],
|
||||
MimeTypes = ["text/plain"]
|
||||
};
|
||||
|
||||
public static FilePickerFileType Log { get; } = new(UI.Dialog_Log_files)
|
||||
{
|
||||
Patterns = ["*.log"],
|
||||
AppleUniformTypeIdentifiers = ["public.plain-text"],
|
||||
MimeTypes = ["text/plain"]
|
||||
};
|
||||
|
||||
public static FilePickerFileType Binary { get; } = new(UI.Dialog_Binary_files)
|
||||
{
|
||||
Patterns = ["*.bin"],
|
||||
MimeTypes = ["application/octet-stream"]
|
||||
};
|
||||
|
||||
public static FilePickerFileType AaruMetadata { get; } = new(UI.Dialog_Aaru_Metadata)
|
||||
{
|
||||
Patterns = ["*.json"],
|
||||
AppleUniformTypeIdentifiers = ["public.json"],
|
||||
MimeTypes = ["application/json"]
|
||||
};
|
||||
|
||||
public static FilePickerFileType AaruResumeFile { get; } = new(UI.Dialog_Aaru_Resume)
|
||||
{
|
||||
Patterns = ["*.json"],
|
||||
AppleUniformTypeIdentifiers = ["public.json"],
|
||||
MimeTypes = ["application/json"]
|
||||
};
|
||||
}
|
||||
@@ -31,6 +31,7 @@
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Reactive;
|
||||
@@ -39,7 +40,7 @@ using System.Threading.Tasks;
|
||||
using Aaru.CommonTypes.Interop;
|
||||
using Aaru.Console;
|
||||
using Aaru.Localization;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Platform.Storage;
|
||||
using JetBrains.Annotations;
|
||||
using MsBox.Avalonia;
|
||||
using MsBox.Avalonia.Enums;
|
||||
@@ -94,27 +95,19 @@ public sealed class ConsoleViewModel : ViewModelBase
|
||||
|
||||
async Task ExecuteSaveCommand()
|
||||
{
|
||||
var dlgSave = new SaveFileDialog();
|
||||
|
||||
dlgSave.Filters?.Add(new FileDialogFilter
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
"log"
|
||||
}
|
||||
],
|
||||
Name = UI.Dialog_Log_files
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.Log
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgSave.ShowAsync(_view);
|
||||
|
||||
if(result is null) return;
|
||||
|
||||
try
|
||||
{
|
||||
var logFs = new FileStream(result, FileMode.Create, FileAccess.ReadWrite);
|
||||
var logFs = new FileStream(result.Path.AbsolutePath, FileMode.Create, FileAccess.ReadWrite);
|
||||
var logSw = new StreamWriter(logFs);
|
||||
|
||||
logSw.WriteLine(UI.Log_saved_at_0, DateTime.Now);
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reactive;
|
||||
using System.Threading.Tasks;
|
||||
@@ -40,6 +41,7 @@ using Aaru.Gui.ViewModels.Tabs;
|
||||
using Aaru.Gui.Views.Tabs;
|
||||
using Aaru.Localization;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Humanizer;
|
||||
using Humanizer.Localisation;
|
||||
using ReactiveUI;
|
||||
@@ -1018,25 +1020,17 @@ public sealed class DeviceInfoViewModel : ViewModelBase
|
||||
|
||||
async Task ExecuteSaveUsbDescriptorsCommand()
|
||||
{
|
||||
var dlgSaveBinary = new SaveFileDialog();
|
||||
|
||||
dlgSaveBinary.Filters?.Add(new FileDialogFilter
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
"*.bin"
|
||||
}
|
||||
],
|
||||
Name = UI.Dialog_Binary_files
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.Binary
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgSaveBinary.ShowAsync(_view);
|
||||
|
||||
if(result is null) return;
|
||||
|
||||
var saveFs = new FileStream(result, FileMode.Create);
|
||||
var saveFs = new FileStream(result.Path.AbsolutePath, FileMode.Create);
|
||||
saveFs.Write(_devInfo.UsbDescriptors, 0, _devInfo.UsbDescriptors.Length);
|
||||
|
||||
saveFs.Close();
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reactive;
|
||||
using System.Text;
|
||||
@@ -43,6 +44,7 @@ using Aaru.Localization;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Media.Imaging;
|
||||
using Avalonia.Platform;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Humanizer.Bytes;
|
||||
using MsBox.Avalonia;
|
||||
using MsBox.Avalonia.Enums;
|
||||
@@ -388,25 +390,17 @@ public sealed class MediaInfoViewModel : ViewModelBase
|
||||
|
||||
async Task SaveElement(byte[] data)
|
||||
{
|
||||
var dlgSaveBinary = new SaveFileDialog();
|
||||
|
||||
dlgSaveBinary.Filters?.Add(new FileDialogFilter
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
"*.bin"
|
||||
}
|
||||
],
|
||||
Name = UI.Dialog_Binary_files
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.Binary
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgSaveBinary.ShowAsync(_view);
|
||||
|
||||
if(result is null) return;
|
||||
|
||||
var saveFs = new FileStream(result, FileMode.Create);
|
||||
var saveFs = new FileStream(result.Path.AbsolutePath, FileMode.Create);
|
||||
saveFs.Write(data, 0, data.Length);
|
||||
|
||||
saveFs.Close();
|
||||
|
||||
@@ -46,6 +46,7 @@ using Aaru.Core;
|
||||
using Aaru.Gui.Models;
|
||||
using Aaru.Localization;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Platform.Storage;
|
||||
using JetBrains.Annotations;
|
||||
using MsBox.Avalonia;
|
||||
using MsBox.Avalonia.Enums;
|
||||
@@ -141,18 +142,18 @@ public sealed class SubdirectoryViewModel
|
||||
{
|
||||
if(SelectedEntries.Count == 0) return;
|
||||
|
||||
var saveFilesFolderDialog = new OpenFolderDialog
|
||||
{
|
||||
Title = UI.Dialog_Choose_destination_folder
|
||||
};
|
||||
IReadOnlyList<IStorageFolder> result =
|
||||
await _view.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||
{
|
||||
Title = UI.Dialog_Choose_destination_folder,
|
||||
AllowMultiple = false
|
||||
});
|
||||
|
||||
string result = await saveFilesFolderDialog.ShowAsync(_view);
|
||||
|
||||
if(result is null) return;
|
||||
if(result.Count != 1) return;
|
||||
|
||||
Statistics.AddCommand("extract-files");
|
||||
|
||||
string folder = saveFilesFolderDialog.Directory;
|
||||
string folder = result[0].Path.AbsolutePath;
|
||||
|
||||
foreach(FileModel file in SelectedEntries)
|
||||
{
|
||||
|
||||
@@ -30,12 +30,14 @@
|
||||
// Copyright © 2011-2024 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reactive;
|
||||
using System.Threading.Tasks;
|
||||
using Aaru.Decoders.ATA;
|
||||
using Aaru.Localization;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Platform.Storage;
|
||||
using JetBrains.Annotations;
|
||||
using ReactiveUI;
|
||||
|
||||
@@ -112,25 +114,17 @@ public sealed class AtaInfoViewModel : ViewModelBase
|
||||
|
||||
async Task ExecuteSaveAtaBinaryCommand()
|
||||
{
|
||||
var dlgSaveBinary = new SaveFileDialog();
|
||||
|
||||
dlgSaveBinary.Filters?.Add(new FileDialogFilter
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
"*.bin"
|
||||
}
|
||||
],
|
||||
Name = UI.Dialog_Binary_files
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.Binary
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgSaveBinary.ShowAsync(_view);
|
||||
|
||||
if(result is null) return;
|
||||
|
||||
var saveFs = new FileStream(result, FileMode.Create);
|
||||
var saveFs = new FileStream(result.Path.AbsolutePath, FileMode.Create);
|
||||
|
||||
if(_ata != null)
|
||||
saveFs.Write(_ata, 0, _ata.Length);
|
||||
@@ -141,25 +135,17 @@ public sealed class AtaInfoViewModel : ViewModelBase
|
||||
|
||||
async Task ExecuteSaveAtaTextCommand()
|
||||
{
|
||||
var dlgSaveText = new SaveFileDialog();
|
||||
|
||||
dlgSaveText.Filters?.Add(new FileDialogFilter
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
"*.txt"
|
||||
}
|
||||
],
|
||||
Name = UI.Dialog_Text_files
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.PlainText
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgSaveText.ShowAsync(_view);
|
||||
|
||||
if(result is null) return;
|
||||
|
||||
var saveFs = new FileStream(result, FileMode.Create);
|
||||
var saveFs = new FileStream(result.Path.AbsolutePath, FileMode.Create);
|
||||
var saveSw = new StreamWriter(saveFs);
|
||||
await saveSw.WriteAsync(AtaIdentifyText);
|
||||
saveFs.Close();
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
// Copyright © 2011-2024 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reactive;
|
||||
using System.Threading.Tasks;
|
||||
@@ -37,6 +38,7 @@ using Aaru.Decoders.Bluray;
|
||||
using Aaru.Decoders.SCSI.MMC;
|
||||
using Aaru.Localization;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Platform.Storage;
|
||||
using JetBrains.Annotations;
|
||||
using ReactiveUI;
|
||||
|
||||
@@ -174,25 +176,17 @@ public sealed class BlurayInfoViewModel
|
||||
|
||||
async Task SaveElement(byte[] data)
|
||||
{
|
||||
var dlgSaveBinary = new SaveFileDialog();
|
||||
|
||||
dlgSaveBinary.Filters?.Add(new FileDialogFilter
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
"*.bin"
|
||||
}
|
||||
],
|
||||
Name = UI.Dialog_Binary_files
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.Binary
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgSaveBinary.ShowAsync(_view);
|
||||
|
||||
if(result is null) return;
|
||||
|
||||
var saveFs = new FileStream(result, FileMode.Create);
|
||||
var saveFs = new FileStream(result.Path.AbsolutePath, FileMode.Create);
|
||||
saveFs.Write(data, 0, data.Length);
|
||||
|
||||
saveFs.Close();
|
||||
|
||||
@@ -40,6 +40,7 @@ using Aaru.Decoders.SCSI.MMC;
|
||||
using Aaru.Gui.Models;
|
||||
using Aaru.Localization;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Platform.Storage;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Aaru.Gui.ViewModels.Tabs;
|
||||
@@ -149,25 +150,17 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase
|
||||
|
||||
async Task ExecuteSaveCdInformationCommand()
|
||||
{
|
||||
var dlgSaveBinary = new SaveFileDialog();
|
||||
|
||||
dlgSaveBinary.Filters?.Add(new FileDialogFilter
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
"*.bin"
|
||||
}
|
||||
],
|
||||
Name = UI.Dialog_Binary_files
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.Binary
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgSaveBinary.ShowAsync(_view);
|
||||
|
||||
if(result is null) return;
|
||||
|
||||
var saveFs = new FileStream(result, FileMode.Create);
|
||||
var saveFs = new FileStream(result.Path.AbsolutePath, FileMode.Create);
|
||||
saveFs.Write(_compactDiscInformationData, 0, _compactDiscInformationData.Length);
|
||||
|
||||
saveFs.Close();
|
||||
@@ -175,25 +168,17 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase
|
||||
|
||||
async Task ExecuteSaveCdTocCommand()
|
||||
{
|
||||
var dlgSaveBinary = new SaveFileDialog();
|
||||
|
||||
dlgSaveBinary.Filters?.Add(new FileDialogFilter
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
"*.bin"
|
||||
}
|
||||
],
|
||||
Name = UI.Dialog_Binary_files
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.Binary
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgSaveBinary.ShowAsync(_view);
|
||||
|
||||
if(result is null) return;
|
||||
|
||||
var saveFs = new FileStream(result, FileMode.Create);
|
||||
var saveFs = new FileStream(result.Path.AbsolutePath, FileMode.Create);
|
||||
saveFs.Write(_tocData, 0, _tocData.Length);
|
||||
|
||||
saveFs.Close();
|
||||
@@ -201,25 +186,17 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase
|
||||
|
||||
async Task ExecuteSaveCdFullTocCommand()
|
||||
{
|
||||
var dlgSaveBinary = new SaveFileDialog();
|
||||
|
||||
dlgSaveBinary.Filters?.Add(new FileDialogFilter
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
"*.bin"
|
||||
}
|
||||
],
|
||||
Name = UI.Dialog_Binary_files
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.Binary
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgSaveBinary.ShowAsync(_view);
|
||||
|
||||
if(result is null) return;
|
||||
|
||||
var saveFs = new FileStream(result, FileMode.Create);
|
||||
var saveFs = new FileStream(result.Path.AbsolutePath, FileMode.Create);
|
||||
saveFs.Write(_rawTocData, 0, _rawTocData.Length);
|
||||
|
||||
saveFs.Close();
|
||||
@@ -227,25 +204,17 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase
|
||||
|
||||
async Task ExecuteSaveCdSessionCommand()
|
||||
{
|
||||
var dlgSaveBinary = new SaveFileDialog();
|
||||
|
||||
dlgSaveBinary.Filters?.Add(new FileDialogFilter
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
"*.bin"
|
||||
}
|
||||
],
|
||||
Name = UI.Dialog_Binary_files
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.Binary
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgSaveBinary.ShowAsync(_view);
|
||||
|
||||
if(result is null) return;
|
||||
|
||||
var saveFs = new FileStream(result, FileMode.Create);
|
||||
var saveFs = new FileStream(result.Path.AbsolutePath, FileMode.Create);
|
||||
saveFs.Write(_sessionData, 0, _sessionData.Length);
|
||||
|
||||
saveFs.Close();
|
||||
@@ -253,25 +222,17 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase
|
||||
|
||||
async Task ExecuteSaveCdTextCommand()
|
||||
{
|
||||
var dlgSaveBinary = new SaveFileDialog();
|
||||
|
||||
dlgSaveBinary.Filters?.Add(new FileDialogFilter
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
"*.bin"
|
||||
}
|
||||
],
|
||||
Name = UI.Dialog_Binary_files
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.Binary
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgSaveBinary.ShowAsync(_view);
|
||||
|
||||
if(result is null) return;
|
||||
|
||||
var saveFs = new FileStream(result, FileMode.Create);
|
||||
var saveFs = new FileStream(result.Path.AbsolutePath, FileMode.Create);
|
||||
saveFs.Write(_cdTextLeadInData, 0, _cdTextLeadInData.Length);
|
||||
|
||||
saveFs.Close();
|
||||
@@ -279,25 +240,17 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase
|
||||
|
||||
async Task ExecuteSaveCdAtipCommand()
|
||||
{
|
||||
var dlgSaveBinary = new SaveFileDialog();
|
||||
|
||||
dlgSaveBinary.Filters?.Add(new FileDialogFilter
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
"*.bin"
|
||||
}
|
||||
],
|
||||
Name = UI.Dialog_Binary_files
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.Binary
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgSaveBinary.ShowAsync(_view);
|
||||
|
||||
if(result is null) return;
|
||||
|
||||
var saveFs = new FileStream(result, FileMode.Create);
|
||||
var saveFs = new FileStream(result.Path.AbsolutePath, FileMode.Create);
|
||||
saveFs.Write(_atipData, 0, _atipData.Length);
|
||||
|
||||
saveFs.Close();
|
||||
@@ -305,25 +258,17 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase
|
||||
|
||||
async Task ExecuteSaveCdPmaCommand()
|
||||
{
|
||||
var dlgSaveBinary = new SaveFileDialog();
|
||||
|
||||
dlgSaveBinary.Filters?.Add(new FileDialogFilter
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
"*.bin"
|
||||
}
|
||||
],
|
||||
Name = UI.Dialog_Binary_files
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.Binary
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgSaveBinary.ShowAsync(_view);
|
||||
|
||||
if(result is null) return;
|
||||
|
||||
var saveFs = new FileStream(result, FileMode.Create);
|
||||
var saveFs = new FileStream(result.Path.AbsolutePath, FileMode.Create);
|
||||
saveFs.Write(_pmaData, 0, _pmaData.Length);
|
||||
|
||||
saveFs.Close();
|
||||
|
||||
@@ -30,12 +30,14 @@
|
||||
// Copyright © 2011-2024 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reactive;
|
||||
using System.Threading.Tasks;
|
||||
using Aaru.Decoders.DVD;
|
||||
using Aaru.Localization;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Platform.Storage;
|
||||
using JetBrains.Annotations;
|
||||
using ReactiveUI;
|
||||
|
||||
@@ -124,25 +126,17 @@ public sealed class DvdInfoViewModel
|
||||
|
||||
async Task SaveElement(byte[] data)
|
||||
{
|
||||
var dlgSaveBinary = new SaveFileDialog();
|
||||
|
||||
dlgSaveBinary.Filters?.Add(new FileDialogFilter
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
"*.bin"
|
||||
}
|
||||
],
|
||||
Name = UI.Dialog_Binary_files
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.Binary
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgSaveBinary.ShowAsync(_view);
|
||||
|
||||
if(result is null) return;
|
||||
|
||||
var saveFs = new FileStream(result, FileMode.Create);
|
||||
var saveFs = new FileStream(result.Path.AbsolutePath, FileMode.Create);
|
||||
saveFs.Write(data, 0, data.Length);
|
||||
|
||||
saveFs.Close();
|
||||
|
||||
@@ -30,12 +30,14 @@
|
||||
// Copyright © 2011-2024 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reactive;
|
||||
using System.Threading.Tasks;
|
||||
using Aaru.Decoders.DVD;
|
||||
using Aaru.Localization;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Platform.Storage;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Aaru.Gui.ViewModels.Tabs;
|
||||
@@ -250,25 +252,17 @@ public sealed class DvdWritableInfoViewModel
|
||||
|
||||
async Task SaveElement(byte[] data)
|
||||
{
|
||||
var dlgSaveBinary = new SaveFileDialog();
|
||||
|
||||
dlgSaveBinary.Filters?.Add(new FileDialogFilter
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
"*.bin"
|
||||
}
|
||||
],
|
||||
Name = UI.Dialog_Binary_files
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.Binary
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgSaveBinary.ShowAsync(_view);
|
||||
|
||||
if(result is null) return;
|
||||
|
||||
var saveFs = new FileStream(result, FileMode.Create);
|
||||
var saveFs = new FileStream(result.Path.AbsolutePath, FileMode.Create);
|
||||
saveFs.Write(data, 0, data.Length);
|
||||
|
||||
saveFs.Close();
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
// Copyright © 2011-2024 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Reactive;
|
||||
@@ -39,6 +40,7 @@ using Aaru.Decoders.PCMCIA;
|
||||
using Aaru.Gui.Models;
|
||||
using Aaru.Localization;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Platform.Storage;
|
||||
using JetBrains.Annotations;
|
||||
using ReactiveUI;
|
||||
|
||||
@@ -175,25 +177,17 @@ public class PcmciaInfoViewModel : ViewModelBase
|
||||
|
||||
async Task ExecuteSavePcmciaCisCommand()
|
||||
{
|
||||
var dlgSaveBinary = new SaveFileDialog();
|
||||
|
||||
dlgSaveBinary.Filters?.Add(new FileDialogFilter
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
"*.bin"
|
||||
}
|
||||
],
|
||||
Name = UI.Dialog_Binary_files
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.Binary
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgSaveBinary.ShowAsync(_view);
|
||||
|
||||
if(result is null) return;
|
||||
|
||||
var saveFs = new FileStream(result, FileMode.Create);
|
||||
var saveFs = new FileStream(result.Path.AbsolutePath, FileMode.Create);
|
||||
saveFs.Write(_cis, 0, _cis.Length);
|
||||
|
||||
saveFs.Close();
|
||||
|
||||
@@ -44,6 +44,7 @@ using Aaru.Gui.Models;
|
||||
using Aaru.Helpers;
|
||||
using Aaru.Localization;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Platform.Storage;
|
||||
using ReactiveUI;
|
||||
using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry;
|
||||
|
||||
@@ -801,25 +802,17 @@ public sealed class ScsiInfoViewModel : ViewModelBase
|
||||
|
||||
async Task ExecuteSaveInquiryBinaryCommand()
|
||||
{
|
||||
var dlgSaveBinary = new SaveFileDialog();
|
||||
|
||||
dlgSaveBinary.Filters?.Add(new FileDialogFilter
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
"*.bin"
|
||||
}
|
||||
],
|
||||
Name = UI.Dialog_Binary_files
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.Binary
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgSaveBinary.ShowAsync(_view);
|
||||
|
||||
if(result is null) return;
|
||||
|
||||
var saveFs = new FileStream(result, FileMode.Create);
|
||||
var saveFs = new FileStream(result.Path.AbsolutePath, FileMode.Create);
|
||||
saveFs.Write(InquiryData, 0, InquiryData.Length);
|
||||
|
||||
saveFs.Close();
|
||||
@@ -827,25 +820,17 @@ public sealed class ScsiInfoViewModel : ViewModelBase
|
||||
|
||||
async Task ExecuteSaveInquiryTextCommand()
|
||||
{
|
||||
var dlgSaveText = new SaveFileDialog();
|
||||
|
||||
dlgSaveText.Filters?.Add(new FileDialogFilter
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
"*.txt"
|
||||
}
|
||||
],
|
||||
Name = UI.Dialog_Text_files
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.PlainText
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgSaveText.ShowAsync(_view);
|
||||
|
||||
if(result is null) return;
|
||||
|
||||
var saveFs = new FileStream(result, FileMode.Create);
|
||||
var saveFs = new FileStream(result.Path.AbsolutePath, FileMode.Create);
|
||||
var saveSw = new StreamWriter(saveFs);
|
||||
await saveSw.WriteAsync(ScsiInquiryText);
|
||||
saveFs.Close();
|
||||
@@ -853,25 +838,17 @@ public sealed class ScsiInfoViewModel : ViewModelBase
|
||||
|
||||
async Task ExecuteSaveModeSense6Command()
|
||||
{
|
||||
var dlgSaveBinary = new SaveFileDialog();
|
||||
|
||||
dlgSaveBinary.Filters?.Add(new FileDialogFilter
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
"*.bin"
|
||||
}
|
||||
],
|
||||
Name = UI.Dialog_Binary_files
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.Binary
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgSaveBinary.ShowAsync(_view);
|
||||
|
||||
if(result is null) return;
|
||||
|
||||
var saveFs = new FileStream(result, FileMode.Create);
|
||||
var saveFs = new FileStream(result.Path.AbsolutePath, FileMode.Create);
|
||||
saveFs.Write(_scsiModeSense6, 0, _scsiModeSense6.Length);
|
||||
|
||||
saveFs.Close();
|
||||
@@ -879,25 +856,17 @@ public sealed class ScsiInfoViewModel : ViewModelBase
|
||||
|
||||
async Task ExecuteSaveModeSense10Command()
|
||||
{
|
||||
var dlgSaveBinary = new SaveFileDialog();
|
||||
|
||||
dlgSaveBinary.Filters?.Add(new FileDialogFilter
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
"*.bin"
|
||||
}
|
||||
],
|
||||
Name = UI.Dialog_Binary_files
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.Binary
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgSaveBinary.ShowAsync(_view);
|
||||
|
||||
if(result is null) return;
|
||||
|
||||
var saveFs = new FileStream(result, FileMode.Create);
|
||||
var saveFs = new FileStream(result.Path.AbsolutePath, FileMode.Create);
|
||||
saveFs.Write(_scsiModeSense10, 0, _scsiModeSense10.Length);
|
||||
|
||||
saveFs.Close();
|
||||
@@ -907,25 +876,17 @@ public sealed class ScsiInfoViewModel : ViewModelBase
|
||||
{
|
||||
if(SelectedEvpdPage is not ScsiPageModel pageModel) return;
|
||||
|
||||
var dlgSaveBinary = new SaveFileDialog();
|
||||
|
||||
dlgSaveBinary.Filters?.Add(new FileDialogFilter
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
"*.bin"
|
||||
}
|
||||
],
|
||||
Name = UI.Dialog_Binary_files
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.Binary
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgSaveBinary.ShowAsync(_view);
|
||||
|
||||
if(result is null) return;
|
||||
|
||||
var saveFs = new FileStream(result, FileMode.Create);
|
||||
var saveFs = new FileStream(result.Path.AbsolutePath, FileMode.Create);
|
||||
saveFs.Write(pageModel.Data, 0, pageModel.Data.Length);
|
||||
|
||||
saveFs.Close();
|
||||
@@ -933,25 +894,17 @@ public sealed class ScsiInfoViewModel : ViewModelBase
|
||||
|
||||
async Task ExecuteSaveMmcFeaturesCommand()
|
||||
{
|
||||
var dlgSaveBinary = new SaveFileDialog();
|
||||
|
||||
dlgSaveBinary.Filters?.Add(new FileDialogFilter
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
"*.bin"
|
||||
}
|
||||
],
|
||||
Name = UI.Dialog_Binary_files
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.Binary
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgSaveBinary.ShowAsync(_view);
|
||||
|
||||
if(result is null) return;
|
||||
|
||||
var saveFs = new FileStream(result, FileMode.Create);
|
||||
var saveFs = new FileStream(result.Path.AbsolutePath, FileMode.Create);
|
||||
saveFs.Write(_configuration, 0, _configuration.Length);
|
||||
|
||||
saveFs.Close();
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
// Copyright © 2011-2024 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reactive;
|
||||
using System.Threading.Tasks;
|
||||
@@ -37,6 +38,7 @@ using Aaru.Core.Media.Info;
|
||||
using Aaru.Decoders.Xbox;
|
||||
using Aaru.Localization;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Platform.Storage;
|
||||
using JetBrains.Annotations;
|
||||
using ReactiveUI;
|
||||
|
||||
@@ -101,25 +103,17 @@ public sealed class XboxInfoViewModel
|
||||
|
||||
async Task SaveElement(byte[] data)
|
||||
{
|
||||
var dlgSaveBinary = new SaveFileDialog();
|
||||
|
||||
dlgSaveBinary.Filters?.Add(new FileDialogFilter
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
"*.bin"
|
||||
}
|
||||
],
|
||||
Name = UI.Dialog_Binary_files
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.Binary
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgSaveBinary.ShowAsync(_view);
|
||||
|
||||
if(result is null) return;
|
||||
|
||||
var saveFs = new FileStream(result, FileMode.Create);
|
||||
var saveFs = new FileStream(result.Path.AbsolutePath, FileMode.Create);
|
||||
saveFs.Write(data, 0, data.Length);
|
||||
|
||||
saveFs.Close();
|
||||
|
||||
@@ -53,6 +53,7 @@ using Aaru.Devices;
|
||||
using Aaru.Gui.Models;
|
||||
using Aaru.Localization;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Avalonia.Threading;
|
||||
using MsBox.Avalonia;
|
||||
using MsBox.Avalonia.Enums;
|
||||
@@ -2049,29 +2050,29 @@ public sealed class ImageConvertViewModel : ViewModelBase
|
||||
{
|
||||
if(SelectedPlugin is null) return;
|
||||
|
||||
var dlgDestination = new SaveFileDialog
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Title = UI.Dialog_Choose_destination_file
|
||||
};
|
||||
|
||||
dlgDestination.Filters?.Add(new FileDialogFilter
|
||||
{
|
||||
Name = SelectedPlugin.Plugin.Name,
|
||||
Extensions = SelectedPlugin.Plugin.KnownExtensions.ToList()
|
||||
Title = UI.Dialog_Choose_destination_file,
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
new(SelectedPlugin.Plugin.Name)
|
||||
{
|
||||
Patterns = SelectedPlugin.Plugin.KnownExtensions.ToList()
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgDestination.ShowAsync(_view);
|
||||
|
||||
if(result is null || result.Length != 1)
|
||||
if(result is null)
|
||||
{
|
||||
DestinationText = "";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(string.IsNullOrEmpty(Path.GetExtension(result))) result += SelectedPlugin.Plugin.KnownExtensions.First();
|
||||
DestinationText = result.Path.AbsolutePath;
|
||||
|
||||
DestinationText = result;
|
||||
if(string.IsNullOrEmpty(Path.GetExtension(DestinationText)))
|
||||
DestinationText += SelectedPlugin.Plugin.KnownExtensions.First();
|
||||
}
|
||||
|
||||
void ExecuteCreatorCommand() => CreatorText = _inputFormat.Info.Creator;
|
||||
@@ -2113,37 +2114,29 @@ public sealed class ImageConvertViewModel : ViewModelBase
|
||||
_aaruMetadata = null;
|
||||
MetadataJsonText = "";
|
||||
|
||||
var dlgMetadata = new OpenFileDialog
|
||||
{
|
||||
Title = UI.Dialog_Choose_existing_metadata_sidecar
|
||||
};
|
||||
IReadOnlyList<IStorageFile> result = _view.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
Title = UI.Dialog_Choose_existing_metadata_sidecar,
|
||||
AllowMultiple = false,
|
||||
FileTypeFilter = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.AaruMetadata
|
||||
}
|
||||
})
|
||||
.Result;
|
||||
|
||||
dlgMetadata.Filters?.Add(new FileDialogFilter
|
||||
{
|
||||
Name = UI.Dialog_Aaru_Metadata,
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
".json"
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
string[] result = await dlgMetadata.ShowAsync(_view);
|
||||
|
||||
if(result is null || result.Length != 1) return;
|
||||
if(result.Count != 1) return;
|
||||
|
||||
try
|
||||
{
|
||||
var fs = new FileStream(result[0], FileMode.Open);
|
||||
var fs = new FileStream(result[0].Path.AbsolutePath, FileMode.Open);
|
||||
|
||||
_aaruMetadata =
|
||||
(await JsonSerializer.DeserializeAsync(fs, typeof(MetadataJson), MetadataJsonContext.Default) as
|
||||
MetadataJson)?.AaruMetadata;
|
||||
|
||||
fs.Close();
|
||||
MetadataJsonText = result[0];
|
||||
MetadataJsonText = result[0].Path.AbsolutePath;
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -2164,30 +2157,22 @@ public sealed class ImageConvertViewModel : ViewModelBase
|
||||
_dumpHardware = null;
|
||||
ResumeFileText = "";
|
||||
|
||||
var dlgMetadata = new OpenFileDialog
|
||||
{
|
||||
Title = UI.Dialog_Choose_existing_resume_file
|
||||
};
|
||||
IReadOnlyList<IStorageFile> result = _view.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
Title = UI.Dialog_Choose_existing_resume_file,
|
||||
AllowMultiple = false,
|
||||
FileTypeFilter = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.AaruResumeFile
|
||||
}
|
||||
})
|
||||
.Result;
|
||||
|
||||
dlgMetadata.Filters?.Add(new FileDialogFilter
|
||||
{
|
||||
Name = UI.Dialog_Choose_existing_resume_file,
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
".json"
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
string[] result = await dlgMetadata.ShowAsync(_view);
|
||||
|
||||
if(result is null || result.Length != 1) return;
|
||||
if(result.Count != 1) return;
|
||||
|
||||
try
|
||||
{
|
||||
var fs = new FileStream(result[0], FileMode.Open);
|
||||
var fs = new FileStream(result[0].Path.AbsolutePath, FileMode.Open);
|
||||
|
||||
Resume resume =
|
||||
(await JsonSerializer.DeserializeAsync(fs, typeof(ResumeJson), ResumeJsonContext.Default) as ResumeJson)
|
||||
@@ -2198,7 +2183,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
|
||||
if(resume?.Tries?.Any() == false)
|
||||
{
|
||||
_dumpHardware = resume.Tries;
|
||||
ResumeFileText = result[0];
|
||||
ResumeFileText = result[0].Path.AbsolutePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Reactive;
|
||||
@@ -44,6 +45,7 @@ using Aaru.Console;
|
||||
using Aaru.Core;
|
||||
using Aaru.Localization;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Avalonia.Threading;
|
||||
using ReactiveUI;
|
||||
|
||||
@@ -322,25 +324,15 @@ public sealed class ImageSidecarViewModel : ViewModelBase
|
||||
|
||||
async Task ExecuteDestinationCommand()
|
||||
{
|
||||
var dlgDestination = new SaveFileDialog
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Title = UI.Dialog_Choose_destination_file
|
||||
};
|
||||
|
||||
dlgDestination.Filters?.Add(new FileDialogFilter
|
||||
{
|
||||
Name = UI.Dialog_Aaru_Metadata,
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
"*.json"
|
||||
}
|
||||
]
|
||||
Title = UI.Dialog_Choose_destination_file,
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.AaruMetadata
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgDestination.ShowAsync(_view);
|
||||
|
||||
if(result is null)
|
||||
{
|
||||
DestinationText = "";
|
||||
@@ -348,8 +340,7 @@ public sealed class ImageSidecarViewModel : ViewModelBase
|
||||
return;
|
||||
}
|
||||
|
||||
if(string.IsNullOrEmpty(Path.GetExtension(result))) result += ".json";
|
||||
|
||||
DestinationText = result;
|
||||
DestinationText = result.Path.AbsolutePath;
|
||||
if(string.IsNullOrEmpty(Path.GetExtension(DestinationText))) DestinationText += ".json";
|
||||
}
|
||||
}
|
||||
@@ -59,6 +59,7 @@ using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Media.Imaging;
|
||||
using Avalonia.Platform;
|
||||
using Avalonia.Platform.Storage;
|
||||
using JetBrains.Annotations;
|
||||
using MsBox.Avalonia;
|
||||
using MsBox.Avalonia.Enums;
|
||||
@@ -530,17 +531,19 @@ public sealed class MainWindowViewModel : ViewModelBase
|
||||
async Task ExecuteOpenCommand()
|
||||
{
|
||||
// TODO: Extensions
|
||||
var dlgOpenImage = new OpenFileDialog
|
||||
IReadOnlyList<IStorageFile> result = await _view.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
Title = UI.Dialog_Choose_image_to_open,
|
||||
AllowMultiple = false
|
||||
};
|
||||
AllowMultiple = false,
|
||||
FileTypeFilter = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.All
|
||||
}
|
||||
});
|
||||
|
||||
string[] result = await dlgOpenImage.ShowAsync(_view);
|
||||
if(result.Count != 1) return;
|
||||
|
||||
if(result?.Length != 1) return;
|
||||
|
||||
IFilter inputFilter = PluginRegister.Singleton.GetFilter(result[0]);
|
||||
IFilter inputFilter = PluginRegister.Singleton.GetFilter(result[0].Path.AbsolutePath);
|
||||
|
||||
if(inputFilter == null)
|
||||
{
|
||||
@@ -587,7 +590,7 @@ public sealed class MainWindowViewModel : ViewModelBase
|
||||
|
||||
var imageModel = new ImageModel
|
||||
{
|
||||
Path = result[0],
|
||||
Path = result[0].Path.AbsolutePath,
|
||||
Icon = AssetLoader.Exists(mediaResource)
|
||||
? new Bitmap(AssetLoader.Open(mediaResource))
|
||||
: imageFormat.Info.MetadataMediaType == MetadataMediaType.BlockMedia
|
||||
@@ -595,9 +598,9 @@ public sealed class MainWindowViewModel : ViewModelBase
|
||||
: imageFormat.Info.MetadataMediaType == MetadataMediaType.OpticalDisc
|
||||
? _genericOpticalIcon
|
||||
: _genericFolderIcon,
|
||||
FileName = Path.GetFileName(result[0]),
|
||||
FileName = Path.GetFileName(result[0].Path.AbsolutePath),
|
||||
Image = imageFormat,
|
||||
ViewModel = new ImageInfoViewModel(result[0], inputFilter, imageFormat, _view),
|
||||
ViewModel = new ImageInfoViewModel(result[0].Path.AbsolutePath, inputFilter, imageFormat, _view),
|
||||
Filter = inputFilter
|
||||
};
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ using Aaru.Devices;
|
||||
using Aaru.Gui.Models;
|
||||
using Aaru.Localization;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Avalonia.Threading;
|
||||
using DynamicData;
|
||||
using JetBrains.Annotations;
|
||||
@@ -505,26 +506,18 @@ public sealed class MediaDumpViewModel : ViewModelBase
|
||||
return;
|
||||
}
|
||||
|
||||
var dlgMetadata = new OpenFileDialog
|
||||
{
|
||||
Title = UI.Dialog_Choose_existing_metadata_sidecar
|
||||
};
|
||||
IReadOnlyList<IStorageFile> result = _view.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
Title = UI.Dialog_Choose_existing_metadata_sidecar,
|
||||
AllowMultiple = false,
|
||||
FileTypeFilter = new List<FilePickerFileType>
|
||||
{
|
||||
FilePickerFileTypes.AaruMetadata
|
||||
}
|
||||
})
|
||||
.Result;
|
||||
|
||||
dlgMetadata.Filters?.Add(new FileDialogFilter
|
||||
{
|
||||
Name = UI.Dialog_Aaru_Metadata,
|
||||
Extensions =
|
||||
[
|
||||
..new[]
|
||||
{
|
||||
".json"
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
string[] result = dlgMetadata.ShowAsync(_view).Result;
|
||||
|
||||
if(result?.Length != 1)
|
||||
if(result.Count != 1)
|
||||
{
|
||||
ExistingMetadata = false;
|
||||
|
||||
@@ -533,7 +526,7 @@ public sealed class MediaDumpViewModel : ViewModelBase
|
||||
|
||||
try
|
||||
{
|
||||
var fs = new FileStream(result[0], FileMode.Open);
|
||||
var fs = new FileStream(result[0].Path.AbsolutePath, FileMode.Open);
|
||||
|
||||
_sidecar =
|
||||
(JsonSerializer.Deserialize(fs, typeof(MetadataJson), MetadataJsonContext.Default) as MetadataJson)
|
||||
@@ -668,19 +661,18 @@ public sealed class MediaDumpViewModel : ViewModelBase
|
||||
{
|
||||
if(SelectedPlugin is null) return;
|
||||
|
||||
var dlgDestination = new SaveFileDialog
|
||||
IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Title = UI.Dialog_Choose_destination_file
|
||||
};
|
||||
|
||||
dlgDestination.Filters?.Add(new FileDialogFilter
|
||||
{
|
||||
Name = SelectedPlugin.Plugin.Name,
|
||||
Extensions = SelectedPlugin.Plugin.KnownExtensions.ToList()
|
||||
Title = UI.Dialog_Choose_destination_file,
|
||||
FileTypeChoices = new List<FilePickerFileType>
|
||||
{
|
||||
new(SelectedPlugin.Plugin.Name)
|
||||
{
|
||||
Patterns = SelectedPlugin.Plugin.KnownExtensions.ToList()
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
string result = await dlgDestination.ShowAsync(_view);
|
||||
|
||||
if(result is null)
|
||||
{
|
||||
Destination = "";
|
||||
@@ -689,11 +681,13 @@ public sealed class MediaDumpViewModel : ViewModelBase
|
||||
return;
|
||||
}
|
||||
|
||||
if(string.IsNullOrEmpty(Path.GetExtension(result))) result += SelectedPlugin.Plugin.KnownExtensions.First();
|
||||
Destination = result.Path.AbsolutePath;
|
||||
|
||||
Destination = result;
|
||||
_outputPrefix = Path.Combine(Path.GetDirectoryName(Destination) ?? "",
|
||||
Path.GetFileNameWithoutExtension(Destination));
|
||||
|
||||
_outputPrefix = Path.Combine(Path.GetDirectoryName(result) ?? "", Path.GetFileNameWithoutExtension(result));
|
||||
if(string.IsNullOrEmpty(Path.GetExtension(Destination)))
|
||||
Destination += SelectedPlugin.Plugin.KnownExtensions.First();
|
||||
|
||||
Resume = true;
|
||||
}
|
||||
|
||||
18
Aaru.Localization/UI.Designer.cs
generated
18
Aaru.Localization/UI.Designer.cs
generated
@@ -2197,6 +2197,24 @@ namespace Aaru.Localization {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Aaru resume file.
|
||||
/// </summary>
|
||||
public static string Dialog_Aaru_Resume {
|
||||
get {
|
||||
return ResourceManager.GetString("Dialog_Aaru_Resume", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to All.
|
||||
/// </summary>
|
||||
public static string Dialog_All_files {
|
||||
get {
|
||||
return ResourceManager.GetString("Dialog_All_files", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Binary.
|
||||
/// </summary>
|
||||
|
||||
@@ -3029,4 +3029,10 @@ Probadores:
|
||||
<data name="CD_PMA" xml:space="preserve">
|
||||
<value>CD PMA:</value>
|
||||
</data>
|
||||
<data name="Dialog_All_files" xml:space="preserve">
|
||||
<value>Todos</value>
|
||||
</data>
|
||||
<data name="Dialog_Aaru_Resume" xml:space="preserve">
|
||||
<value>Fichero de resumen de Aaru</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -3105,4 +3105,10 @@ Do you want to continue?</value>
|
||||
<data name="CD_PMA" xml:space="preserve">
|
||||
<value>CD PMA:</value>
|
||||
</data>
|
||||
<data name="Dialog_All_files" xml:space="preserve">
|
||||
<value>All</value>
|
||||
</data>
|
||||
<data name="Dialog_Aaru_Resume" xml:space="preserve">
|
||||
<value>Aaru resume file</value>
|
||||
</data>
|
||||
</root>
|
||||
Reference in New Issue
Block a user