This commit is contained in:
2024-03-15 12:54:21 +01:00
Unverified
parent 8ff6071c1d
commit c4710b5a53
21 changed files with 138 additions and 151 deletions

View File

@@ -7,10 +7,10 @@ using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VDownload.Core.Strings;
using VDownload.Core.Tasks;
using VDownload.Services.Data.Settings;
using VDownload.Services.UI.Dialogs;
using VDownload.Services.UI.StringResources;
namespace VDownload.Core.ViewModels.Home
{
@@ -21,7 +21,6 @@ namespace VDownload.Core.ViewModels.Home
protected readonly IDownloadTaskManager _tasksManager;
protected readonly IDialogsService _dialogsService;
protected readonly IStringResourcesService _stringResourcesService;
protected readonly ISettingsService _settingsService;
#endregion
@@ -41,13 +40,12 @@ namespace VDownload.Core.ViewModels.Home
#region CONSTRUCTORS
public HomeDownloadsViewModel(IDownloadTaskManager tasksManager, IDialogsService dialogsService, IStringResourcesService stringResourcesService, ISettingsService settingsService)
public HomeDownloadsViewModel(IDownloadTaskManager tasksManager, IDialogsService dialogsService, ISettingsService settingsService)
{
_tasksManager = tasksManager;
_tasksManager.TaskCollectionChanged += Tasks_CollectionChanged;
_dialogsService = dialogsService;
_stringResourcesService = stringResourcesService;
_settingsService = settingsService;
_taskListIsEmpty = _tasksManager.Tasks.Count == 0;
@@ -73,8 +71,8 @@ namespace VDownload.Core.ViewModels.Home
{
if (!NetworkHelper.Instance.ConnectionInformation.IsInternetAvailable)
{
string title = _stringResourcesService.HomeDownloadsViewResources.Get("DialogErrorTitle");
string message = _stringResourcesService.HomeDownloadsViewResources.Get("DialogErrorMessageNoInternetConnection");
string title = StringResourcesManager.HomeDownloadsView.Get("DialogErrorTitle");
string message = StringResourcesManager.HomeDownloadsView.Get("DialogErrorMessageNoInternetConnection");
await _dialogsService.ShowOk(title, message);
return;
}
@@ -87,8 +85,8 @@ namespace VDownload.Core.ViewModels.Home
NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection
)
{
string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle");
string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage");
string title = StringResourcesManager.Common.Get("StartAtMeteredConnectionDialogTitle");
string message = StringResourcesManager.Common.Get("StartAtMeteredConnectionDialogMessage");
DialogResultYesNo result = await _dialogsService.ShowYesNo(title, message);
continueEnqueue = result == DialogResultYesNo.Yes;
}

View File

@@ -18,9 +18,9 @@ using SimpleToolkit.MVVM;
using System.Text.RegularExpressions;
using VDownload.Services.Utility.Filename;
using VDownload.Services.UI.Dialogs;
using VDownload.Services.UI.StringResources;
using CommunityToolkit.WinUI.Helpers;
using VDownload.Services.Data.Application;
using VDownload.Core.Strings;
namespace VDownload.Core.ViewModels.Home
{
@@ -34,7 +34,6 @@ namespace VDownload.Core.ViewModels.Home
protected readonly IStoragePickerService _storagePickerService;
protected readonly IFilenameService _filenameService;
protected readonly IDialogsService _dialogsService;
protected readonly IStringResourcesService _stringResourcesService;
protected readonly IApplicationDataService _applicationDataService;
#endregion
@@ -181,14 +180,13 @@ namespace VDownload.Core.ViewModels.Home
#region CONSTRUCTORS
public HomeVideoCollectionViewModel(IDownloadTaskManager tasksManager, ISettingsService settingsService, IStoragePickerService storagePickerService, IFilenameService filenameService, IDialogsService dialogsService, IStringResourcesService stringResourcesService, IApplicationDataService applicationDataService)
public HomeVideoCollectionViewModel(IDownloadTaskManager tasksManager, ISettingsService settingsService, IStoragePickerService storagePickerService, IFilenameService filenameService, IDialogsService dialogsService, IApplicationDataService applicationDataService)
{
_tasksManager = tasksManager;
_settingsService = settingsService;
_storagePickerService = storagePickerService;
_filenameService = filenameService;
_dialogsService = dialogsService;
_stringResourcesService = stringResourcesService;
_applicationDataService = applicationDataService;
_removedVideos = new List<VideoViewModel>();
@@ -306,8 +304,8 @@ namespace VDownload.Core.ViewModels.Home
NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection
)
{
string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle");
string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage");
string title = StringResourcesManager.Common.Get("StartAtMeteredConnectionDialogTitle");
string message = StringResourcesManager.Common.Get("StartAtMeteredConnectionDialogMessage");
DialogResultYesNo result = await _dialogsService.ShowYesNo(title, message);
download = result == DialogResultYesNo.Yes;
}

View File

@@ -8,13 +8,13 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VDownload.Core.Strings;
using VDownload.Core.Tasks;
using VDownload.Models;
using VDownload.Services.Data.Application;
using VDownload.Services.Data.Settings;
using VDownload.Services.UI.Dialogs;
using VDownload.Services.UI.StoragePicker;
using VDownload.Services.UI.StringResources;
using VDownload.Services.Utility.Filename;
namespace VDownload.Core.ViewModels.Home
@@ -29,7 +29,6 @@ namespace VDownload.Core.ViewModels.Home
protected readonly IStoragePickerService _storagePickerService;
protected readonly IFilenameService _filenameService;
protected readonly IDialogsService _dialogsService;
protected readonly IStringResourcesService _stringResourcesService;
protected readonly IApplicationDataService _applicationDataService;
#endregion
@@ -98,14 +97,13 @@ namespace VDownload.Core.ViewModels.Home
#region CONSTRUCTORS
public HomeVideoViewModel(IDownloadTaskManager tasksManager, ISettingsService settingsService, IStoragePickerService storagePickerService, IFilenameService filenameService, IDialogsService dialogsService, IStringResourcesService stringResourcesService, IApplicationDataService applicationDataService)
public HomeVideoViewModel(IDownloadTaskManager tasksManager, ISettingsService settingsService, IStoragePickerService storagePickerService, IFilenameService filenameService, IDialogsService dialogsService, IApplicationDataService applicationDataService)
{
_tasksManager = tasksManager;
_settingsService = settingsService;
_storagePickerService = storagePickerService;
_filenameService = filenameService;
_dialogsService = dialogsService;
_stringResourcesService = stringResourcesService;
_applicationDataService = applicationDataService;
}
@@ -184,8 +182,8 @@ namespace VDownload.Core.ViewModels.Home
NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection
)
{
string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle");
string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage");
string title = StringResourcesManager.Common.Get("StartAtMeteredConnectionDialogTitle");
string message = StringResourcesManager.Common.Get("StartAtMeteredConnectionDialogMessage");
DialogResultYesNo result = await _dialogsService.ShowYesNo(title, message);
download = result == DialogResultYesNo.Yes;
}

View File

@@ -7,13 +7,13 @@ using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using VDownload.Core.Strings;
using VDownload.Core.Tasks;
using VDownload.Models;
using VDownload.Services.Data.Configuration;
using VDownload.Services.Data.Settings;
using VDownload.Services.Data.Subscriptions;
using VDownload.Services.UI.Dialogs;
using VDownload.Services.UI.StringResources;
using VDownload.Sources;
using VDownload.Sources.Common;
using VDownload.Sources.Twitch.Configuration.Models;
@@ -45,7 +45,6 @@ namespace VDownload.Core.ViewModels.Home
protected readonly IConfigurationService _configurationService;
protected readonly ISettingsService _settingsService;
protected readonly IStringResourcesService _stringResourcesService;
protected readonly ISearchService _searchService;
protected readonly ISubscriptionsDataService _subscriptionsDataService;
protected readonly IDialogsService _dialogsService;
@@ -116,11 +115,10 @@ namespace VDownload.Core.ViewModels.Home
#region CONSTRUCTORS
public HomeViewModel(IConfigurationService configurationService, ISettingsService settingsService, IStringResourcesService stringResourcesService, ISearchService searchService, ISubscriptionsDataService subscriptionsDataService, IDialogsService dialogsService, IDownloadTaskManager downloadTaskManager, HomeVideoViewModel videoViewModel, HomeVideoCollectionViewModel videoCollectionViewModel)
public HomeViewModel(IConfigurationService configurationService, ISettingsService settingsService, ISearchService searchService, ISubscriptionsDataService subscriptionsDataService, IDialogsService dialogsService, IDownloadTaskManager downloadTaskManager, HomeVideoViewModel videoViewModel, HomeVideoCollectionViewModel videoCollectionViewModel)
{
_configurationService = configurationService;
_settingsService = settingsService;
_stringResourcesService = stringResourcesService;
_searchService = searchService;
_subscriptionsDataService = subscriptionsDataService;
_dialogsService = dialogsService;
@@ -181,7 +179,7 @@ namespace VDownload.Core.ViewModels.Home
StartSearch();
SubscriptionsVideoList subList = new SubscriptionsVideoList { Name = _stringResourcesService.CommonResources.Get("SubscriptionVideoListName") };
SubscriptionsVideoList subList = new SubscriptionsVideoList { Name = StringResourcesManager.Common.Get("SubscriptionVideoListName") };
List<Task> tasks = new List<Task>();
try
{
@@ -218,14 +216,14 @@ namespace VDownload.Core.ViewModels.Home
if (subList.Count > 0)
{
OptionBarMessage = $"{_stringResourcesService.HomeViewResources.Get("OptionBarMessageVideosFound")} {subList.Count}";
OptionBarMessage = $"{StringResourcesManager.HomeView.Get("OptionBarMessageVideosFound")} {subList.Count}";
_videoCollectionViewModel.LoadCollection(subList);
MainContent = _videoCollectionView;
}
else
{
OptionBarMessage = _stringResourcesService.HomeViewResources.Get("OptionBarMessageVideosNotFound");
OptionBarMessage = StringResourcesManager.HomeView.Get("OptionBarMessageVideosNotFound");
}
OptionBarSearchNotPending = true;
@@ -285,7 +283,7 @@ namespace VDownload.Core.ViewModels.Home
}
catch (MediaSearchException ex)
{
ShowError(_stringResourcesService.SearchResources.Get(ex.StringCode));
ShowError(StringResourcesManager.Search.Get(ex.StringCode));
return;
}
catch (Exception ex) when (ex is TaskCanceledException || ex is HttpRequestException)
@@ -321,7 +319,7 @@ namespace VDownload.Core.ViewModels.Home
}
catch (MediaSearchException ex)
{
ShowError(_stringResourcesService.SearchResources.Get(ex.StringCode));
ShowError(StringResourcesManager.Search.Get(ex.StringCode));
return;
}
catch (Exception ex) when (ex is TaskCanceledException || ex is HttpRequestException)
@@ -357,8 +355,8 @@ namespace VDownload.Core.ViewModels.Home
NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection
)
{
string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle");
string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage");
string title = StringResourcesManager.Common.Get("StartAtMeteredConnectionDialogTitle");
string message = StringResourcesManager.Common.Get("StartAtMeteredConnectionDialogMessage");
DialogResultYesNo result = await _dialogsService.ShowYesNo(title, message);
if (result == DialogResultYesNo.No)
{
@@ -417,14 +415,14 @@ namespace VDownload.Core.ViewModels.Home
{
OptionBarSearchNotPending = false;
OptionBarLoading = true;
OptionBarMessage = _stringResourcesService.HomeViewResources.Get("OptionBarMessageLoading");
OptionBarMessage = StringResourcesManager.HomeView.Get("OptionBarMessageLoading");
}
protected async void BackToDownload_EventHandler(object sender, EventArgs e) => await Navigation();
protected string ErrorNoInternetConnection() => _stringResourcesService.HomeViewResources.Get("ErrorInfoBarNoInternetConnection");
protected string ErrorNoInternetConnection() => StringResourcesManager.HomeView.Get("ErrorInfoBarNoInternetConnection");
protected string ErrorSearchTimeout() => _stringResourcesService.SearchResources.Get("SearchTimeout");
protected string ErrorSearchTimeout() => StringResourcesManager.Search.Get("SearchTimeout");
#endregion
}