twitch vod downloading done
ffmpeg essentials fix Project reorganized git lfs ffmpeg removed ffmpeg added
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VDownload.Services.UI.StoragePicker
|
||||
{
|
||||
public class FileSavePickerFileTypeChoice
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public string Description { get; private set; }
|
||||
public IEnumerable<string> Extensions { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public FileSavePickerFileTypeChoice(string description, string[] extensions)
|
||||
{
|
||||
Description = description;
|
||||
Extensions = extensions.Select(x => x.StartsWith('.') ? x : $".{x}");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Storage;
|
||||
using Windows.Storage.Pickers;
|
||||
using WinRT.Interop;
|
||||
|
||||
namespace VDownload.Services.UI.StoragePicker
|
||||
{
|
||||
public interface IStoragePickerService
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
Window DefaultRoot { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region METHODS
|
||||
|
||||
Task<string?> OpenDirectory();
|
||||
Task<string?> OpenDirectory(StoragePickerStartLocation startLocation);
|
||||
Task<IEnumerable<string>> OpenMultipleFiles();
|
||||
Task<IEnumerable<string>> OpenMultipleFiles(StoragePickerStartLocation startLocation);
|
||||
Task<IEnumerable<string>> OpenMultipleFiles(string[] fileTypes);
|
||||
Task<IEnumerable<string>> OpenMultipleFiles(string[] fileTypes, StoragePickerStartLocation startLocation);
|
||||
Task<string?> OpenSingleFile();
|
||||
Task<string?> OpenSingleFile(StoragePickerStartLocation startLocation);
|
||||
Task<string?> OpenSingleFile(string[] fileTypes);
|
||||
Task<string?> OpenSingleFile(string[] fileTypes, StoragePickerStartLocation startLocation);
|
||||
Task<string?> SaveFile(FileSavePickerFileTypeChoice[] fileTypes, string defaultFileType);
|
||||
Task<string?> SaveFile(FileSavePickerFileTypeChoice[] fileTypes, string defaultFileType, StoragePickerStartLocation startLocation);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class StoragePickerService : IStoragePickerService
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Window DefaultRoot { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public async Task<string?> OpenDirectory() => await OpenDirectory(StoragePickerStartLocation.Unspecified);
|
||||
public async Task<string?> OpenDirectory(StoragePickerStartLocation startLocation)
|
||||
{
|
||||
FolderPicker picker = new FolderPicker();
|
||||
InitializePicker(picker);
|
||||
|
||||
ConfigureFolderPicker(picker, startLocation);
|
||||
|
||||
StorageFolder directory = await picker.PickSingleFolderAsync();
|
||||
return directory?.Path;
|
||||
}
|
||||
|
||||
public async Task<string?> OpenSingleFile() => await OpenSingleFile(["*"], StoragePickerStartLocation.Unspecified);
|
||||
public async Task<string?> OpenSingleFile(string[] fileTypes) => await OpenSingleFile(fileTypes, StoragePickerStartLocation.Unspecified);
|
||||
public async Task<string?> OpenSingleFile(StoragePickerStartLocation startLocation) => await OpenSingleFile(["*"], startLocation);
|
||||
public async Task<string?> OpenSingleFile(string[] fileTypes, StoragePickerStartLocation startLocation)
|
||||
{
|
||||
FileOpenPicker picker = new FileOpenPicker();
|
||||
InitializePicker(picker);
|
||||
|
||||
ConfigureFileOpenPicker(picker, fileTypes, startLocation);
|
||||
|
||||
StorageFile storageFile = await picker.PickSingleFileAsync();
|
||||
return storageFile?.Path;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<string>> OpenMultipleFiles() => await OpenMultipleFiles(["*"], StoragePickerStartLocation.Unspecified);
|
||||
public async Task<IEnumerable<string>> OpenMultipleFiles(string[] fileTypes) => await OpenMultipleFiles(fileTypes, StoragePickerStartLocation.Unspecified);
|
||||
public async Task<IEnumerable<string>> OpenMultipleFiles(StoragePickerStartLocation startLocation) => await OpenMultipleFiles(["*"], startLocation);
|
||||
public async Task<IEnumerable<string>> OpenMultipleFiles(string[] fileTypes, StoragePickerStartLocation startLocation)
|
||||
{
|
||||
FileOpenPicker picker = new FileOpenPicker();
|
||||
InitializePicker(picker);
|
||||
|
||||
ConfigureFileOpenPicker(picker, fileTypes, startLocation);
|
||||
|
||||
IEnumerable<StorageFile> list = await picker.PickMultipleFilesAsync();
|
||||
return list.Select(x => x.Path);
|
||||
}
|
||||
|
||||
public async Task<string?> SaveFile(FileSavePickerFileTypeChoice[] fileTypes, string defaultFileType) => await SaveFile(fileTypes, defaultFileType, StoragePickerStartLocation.Unspecified);
|
||||
public async Task<string?> SaveFile(FileSavePickerFileTypeChoice[] fileTypes, string defaultFileType, StoragePickerStartLocation startLocation)
|
||||
{
|
||||
FileSavePicker picker = new FileSavePicker();
|
||||
InitializePicker(picker);
|
||||
|
||||
ConfigureFileSavePicker(picker, fileTypes, defaultFileType, startLocation);
|
||||
|
||||
StorageFile file = await picker.PickSaveFileAsync();
|
||||
return file?.Path;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PRIVATE METHODS
|
||||
|
||||
protected void InitializePicker(object picker)
|
||||
{
|
||||
var hwnd = WindowNative.GetWindowHandle(DefaultRoot);
|
||||
InitializeWithWindow.Initialize(picker, hwnd);
|
||||
}
|
||||
|
||||
protected void ConfigureFolderPicker(FolderPicker picker, StoragePickerStartLocation startLocation)
|
||||
{
|
||||
if (startLocation != StoragePickerStartLocation.Unspecified)
|
||||
{
|
||||
picker.SuggestedStartLocation = (PickerLocationId)startLocation;
|
||||
}
|
||||
}
|
||||
|
||||
protected void ConfigureFileOpenPicker(FileOpenPicker picker, string[] fileTypes, StoragePickerStartLocation startLocation)
|
||||
{
|
||||
foreach (string fileType in fileTypes)
|
||||
{
|
||||
picker.FileTypeFilter.Add(fileType);
|
||||
}
|
||||
|
||||
if (startLocation != StoragePickerStartLocation.Unspecified)
|
||||
{
|
||||
picker.SuggestedStartLocation = (PickerLocationId)startLocation;
|
||||
}
|
||||
}
|
||||
|
||||
protected void ConfigureFileSavePicker(FileSavePicker picker, FileSavePickerFileTypeChoice[] fileTypes, string defaultFileType, StoragePickerStartLocation startLocation)
|
||||
{
|
||||
if (startLocation != StoragePickerStartLocation.Unspecified)
|
||||
{
|
||||
picker.SuggestedStartLocation = (PickerLocationId)startLocation;
|
||||
}
|
||||
|
||||
foreach (FileSavePickerFileTypeChoice fileType in fileTypes)
|
||||
{
|
||||
picker.FileTypeChoices.Add(fileType.Description, fileType.Extensions.ToList());
|
||||
}
|
||||
|
||||
if (!defaultFileType.StartsWith('.'))
|
||||
{
|
||||
defaultFileType = $".{defaultFileType}";
|
||||
}
|
||||
|
||||
if (!fileTypes.Any(x => x.Extensions.Contains(defaultFileType)))
|
||||
{
|
||||
picker.FileTypeChoices.Add("Default", [defaultFileType]);
|
||||
}
|
||||
|
||||
picker.DefaultFileExtension = defaultFileType;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VDownload.Services.UI.StoragePicker
|
||||
{
|
||||
public enum StoragePickerStartLocation
|
||||
{
|
||||
Documents = 0,
|
||||
Computer = 1,
|
||||
Desktop = 2,
|
||||
Downloads = 3,
|
||||
Music = 5,
|
||||
Pictures = 6,
|
||||
Videos = 7,
|
||||
Unspecified = 999
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<RootNamespace>VDownload.Services.UI.StoragePicker</RootNamespace>
|
||||
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
|
||||
<UseWinUI>true</UseWinUI>
|
||||
<UseRidGraph>true</UseRidGraph>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.240211001" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.2428" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user