From e4c90744651175d876dbdfe8607764fc4bf91b80 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Tue, 5 Mar 2024 01:45:06 +0100 Subject: [PATCH] tasks settings added, app icon added --- .../Strings/en-US/CommonResources.resw | 9 ++ .../en-US/HomeDownloadsViewResources.resw | 9 -- .../en-US/HomePlaylistViewResources.resw | 9 -- .../Strings/en-US/HomeVideoViewResources.resw | 9 -- .../Strings/en-US/SettingsViewResources.resw | 33 ++++++++ .../Settings/SettingsViewModel.cs | 78 +++++++++++++++++- .../VDownload.Core.Views/BaseWindow.xaml.cs | 11 +++ .../Home/HomeDownloadsView.xaml | 6 +- .../Home/HomePlaylistView.xaml | 6 +- .../Home/HomeVideoView.xaml | 6 +- .../Settings/SettingsView.xaml | 76 +++++++++++++++++ .../StringResourcesService.cs | 3 + VDownload/Assets/Logo/Logo.ico | Bin 0 -> 18237 bytes .../TasksDefaultMediaOptionsDark.png | Bin 0 -> 31809 bytes .../TasksDefaultMediaOptionsLight.png | Bin 0 -> 18163 bytes .../TasksFilenameTemplateDark.png | Bin 0 -> 17996 bytes .../TasksFilenameTemplateLight.png | Bin 0 -> 27707 bytes .../SettingsView/TasksOutputDirectoryDark.png | Bin 0 -> 18860 bytes .../TasksOutputDirectoryLight.png | Bin 0 -> 24198 bytes .../SettingsView/TasksRunningTasksDark.png | Bin 0 -> 19493 bytes .../SettingsView/TasksRunningTasksLight.png | Bin 0 -> 27783 bytes VDownload/Dictionaries/Converters.xaml | 1 + VDownload/Dictionaries/Images/ImagesLogo.xaml | 1 + .../Images/ImagesSettingsView.xaml | 8 ++ VDownload/VDownload.csproj | 42 +++++++++- 25 files changed, 267 insertions(+), 40 deletions(-) create mode 100644 VDownload/Assets/Logo/Logo.ico create mode 100644 VDownload/Assets/SettingsView/TasksDefaultMediaOptionsDark.png create mode 100644 VDownload/Assets/SettingsView/TasksDefaultMediaOptionsLight.png create mode 100644 VDownload/Assets/SettingsView/TasksFilenameTemplateDark.png create mode 100644 VDownload/Assets/SettingsView/TasksFilenameTemplateLight.png create mode 100644 VDownload/Assets/SettingsView/TasksOutputDirectoryDark.png create mode 100644 VDownload/Assets/SettingsView/TasksOutputDirectoryLight.png create mode 100644 VDownload/Assets/SettingsView/TasksRunningTasksDark.png create mode 100644 VDownload/Assets/SettingsView/TasksRunningTasksLight.png diff --git a/VDownload.Core/VDownload.Core.Strings/Strings/en-US/CommonResources.resw b/VDownload.Core/VDownload.Core.Strings/Strings/en-US/CommonResources.resw index 2deb893..08fb142 100644 --- a/VDownload.Core/VDownload.Core.Strings/Strings/en-US/CommonResources.resw +++ b/VDownload.Core/VDownload.Core.Strings/Strings/en-US/CommonResources.resw @@ -117,6 +117,15 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Only audio + + + Only video + + + Original + You are trying to download a video using a metered connection. Do you want to continue? diff --git a/VDownload.Core/VDownload.Core.Strings/Strings/en-US/HomeDownloadsViewResources.resw b/VDownload.Core/VDownload.Core.Strings/Strings/en-US/HomeDownloadsViewResources.resw index 3867e3d..f6b9601 100644 --- a/VDownload.Core/VDownload.Core.Strings/Strings/en-US/HomeDownloadsViewResources.resw +++ b/VDownload.Core/VDownload.Core.Strings/Strings/en-US/HomeDownloadsViewResources.resw @@ -117,15 +117,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Only audio - - - Only video - - - Original - Cancelled diff --git a/VDownload.Core/VDownload.Core.Strings/Strings/en-US/HomePlaylistViewResources.resw b/VDownload.Core/VDownload.Core.Strings/Strings/en-US/HomePlaylistViewResources.resw index 874d57f..512a21d 100644 --- a/VDownload.Core/VDownload.Core.Strings/Strings/en-US/HomePlaylistViewResources.resw +++ b/VDownload.Core/VDownload.Core.Strings/Strings/en-US/HomePlaylistViewResources.resw @@ -180,15 +180,6 @@ Media options - - Only audio - - - Only video - - - Original - Media type diff --git a/VDownload.Core/VDownload.Core.Strings/Strings/en-US/HomeVideoViewResources.resw b/VDownload.Core/VDownload.Core.Strings/Strings/en-US/HomeVideoViewResources.resw index b8b8cf7..5e860a6 100644 --- a/VDownload.Core/VDownload.Core.Strings/Strings/en-US/HomeVideoViewResources.resw +++ b/VDownload.Core/VDownload.Core.Strings/Strings/en-US/HomeVideoViewResources.resw @@ -144,15 +144,6 @@ Media options - - Only audio - - - Only video - - - Original - Media type diff --git a/VDownload.Core/VDownload.Core.Strings/Strings/en-US/SettingsViewResources.resw b/VDownload.Core/VDownload.Core.Strings/Strings/en-US/SettingsViewResources.resw index 8b0e6f4..6d25d00 100644 --- a/VDownload.Core/VDownload.Core.Strings/Strings/en-US/SettingsViewResources.resw +++ b/VDownload.Core/VDownload.Core.Strings/Strings/en-US/SettingsViewResources.resw @@ -129,6 +129,39 @@ Default number of videos fetched from playlist + + Audio extension + + + Default media options + + + Default output directory + + + Browse + + + Filename template + + + Tasks + + + Media type + + + Maximum number of tasks running in parallel + + + Otherwise, default directory defined below will be used + + + Save last output directory + + + Video extension + Twitch diff --git a/VDownload.Core/VDownload.Core.ViewModels/Settings/SettingsViewModel.cs b/VDownload.Core/VDownload.Core.ViewModels/Settings/SettingsViewModel.cs index 8315d0f..9666315 100644 --- a/VDownload.Core/VDownload.Core.ViewModels/Settings/SettingsViewModel.cs +++ b/VDownload.Core/VDownload.Core.ViewModels/Settings/SettingsViewModel.cs @@ -1,18 +1,26 @@ using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using VDownload.Models; +using VDownload.Services.Data.Configuration; using VDownload.Services.Data.Settings; +using VDownload.Services.UI.StoragePicker; +using VDownload.Services.UI.StringResources; namespace VDownload.Core.ViewModels.Settings { - public class SettingsViewModel : ObservableObject + public partial class SettingsViewModel : ObservableObject { #region SERVICES protected readonly ISettingsService _settingsService; + protected readonly IConfigurationService _configurationService; + protected readonly IStringResourcesService _stringResourcesService; + protected readonly IStoragePickerService _storagePickerService; #endregion @@ -26,6 +34,48 @@ namespace VDownload.Core.ViewModels.Settings set => SetProperty(_settingsService.Data.Common.Searching.MaxNumberOfVideosToGetFromPlaylist, value, _settingsService.Data.Common.Searching, (u, n) => u.MaxNumberOfVideosToGetFromPlaylist = n); } + public int TasksRunningTasks + { + get => _settingsService.Data.Common.Tasks.MaxNumberOfRunningTasks; + set => SetProperty(_settingsService.Data.Common.Tasks.MaxNumberOfRunningTasks, value, _settingsService.Data.Common.Tasks, (u, n) => u.MaxNumberOfRunningTasks = n); + } + + public MediaType TasksMediaType + { + get => _settingsService.Data.Common.Tasks.DefaultMediaType; + set => SetProperty(_settingsService.Data.Common.Tasks.DefaultMediaType, value, _settingsService.Data.Common.Tasks, (u, n) => u.DefaultMediaType = n); + } + + public VideoExtension TasksVideoExtension + { + get => _settingsService.Data.Common.Tasks.DefaultVideoExtension; + set => SetProperty(_settingsService.Data.Common.Tasks.DefaultVideoExtension, value, _settingsService.Data.Common.Tasks, (u, n) => u.DefaultVideoExtension = n); + } + + public AudioExtension TasksAudioExtension + { + get => _settingsService.Data.Common.Tasks.DefaultAudioExtension; + set => SetProperty(_settingsService.Data.Common.Tasks.DefaultAudioExtension, value, _settingsService.Data.Common.Tasks, (u, n) => u.DefaultAudioExtension = n); + } + + public string TasksFilenameTemplate + { + get => _settingsService.Data.Common.Tasks.FilenameTemplate; + set => SetProperty(_settingsService.Data.Common.Tasks.FilenameTemplate, value, _settingsService.Data.Common.Tasks, (u, n) => u.FilenameTemplate = n); + } + + public bool TasksSaveLastOutputDirectory + { + get => _settingsService.Data.Common.Tasks.SaveLastOutputDirectory; + set => SetProperty(_settingsService.Data.Common.Tasks.SaveLastOutputDirectory, value, _settingsService.Data.Common.Tasks, (u, n) => u.SaveLastOutputDirectory = n); + } + + public string TasksDefaultOutputDirectory + { + get => _settingsService.Data.Common.Tasks.DefaultOutputDirectory; + set => SetProperty(_settingsService.Data.Common.Tasks.DefaultOutputDirectory, value, _settingsService.Data.Common.Tasks, (u, n) => u.DefaultOutputDirectory = n); + } + public bool TwitchVodPassiveTrimming { get => _settingsService.Data.Twitch.Vod.PassiveTrimming; @@ -56,17 +106,41 @@ namespace VDownload.Core.ViewModels.Settings set => SetProperty(_settingsService.Data.Twitch.Vod.ChunkDownloadingError.RetryDelay, value, _settingsService.Data.Twitch.Vod.ChunkDownloadingError, (u, n) => u.RetryDelay = n); } + [ObservableProperty] + protected string _tasksFilenameTemplateTooltip; + #endregion #region CONSTRUCTORS - public SettingsViewModel(ISettingsService settingsService) + public SettingsViewModel(ISettingsService settingsService, IConfigurationService configurationService, IStringResourcesService stringResourcesService, IStoragePickerService storagePickerService) { _settingsService = settingsService; + _configurationService = configurationService; + _stringResourcesService = stringResourcesService; + _storagePickerService = storagePickerService; base.PropertyChanged += PropertyChangedEventHandler; + + _tasksFilenameTemplateTooltip = string.Join('\n', _configurationService.Common.FilenameTemplates.Select(x => _stringResourcesService.FilenameTemplateResources.Get(x.Name))); + } + + #endregion + + + + #region COMMANDS + + [RelayCommand] + public async Task BrowseTasksDefaultOutputDirectory() + { + string? newDirectory = await _storagePickerService.OpenDirectory(); + if (newDirectory is not null) + { + this.TasksDefaultOutputDirectory = newDirectory; + } } #endregion diff --git a/VDownload.Core/VDownload.Core.Views/BaseWindow.xaml.cs b/VDownload.Core/VDownload.Core.Views/BaseWindow.xaml.cs index c6dcf97..ade7603 100644 --- a/VDownload.Core/VDownload.Core.Views/BaseWindow.xaml.cs +++ b/VDownload.Core/VDownload.Core.Views/BaseWindow.xaml.cs @@ -1,3 +1,5 @@ +using Microsoft.UI; +using Microsoft.UI.Windowing; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls.Primitives; @@ -39,6 +41,7 @@ namespace VDownload.Core.Views public BaseWindow(BaseViewModel viewModel) { this.InitializeComponent(); + this.Activated += BaseWindow_Activated; this.ExtendsContentIntoTitleBar = true; this.SetTitleBar(this.AppTitleBar); @@ -54,6 +57,14 @@ namespace VDownload.Core.Views private void Root_Loaded(object sender, RoutedEventArgs e) => RootLoaded?.Invoke(this, EventArgs.Empty); + private void BaseWindow_Activated(object sender, WindowActivatedEventArgs args) + { + IntPtr windowHandle = WinRT.Interop.WindowNative.GetWindowHandle(this); + WindowId windowId = Win32Interop.GetWindowIdFromWindow(windowHandle); + AppWindow appWindow = AppWindow.GetFromWindowId(windowId); + appWindow.SetIcon(@"Assets\Logo\Logo.ico"); + } + #endregion } } diff --git a/VDownload.Core/VDownload.Core.Views/Home/HomeDownloadsView.xaml b/VDownload.Core/VDownload.Core.Views/Home/HomeDownloadsView.xaml index 911e767..b2a9a6d 100644 --- a/VDownload.Core/VDownload.Core.Views/Home/HomeDownloadsView.xaml +++ b/VDownload.Core/VDownload.Core.Views/Home/HomeDownloadsView.xaml @@ -98,15 +98,15 @@ Orientation="Horizontal"> - - - diff --git a/VDownload.Core/VDownload.Core.Views/Home/HomePlaylistView.xaml b/VDownload.Core/VDownload.Core.Views/Home/HomePlaylistView.xaml index ebfbe2f..9b13f73 100644 --- a/VDownload.Core/VDownload.Core.Views/Home/HomePlaylistView.xaml +++ b/VDownload.Core/VDownload.Core.Views/Home/HomePlaylistView.xaml @@ -311,13 +311,13 @@ - + - + - + diff --git a/VDownload.Core/VDownload.Core.Views/Home/HomeVideoView.xaml b/VDownload.Core/VDownload.Core.Views/Home/HomeVideoView.xaml index 73832dc..aff7cb3 100644 --- a/VDownload.Core/VDownload.Core.Views/Home/HomeVideoView.xaml +++ b/VDownload.Core/VDownload.Core.Views/Home/HomeVideoView.xaml @@ -111,13 +111,13 @@ - + - + - + diff --git a/VDownload.Core/VDownload.Core.Views/Settings/SettingsView.xaml b/VDownload.Core/VDownload.Core.Views/Settings/SettingsView.xaml index f1fe579..b9de1bd 100644 --- a/VDownload.Core/VDownload.Core.Views/Settings/SettingsView.xaml +++ b/VDownload.Core/VDownload.Core.Views/Settings/SettingsView.xaml @@ -11,6 +11,7 @@ xmlns:ct="using:CommunityToolkit.WinUI" xmlns:i="using:Microsoft.Xaml.Interactivity" xmlns:ic="using:Microsoft.Xaml.Interactions.Core" + xmlns:m="using:VDownload.Models" mc:Ignorable="d" Background="{ThemeResource ViewBackgroundColor}"> @@ -42,6 +43,81 @@ SpinButtonPlacementMode="Compact"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +