Added playlist view.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@@ -7,16 +8,18 @@ using Windows.Storage.Pickers;
|
||||
|
||||
namespace Harmonia.WinUI.Storage;
|
||||
|
||||
public class WindowsStorageProvider(MainWindow mainWindow) : IStorageProvider
|
||||
public class WindowsStorageProvider : IStorageProvider
|
||||
{
|
||||
public async Task<string> GetFileAsync(FilePickerOptions? options = null)
|
||||
private static MainWindow MainWindow => App.ServiceProvider.GetRequiredService<MainWindow>();
|
||||
|
||||
public async Task<string?> GetSingleFileAsync(FilePickerOptions? options = null)
|
||||
{
|
||||
FileOpenPicker fileOpenPicker = GetFileOpenPicker(options);
|
||||
InitializePicker(fileOpenPicker);
|
||||
|
||||
StorageFile storageFile = await fileOpenPicker.PickSingleFileAsync();
|
||||
StorageFile? storageFile = await fileOpenPicker.PickSingleFileAsync();
|
||||
|
||||
return storageFile.Path;
|
||||
return storageFile?.Path;
|
||||
}
|
||||
|
||||
public async Task<string[]> GetFilesAsync(FilePickerOptions? options = null)
|
||||
@@ -67,7 +70,7 @@ public class WindowsStorageProvider(MainWindow mainWindow) : IStorageProvider
|
||||
return [.. fileTypes.SelectMany(fileType => fileType.Patterns)];
|
||||
}
|
||||
|
||||
public async Task<string> GetPathAsync()
|
||||
public async Task<string?> GetPathAsync()
|
||||
{
|
||||
var folderPicker = new FolderPicker
|
||||
{
|
||||
@@ -77,14 +80,14 @@ public class WindowsStorageProvider(MainWindow mainWindow) : IStorageProvider
|
||||
|
||||
InitializePicker(folderPicker);
|
||||
|
||||
StorageFolder folder = await folderPicker.PickSingleFolderAsync();
|
||||
StorageFolder? folder = await folderPicker.PickSingleFolderAsync();
|
||||
|
||||
return folder.Path;
|
||||
return folder?.Path;
|
||||
}
|
||||
|
||||
private void InitializePicker(object target)
|
||||
private static void InitializePicker(object target)
|
||||
{
|
||||
var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(mainWindow);
|
||||
var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(MainWindow);
|
||||
WinRT.Interop.InitializeWithWindow.Initialize(target, hWnd);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user