twitch vod downloading done
ffmpeg essentials fix Project reorganized git lfs ffmpeg removed ffmpeg added
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VDownload.Services.UI.Dialogs
|
||||
{
|
||||
public enum DialogResult
|
||||
{
|
||||
Primary,
|
||||
Secondary,
|
||||
Cancelled
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VDownload.Services.UI.Dialogs
|
||||
{
|
||||
public enum DialogResultOkCancel
|
||||
{
|
||||
Ok,
|
||||
Cancel
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VDownload.Services.UI.Dialogs
|
||||
{
|
||||
public enum DialogResultYesNo
|
||||
{
|
||||
Yes,
|
||||
No
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VDownload.Services.UI.Dialogs
|
||||
{
|
||||
public enum DialogResultYesNoCancel
|
||||
{
|
||||
Yes,
|
||||
No,
|
||||
Cancelled
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VDownload.Services.UI.Dialogs
|
||||
{
|
||||
public interface IDialogsService
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
XamlRoot DefaultRoot { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region METHODS
|
||||
|
||||
Task ShowClose(string title, string message);
|
||||
Task<DialogResult> ShowDouble(string title, string message, string primaryButtonText, string secondaryButtonText);
|
||||
Task ShowOk(string title, string message);
|
||||
Task<DialogResultOkCancel> ShowOkCancel(string title, string message);
|
||||
Task ShowSingle(string title, string message, string buttonText);
|
||||
Task<DialogResult> ShowTriple(string title, string message, string primaryButtonText, string secondaryButtonText, string cancelButtonText);
|
||||
Task<DialogResultYesNo> ShowYesNo(string title, string message);
|
||||
Task<DialogResultYesNoCancel> ShowYesNoCancel(string title, string message);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class DialogsService : IDialogsService
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public XamlRoot DefaultRoot { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public async Task ShowOk(string title, string message) => await ShowSingle(title, message, "OK");
|
||||
public async Task ShowClose(string title, string message) => await ShowSingle(title, message, "Close");
|
||||
public async Task ShowSingle(string title, string message, string buttonText)
|
||||
{
|
||||
ContentDialog contentDialog = BuildDialog(title, message);
|
||||
contentDialog.CloseButtonText = buttonText;
|
||||
await ShowDialog(contentDialog);
|
||||
}
|
||||
|
||||
public async Task<DialogResultOkCancel> ShowOkCancel(string title, string message) => await ShowDouble(title, message, "OK", "Cancel") switch
|
||||
{
|
||||
DialogResult.Primary => DialogResultOkCancel.Ok,
|
||||
_ => DialogResultOkCancel.Cancel
|
||||
};
|
||||
public async Task<DialogResultYesNo> ShowYesNo(string title, string message) => await ShowDouble(title, message, "Yes", "No") switch
|
||||
{
|
||||
DialogResult.Primary => DialogResultYesNo.Yes,
|
||||
_ => DialogResultYesNo.No
|
||||
};
|
||||
public async Task<DialogResult> ShowDouble(string title, string message, string primaryButtonText, string secondaryButtonText)
|
||||
{
|
||||
ContentDialog contentDialog = BuildDialog(title, message);
|
||||
contentDialog.PrimaryButtonText = primaryButtonText;
|
||||
contentDialog.SecondaryButtonText = secondaryButtonText;
|
||||
return await ShowDialog(contentDialog);
|
||||
}
|
||||
|
||||
public async Task<DialogResultYesNoCancel> ShowYesNoCancel(string title, string message) => await ShowTriple(title, message, "Yes", "No", "Cancel") switch
|
||||
{
|
||||
DialogResult.Primary => DialogResultYesNoCancel.Yes,
|
||||
DialogResult.Secondary => DialogResultYesNoCancel.Yes,
|
||||
_ => DialogResultYesNoCancel.Cancelled
|
||||
};
|
||||
public async Task<DialogResult> ShowTriple(string title, string message, string primaryButtonText, string secondaryButtonText, string cancelButtonText)
|
||||
{
|
||||
ContentDialog contentDialog = BuildDialog(title, message);
|
||||
contentDialog.PrimaryButtonText = primaryButtonText;
|
||||
contentDialog.SecondaryButtonText = secondaryButtonText;
|
||||
contentDialog.CloseButtonText = cancelButtonText;
|
||||
return await ShowDialog(contentDialog);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PRIVATE METHODS
|
||||
|
||||
private ContentDialog BuildDialog(string title, string message)
|
||||
{
|
||||
return new ContentDialog()
|
||||
{
|
||||
Title = title,
|
||||
Content = message,
|
||||
XamlRoot = DefaultRoot
|
||||
};
|
||||
}
|
||||
|
||||
private async Task<DialogResult> ShowDialog(ContentDialog dialog)
|
||||
{
|
||||
ContentDialogResult result = await dialog.ShowAsync();
|
||||
return result switch
|
||||
{
|
||||
ContentDialogResult.Primary => DialogResult.Primary,
|
||||
ContentDialogResult.Secondary => DialogResult.Secondary,
|
||||
_ => DialogResult.Cancelled
|
||||
}; ;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -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.Dialogs</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>
|
||||
@@ -0,0 +1,41 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VDownload.Services.UI.DictionaryResources
|
||||
{
|
||||
public interface IDictionaryResourcesService
|
||||
{
|
||||
T Get<T>(string key);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class DictionaryResourcesService : IDictionaryResourcesService
|
||||
{
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public DictionaryResourcesService() { }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public T Get<T>(string key)
|
||||
{
|
||||
Application.Current.Resources.TryGetValue(key, out object value);
|
||||
if (value is not null && value is T cast)
|
||||
{
|
||||
return cast;
|
||||
}
|
||||
throw new KeyNotFoundException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -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.DictionaryResources</RootNamespace>
|
||||
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
|
||||
<UseWinUI>true</UseWinUI>
|
||||
<UseRidGraph>true</UseRidGraph>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.230913002" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.755" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,36 @@
|
||||
using Microsoft.Windows.AppNotifications;
|
||||
using Microsoft.Windows.AppNotifications.Builder;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VDownload.Services.UI.Notifications
|
||||
{
|
||||
public interface INotificationsService
|
||||
{
|
||||
void SendNotification(string title, IEnumerable<string> message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class NotificationsService : INotificationsService
|
||||
{
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public void SendNotification(string title, IEnumerable<string> message)
|
||||
{
|
||||
AppNotificationBuilder builder = new AppNotificationBuilder();
|
||||
builder.AddText(title);
|
||||
foreach (string text in message)
|
||||
{
|
||||
builder.AddText(text);
|
||||
}
|
||||
AppNotification notification = builder.BuildNotification();
|
||||
AppNotificationManager.Default.Show(notification);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -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.Notifications</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>
|
||||
@@ -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>
|
||||
@@ -0,0 +1,37 @@
|
||||
using Windows.ApplicationModel.Resources;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VDownload.Services.UI.StringResources
|
||||
{
|
||||
public class StringResources
|
||||
{
|
||||
#region FIELDS
|
||||
|
||||
protected ResourceLoader _resourceLoader;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
internal StringResources(ResourceLoader resourceLoader)
|
||||
{
|
||||
_resourceLoader = resourceLoader;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public string Get(string key) => _resourceLoader.GetString(key);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using VDownload.Services.Data.Configuration;
|
||||
using Windows.ApplicationModel.Resources;
|
||||
|
||||
namespace VDownload.Services.UI.StringResources
|
||||
{
|
||||
public interface IStringResourcesService
|
||||
{
|
||||
StringResources BaseViewResources { get; }
|
||||
StringResources HomeViewResources { get; }
|
||||
StringResources HomeVideoViewResources { get; }
|
||||
StringResources HomeDownloadsViewResources { get; }
|
||||
StringResources AuthenticationViewResources { get; }
|
||||
StringResources NotificationsResources { get; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class StringResourcesService : IStringResourcesService
|
||||
{
|
||||
#region SERVICES
|
||||
|
||||
protected readonly IConfigurationService _configurationService;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
public StringResources BaseViewResources { get; protected set; }
|
||||
public StringResources HomeViewResources { get; protected set; }
|
||||
public StringResources HomeVideoViewResources { get; protected set; }
|
||||
public StringResources HomeDownloadsViewResources { get; protected set; }
|
||||
public StringResources AuthenticationViewResources { get; protected set; }
|
||||
public StringResources NotificationsResources { get; protected set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public StringResourcesService(IConfigurationService configurationService)
|
||||
{
|
||||
_configurationService = configurationService;
|
||||
|
||||
BaseViewResources = BuildResource("BaseViewResources");
|
||||
HomeViewResources = BuildResource("HomeViewResources");
|
||||
HomeVideoViewResources = BuildResource("HomeVideoViewResources");
|
||||
HomeDownloadsViewResources = BuildResource("HomeDownloadsViewResources");
|
||||
AuthenticationViewResources = BuildResource("AuthenticationViewResources");
|
||||
NotificationsResources = BuildResource("NotificationsResources");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PRIVATE METHODS
|
||||
|
||||
protected StringResources BuildResource(string resourceName) => new StringResources(ResourceLoader.GetForViewIndependentUse($"{_configurationService.Common.StringResourcesAssembly}/{resourceName}"));
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<RootNamespace>VDownload.Services.UI.StringResources</RootNamespace>
|
||||
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
|
||||
<UseWinUI>true</UseWinUI>
|
||||
<UseRidGraph>true</UseRidGraph>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.230913002" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.755" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\VDownload.Core\VDownload.Core.Strings\VDownload.Core.Strings.csproj" />
|
||||
<ProjectReference Include="..\..\VDownload.Services.Data\VDownload.Services.Data.Configuration\VDownload.Services.Data.Configuration.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<RootNamespace>VDownload.Services.UI.WebView</RootNamespace>
|
||||
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
|
||||
<UseWinUI>true</UseWinUI>
|
||||
<UseRidGraph>true</UseRidGraph>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="WebViewWindow.xaml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.240211001" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.2428" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Page Update="WebViewWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VDownload.Services.UI.WebView
|
||||
{
|
||||
public interface IWebViewService
|
||||
{
|
||||
Task<string> Show(Uri url, Predicate<string> closePredicate, string name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class WebViewService : IWebViewService
|
||||
{
|
||||
#region METHODS
|
||||
|
||||
public async Task<string> Show(Uri url, Predicate<string> closePredicate, string name)
|
||||
{
|
||||
WebViewWindow window = new WebViewWindow(name);
|
||||
return await window.Show(url, closePredicate);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Window
|
||||
x:Class="VDownload.Services.UI.WebView.WebViewWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:VDownload.Services.UI.WebView"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Closed="Window_Closed">
|
||||
<WebView2 x:Name="WebView" NavigationCompleted="WebView_NavigationCompleted"/>
|
||||
</Window>
|
||||
@@ -0,0 +1,89 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Controls.Primitives;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Microsoft.UI.Xaml.Navigation;
|
||||
using Microsoft.Web.WebView2.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
|
||||
namespace VDownload.Services.UI.WebView
|
||||
{
|
||||
public sealed partial class WebViewWindow : Window
|
||||
{
|
||||
#region FIEDLS
|
||||
|
||||
private readonly Predicate<string> _defaultClosePredicate = args => false;
|
||||
|
||||
private bool _isOpened;
|
||||
private Predicate<string> _closePredicate;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public WebViewWindow(string name)
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.Title = name;
|
||||
|
||||
_isOpened = false;
|
||||
_closePredicate = _defaultClosePredicate;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
internal async Task<string> Show(Uri url, Predicate<string> closePredicate)
|
||||
{
|
||||
this.WebView.Source = url;
|
||||
_closePredicate = closePredicate;
|
||||
|
||||
this.Activate();
|
||||
_isOpened = true;
|
||||
while (_isOpened)
|
||||
{
|
||||
await Task.Delay(10);
|
||||
}
|
||||
|
||||
_closePredicate = _defaultClosePredicate;
|
||||
|
||||
return this.WebView.Source.ToString();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region EVENT HANDLER
|
||||
|
||||
|
||||
private void WebView_NavigationCompleted(WebView2 sender, CoreWebView2NavigationCompletedEventArgs args)
|
||||
{
|
||||
if (_closePredicate.Invoke(this.WebView.Source.ToString()))
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Closed(object sender, WindowEventArgs args)
|
||||
{
|
||||
_isOpened = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user