diff --git a/VDownload.Core/VDownload.Core.Strings/VDownload.Core.Strings.csproj b/VDownload.Core/VDownload.Core.Strings/VDownload.Core.Strings.csproj
index 2a99cd6..d5d725e 100644
--- a/VDownload.Core/VDownload.Core.Strings/VDownload.Core.Strings.csproj
+++ b/VDownload.Core/VDownload.Core.Strings/VDownload.Core.Strings.csproj
@@ -9,8 +9,8 @@
-
-
+
+
diff --git a/VDownload.Core/VDownload.Core.Tasks/DownloadTask.cs b/VDownload.Core/VDownload.Core.Tasks/DownloadTask.cs
index 4686cba..bd7293e 100644
--- a/VDownload.Core/VDownload.Core.Tasks/DownloadTask.cs
+++ b/VDownload.Core/VDownload.Core.Tasks/DownloadTask.cs
@@ -140,7 +140,7 @@ namespace VDownload.Core.Tasks
await _settingsService.Load();
- string tempDirectory = $"{_settingsService.Data.Common.TempDirectory}\\{_configurationService.Common.Path.Temp.TasksDirectory}\\{_id}";
+ string tempDirectory = $"{_settingsService.Data.Common.Temp.Directory}\\{_configurationService.Common.Path.Temp.TasksDirectory}\\{_id}";
Directory.CreateDirectory(tempDirectory);
List content = new List()
@@ -211,7 +211,7 @@ namespace VDownload.Core.Tasks
}
finally
{
- if (Status != DownloadTaskStatus.EndedUnsuccessfully || _settingsService.Data.Common.DeleteTempOnError)
+ if (Status != DownloadTaskStatus.EndedUnsuccessfully || _settingsService.Data.Common.Temp.DeleteOnError)
{
Directory.Delete(tempDirectory, true);
}
diff --git a/VDownload.Core/VDownload.Core.Tasks/DownloadTaskManager.cs b/VDownload.Core/VDownload.Core.Tasks/DownloadTaskManager.cs
index 3d1773a..7b29197 100644
--- a/VDownload.Core/VDownload.Core.Tasks/DownloadTaskManager.cs
+++ b/VDownload.Core/VDownload.Core.Tasks/DownloadTaskManager.cs
@@ -129,13 +129,12 @@ namespace VDownload.Core.Tasks
DownloadTaskStatus.Processing,
DownloadTaskStatus.Finalizing
];
-
while (true)
{
try
{
IEnumerable pendingTasks = Tasks.Where(x => pendingStatuses.Contains(x.Status));
- int freeSlots = _settingsService.Data.Common.MaxNumberOfRunningTasks - pendingTasks.Count();
+ int freeSlots = _settingsService.Data.Common.Tasks.MaxNumberOfRunningTasks - pendingTasks.Count();
if (freeSlots > 0)
{
IEnumerable queuedTasks = Tasks.Where(x => x.Status == DownloadTaskStatus.Queued).OrderBy(x => x.CreateDate).Take(freeSlots);
diff --git a/VDownload.Core/VDownload.Core.ViewModels/BaseViewModel.cs b/VDownload.Core/VDownload.Core.ViewModels/BaseViewModel.cs
index 9b5adfc..0e1986b 100644
--- a/VDownload.Core/VDownload.Core.ViewModels/BaseViewModel.cs
+++ b/VDownload.Core/VDownload.Core.ViewModels/BaseViewModel.cs
@@ -11,7 +11,7 @@ using VDownload.Core.ViewModels.Home;
using VDownload.Core.ViewModels.Settings;
using VDownload.Services.UI.DictionaryResources;
using VDownload.Services.UI.StringResources;
-using VDownload.Toolkit.UI.Models;
+using SimpleToolkit.UI.Models;
namespace VDownload.Core.ViewModels
{
diff --git a/VDownload.Core/VDownload.Core.ViewModels/Home/HomePlaylistViewModel.cs b/VDownload.Core/VDownload.Core.ViewModels/Home/HomePlaylistViewModel.cs
new file mode 100644
index 0000000..de45d65
--- /dev/null
+++ b/VDownload.Core/VDownload.Core.ViewModels/Home/HomePlaylistViewModel.cs
@@ -0,0 +1,75 @@
+using CommunityToolkit.Mvvm.ComponentModel;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using VDownload.Models;
+using VDownload.Sources.Twitch.Configuration.Models;
+
+namespace VDownload.Core.ViewModels.Home
+{
+ public partial class HomePlaylistViewModel : ObservableObject
+ {
+ #region SERVICES
+
+
+
+ #endregion
+
+
+
+ #region FIELDS
+
+
+
+ #endregion
+
+
+
+ #region PROPERTIES
+
+ [ObservableProperty]
+ protected string _name;
+
+ #endregion
+
+
+
+ #region CONSTRUCTORS
+
+ public HomePlaylistViewModel()
+ {
+ }
+
+ #endregion
+
+
+
+ #region PUBLIC METHODS
+
+ public async Task LoadPlaylist(Playlist playlist)
+ {
+ Name = playlist.Name;
+ }
+
+ #endregion
+
+
+
+ #region COMMANDS
+
+
+
+ #endregion
+
+
+
+ #region EVENTS
+
+ public event EventHandler CloseRequested;
+
+ #endregion
+ }
+}
diff --git a/VDownload.Core/VDownload.Core.ViewModels/Home/HomeVideoViewModel.cs b/VDownload.Core/VDownload.Core.ViewModels/Home/HomeVideoViewModel.cs
index 9de4c76..8fb5a4e 100644
--- a/VDownload.Core/VDownload.Core.ViewModels/Home/HomeVideoViewModel.cs
+++ b/VDownload.Core/VDownload.Core.ViewModels/Home/HomeVideoViewModel.cs
@@ -87,14 +87,6 @@ namespace VDownload.Core.ViewModels.Home
- #region EVENTS
-
- public event EventHandler TaskAdded;
-
- #endregion
-
-
-
#region CONSTRUCTORS
public HomeVideoViewModel(IDownloadTaskManager tasksManager, ISettingsService settingsService, IStoragePickerService storagePickerService)
@@ -110,7 +102,7 @@ namespace VDownload.Core.ViewModels.Home
#region PUBLIC METHODS
- public async void LoadVideo(Video video)
+ public async Task LoadVideo(Video video)
{
await _settingsService.Load();
@@ -125,13 +117,13 @@ namespace VDownload.Core.ViewModels.Home
Streams = [.. video.Streams];
SelectedStream = Streams[0];
- MediaType = _settingsService.Data.Common.DefaultTaskSettings.MediaType;
+ MediaType = _settingsService.Data.Common.Tasks.DefaultMediaType;
TrimStart = TimeSpan.Zero;
TrimEnd = Duration;
- DirectoryPath = _settingsService.Data.Common.DefaultTaskSettings.OutputDirectory;
+ DirectoryPath = _settingsService.Data.Common.Tasks.DefaultOutputDirectory;
Filename = Title.Length > 50 ? Title.Substring(0, 50) : Title;
- VideoExtension = _settingsService.Data.Common.DefaultTaskSettings.VideoExtension;
- AudioExtension = _settingsService.Data.Common.DefaultTaskSettings.AudioExtension;
+ VideoExtension = _settingsService.Data.Common.Tasks.DefaultVideoExtension;
+ AudioExtension = _settingsService.Data.Common.Tasks.DefaultAudioExtension;
}
@@ -149,14 +141,14 @@ namespace VDownload.Core.ViewModels.Home
public void CreateTask()
{
_tasksManager.AddTask(_video, BuildDownloadOptions());
- TaskAdded?.Invoke(this, EventArgs.Empty);
+ CloseRequested?.Invoke(this, EventArgs.Empty);
}
[RelayCommand]
public void CreateTaskAndDownload()
{
DownloadTask task = _tasksManager.AddTask(_video, BuildDownloadOptions());
- TaskAdded?.Invoke(this, EventArgs.Empty);
+ CloseRequested?.Invoke(this, EventArgs.Empty);
task.Enqueue();
}
@@ -181,5 +173,13 @@ namespace VDownload.Core.ViewModels.Home
}
#endregion
+
+
+
+ #region EVENTS
+
+ public event EventHandler CloseRequested;
+
+ #endregion
}
}
diff --git a/VDownload.Core/VDownload.Core.ViewModels/Home/HomeViewModel.cs b/VDownload.Core/VDownload.Core.ViewModels/Home/HomeViewModel.cs
index 474b89e..55e2944 100644
--- a/VDownload.Core/VDownload.Core.ViewModels/Home/HomeViewModel.cs
+++ b/VDownload.Core/VDownload.Core.ViewModels/Home/HomeViewModel.cs
@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using VDownload.Core.Tasks;
using VDownload.Models;
using VDownload.Services.Data.Configuration;
using VDownload.Services.Data.Settings;
@@ -42,7 +43,10 @@ namespace VDownload.Core.ViewModels.Home
protected readonly IStringResourcesService _stringResourcesService;
protected readonly ISearchService _searchService;
+ protected readonly IDownloadTaskManager _downloadTaskManager;
+
protected readonly HomeVideoViewModel _videoViewModel;
+ protected readonly HomePlaylistViewModel _playlistViewModel;
#endregion
@@ -52,6 +56,7 @@ namespace VDownload.Core.ViewModels.Home
protected readonly Type _downloadsView = typeof(HomeDownloadsViewModel);
protected readonly Type _videoView = typeof(HomeVideoViewModel);
+ protected readonly Type _playlistView = typeof(HomePlaylistViewModel);
#endregion
@@ -96,15 +101,20 @@ namespace VDownload.Core.ViewModels.Home
#region CONSTRUCTORS
- public HomeViewModel(IConfigurationService configurationService, ISettingsService settingsService, IStringResourcesService stringResourcesService, ISearchService searchService, HomeVideoViewModel videoViewModel)
+ public HomeViewModel(IConfigurationService configurationService, ISettingsService settingsService, IStringResourcesService stringResourcesService, ISearchService searchService, IDownloadTaskManager downloadTaskManager, HomeVideoViewModel videoViewModel, HomePlaylistViewModel playlistViewModel)
{
_configurationService = configurationService;
_settingsService = settingsService;
_stringResourcesService = stringResourcesService;
_searchService = searchService;
+ _downloadTaskManager = downloadTaskManager;
+
_videoViewModel = videoViewModel;
- _videoViewModel.TaskAdded += VideoViewModel_TaskAdded;
+ _videoViewModel.CloseRequested += BackToDownload_EventHandler;
+
+ _playlistViewModel = playlistViewModel;
+ _playlistViewModel.CloseRequested += BackToDownload_EventHandler;
}
#endregion
@@ -195,7 +205,7 @@ namespace VDownload.Core.ViewModels.Home
return;
}
- _videoViewModel.LoadVideo(video);
+ await _videoViewModel.LoadVideo(video);
MainContent = _videoView;
@@ -224,6 +234,10 @@ namespace VDownload.Core.ViewModels.Home
return;
}
+ await _playlistViewModel.LoadPlaylist(playlist);
+
+ MainContent = _playlistView;
+
OptionBarSearchNotPending = true;
OptionBarLoading = false;
OptionBarMessage = null;
@@ -232,7 +246,10 @@ namespace VDownload.Core.ViewModels.Home
[RelayCommand]
public void Download()
{
-
+ foreach (DownloadTask task in _downloadTaskManager.Tasks)
+ {
+ task.Enqueue();
+ }
}
#endregion
@@ -241,7 +258,7 @@ namespace VDownload.Core.ViewModels.Home
#region PRIVATE METHODS
- private async void VideoViewModel_TaskAdded(object sender, EventArgs e) => await Navigation();
+ private async void BackToDownload_EventHandler(object sender, EventArgs e) => await Navigation();
#endregion
}
diff --git a/VDownload.Core/VDownload.Core.ViewModels/VDownload.Core.ViewModels.csproj b/VDownload.Core/VDownload.Core.ViewModels/VDownload.Core.ViewModels.csproj
index 9f8b80b..fb0943c 100644
--- a/VDownload.Core/VDownload.Core.ViewModels/VDownload.Core.ViewModels.csproj
+++ b/VDownload.Core/VDownload.Core.ViewModels/VDownload.Core.ViewModels.csproj
@@ -12,6 +12,7 @@
+
@@ -23,7 +24,6 @@
-
diff --git a/VDownload.Core/VDownload.Core.Views/BaseWindow.xaml b/VDownload.Core/VDownload.Core.Views/BaseWindow.xaml
index 502fbc3..47ac369 100644
--- a/VDownload.Core/VDownload.Core.Views/BaseWindow.xaml
+++ b/VDownload.Core/VDownload.Core.Views/BaseWindow.xaml
@@ -7,7 +7,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="using:Microsoft.Xaml.Interactivity"
xmlns:ic="using:Microsoft.Xaml.Interactions.Core"
- xmlns:cb="using:VDownload.Toolkit.UI.Behaviors"
+ xmlns:cb="using:SimpleToolkit.UI.WinUI.Behaviors"
mc:Ignorable="d">
diff --git a/VDownload.Core/VDownload.Core.Views/Home/HomePlaylistView.xaml b/VDownload.Core/VDownload.Core.Views/Home/HomePlaylistView.xaml
new file mode 100644
index 0000000..7b48111
--- /dev/null
+++ b/VDownload.Core/VDownload.Core.Views/Home/HomePlaylistView.xaml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/VDownload.Core/VDownload.Core.Views/Home/HomePlaylistView.xaml.cs b/VDownload.Core/VDownload.Core.Views/Home/HomePlaylistView.xaml.cs
new file mode 100644
index 0000000..541afe6
--- /dev/null
+++ b/VDownload.Core/VDownload.Core.Views/Home/HomePlaylistView.xaml.cs
@@ -0,0 +1,31 @@
+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 System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using VDownload.Core.ViewModels.Home;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+
+namespace VDownload.Core.Views.Home
+{
+ public sealed partial class HomePlaylistView : Page
+ {
+ #region CONSTRUCTORS
+
+ public HomePlaylistView(HomePlaylistViewModel viewModel)
+ {
+ this.InitializeComponent();
+ this.DataContext = viewModel;
+ }
+
+ #endregion
+ }
+}
diff --git a/VDownload.Core/VDownload.Core.Views/Home/HomeVideoView.xaml b/VDownload.Core/VDownload.Core.Views/Home/HomeVideoView.xaml
index 4e162e2..b9259fa 100644
--- a/VDownload.Core/VDownload.Core.Views/Home/HomeVideoView.xaml
+++ b/VDownload.Core/VDownload.Core.Views/Home/HomeVideoView.xaml
@@ -12,7 +12,7 @@
xmlns:ct="using:CommunityToolkit.WinUI"
xmlns:ctc="using:CommunityToolkit.WinUI.Controls"
xmlns:ctuc="using:CommunityToolkit.WinUI.UI.Controls"
- xmlns:c="using:VDownload.Toolkit.UI.Controls"
+ xmlns:c="using:SimpleToolkit.UI.WinUI.Controls"
mc:Ignorable="d"
Background="{ThemeResource ViewBackgroundColor}">
diff --git a/VDownload.Core/VDownload.Core.Views/VDownload.Core.Views.csproj b/VDownload.Core/VDownload.Core.Views/VDownload.Core.Views.csproj
index 43efa2d..9c56c5c 100644
--- a/VDownload.Core/VDownload.Core.Views/VDownload.Core.Views.csproj
+++ b/VDownload.Core/VDownload.Core.Views/VDownload.Core.Views.csproj
@@ -7,6 +7,9 @@
true
true
+
+
+
@@ -16,11 +19,11 @@
+
+
-
-
@@ -35,6 +38,9 @@
MSBuild:Compile
+
+ MSBuild:Compile
+
MSBuild:Compile
diff --git a/VDownload.Core/VDownload.Core.Views/ViewModelToViewConverter.cs b/VDownload.Core/VDownload.Core.Views/ViewModelToViewConverter.cs
index 7bafd1b..7ce906b 100644
--- a/VDownload.Core/VDownload.Core.Views/ViewModelToViewConverter.cs
+++ b/VDownload.Core/VDownload.Core.Views/ViewModelToViewConverter.cs
@@ -20,6 +20,7 @@ namespace VDownload.Core.Views
{ typeof(HomeViewModel), typeof(HomeView) },
{ typeof(HomeDownloadsViewModel), typeof(HomeDownloadsView) },
{ typeof(HomeVideoViewModel), typeof(HomeVideoView) },
+ { typeof(HomePlaylistViewModel), typeof(HomePlaylistView) },
{ typeof(SettingsViewModel), typeof(SettingsView) },
{ typeof(AuthenticationViewModel), typeof(AuthenticationView) }
};
diff --git a/VDownload.Models/Playlist.cs b/VDownload.Models/Playlist.cs
index c9ffadd..4dcb4fe 100644
--- a/VDownload.Models/Playlist.cs
+++ b/VDownload.Models/Playlist.cs
@@ -6,7 +6,15 @@ using System.Threading.Tasks;
namespace VDownload.Models
{
- public abstract class Playlist
+ public abstract class Playlist : List