metered connection warnings added
This commit is contained in:
@@ -0,0 +1,126 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<data name="StartAtMeteredConnectionDialogMessage" xml:space="preserve">
|
||||||
|
<value>You are trying to download a video using a metered connection. Do you want to continue?</value>
|
||||||
|
</data>
|
||||||
|
<data name="StartAtMeteredConnectionDialogTitle" xml:space="preserve">
|
||||||
|
<value>Warning</value>
|
||||||
|
</data>
|
||||||
|
</root>
|
||||||
@@ -7,6 +7,9 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using VDownload.Core.Tasks;
|
using VDownload.Core.Tasks;
|
||||||
|
using VDownload.Services.UI.Dialogs;
|
||||||
|
using VDownload.Services.UI.StringResources;
|
||||||
|
using VDownload.Services.Utility.Network;
|
||||||
|
|
||||||
namespace VDownload.Core.ViewModels.Home
|
namespace VDownload.Core.ViewModels.Home
|
||||||
{
|
{
|
||||||
@@ -16,6 +19,10 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
|
|
||||||
protected readonly IDownloadTaskManager _tasksManager;
|
protected readonly IDownloadTaskManager _tasksManager;
|
||||||
|
|
||||||
|
protected readonly INetworkService _networkService;
|
||||||
|
protected readonly IDialogsService _dialogsService;
|
||||||
|
protected readonly IStringResourcesService _stringResourcesService;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
@@ -33,11 +40,15 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
|
|
||||||
#region CONSTRUCTORS
|
#region CONSTRUCTORS
|
||||||
|
|
||||||
public HomeDownloadsViewModel(IDownloadTaskManager tasksManager)
|
public HomeDownloadsViewModel(IDownloadTaskManager tasksManager, INetworkService networkService, IDialogsService dialogsService, IStringResourcesService stringResourcesService)
|
||||||
{
|
{
|
||||||
_tasksManager = tasksManager;
|
_tasksManager = tasksManager;
|
||||||
_tasksManager.TaskCollectionChanged += Tasks_CollectionChanged;
|
_tasksManager.TaskCollectionChanged += Tasks_CollectionChanged;
|
||||||
|
|
||||||
|
_networkService = networkService;
|
||||||
|
_dialogsService = dialogsService;
|
||||||
|
_stringResourcesService = stringResourcesService;
|
||||||
|
|
||||||
_taskListIsEmpty = _tasksManager.Tasks.Count == 0;
|
_taskListIsEmpty = _tasksManager.Tasks.Count == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +70,19 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
];
|
];
|
||||||
if (idleStatuses.Contains(task.Status))
|
if (idleStatuses.Contains(task.Status))
|
||||||
{
|
{
|
||||||
task.Enqueue();
|
bool continueEnqueue = true;
|
||||||
|
if (_networkService.IsMetered)
|
||||||
|
{
|
||||||
|
string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle");
|
||||||
|
string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage");
|
||||||
|
DialogResultYesNo result = await _dialogsService.ShowYesNo(title, message);
|
||||||
|
continueEnqueue = result == DialogResultYesNo.Yes;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (continueEnqueue)
|
||||||
|
{
|
||||||
|
task.Enqueue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ using VDownload.Sources.Twitch.Configuration.Models;
|
|||||||
using SimpleToolkit.MVVM;
|
using SimpleToolkit.MVVM;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using VDownload.Services.Utility.Filename;
|
using VDownload.Services.Utility.Filename;
|
||||||
|
using VDownload.Services.UI.Dialogs;
|
||||||
|
using VDownload.Services.UI.StringResources;
|
||||||
|
using VDownload.Services.Utility.Network;
|
||||||
|
|
||||||
namespace VDownload.Core.ViewModels.Home
|
namespace VDownload.Core.ViewModels.Home
|
||||||
{
|
{
|
||||||
@@ -29,6 +32,9 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
protected readonly ISettingsService _settingsService;
|
protected readonly ISettingsService _settingsService;
|
||||||
protected readonly IStoragePickerService _storagePickerService;
|
protected readonly IStoragePickerService _storagePickerService;
|
||||||
protected readonly IFilenameService _filenameService;
|
protected readonly IFilenameService _filenameService;
|
||||||
|
protected readonly INetworkService _networkService;
|
||||||
|
protected readonly IDialogsService _dialogsService;
|
||||||
|
protected readonly IStringResourcesService _stringResourcesService;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -174,12 +180,15 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
|
|
||||||
#region CONSTRUCTORS
|
#region CONSTRUCTORS
|
||||||
|
|
||||||
public HomePlaylistViewModel(IDownloadTaskManager tasksManager, ISettingsService settingsService, IStoragePickerService storagePickerService, IFilenameService filenameService)
|
public HomePlaylistViewModel(IDownloadTaskManager tasksManager, ISettingsService settingsService, IStoragePickerService storagePickerService, IFilenameService filenameService, INetworkService networkService, IDialogsService dialogsService, IStringResourcesService stringResourcesService)
|
||||||
{
|
{
|
||||||
_tasksManager = tasksManager;
|
_tasksManager = tasksManager;
|
||||||
_settingsService = settingsService;
|
_settingsService = settingsService;
|
||||||
_storagePickerService = storagePickerService;
|
_storagePickerService = storagePickerService;
|
||||||
_filenameService = filenameService;
|
_filenameService = filenameService;
|
||||||
|
_networkService = networkService;
|
||||||
|
_dialogsService = dialogsService;
|
||||||
|
_stringResourcesService = stringResourcesService;
|
||||||
|
|
||||||
_removedVideos = new List<VideoViewModel>();
|
_removedVideos = new List<VideoViewModel>();
|
||||||
|
|
||||||
@@ -271,10 +280,10 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
public void CreateTasksAndDownload() => CreateTasks(true);
|
public async Task CreateTasksAndDownload() => await CreateTasks(true);
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
public void CreateTasks() => CreateTasks(false);
|
public async Task CreateTasks() => await CreateTasks(false);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -282,8 +291,16 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
|
|
||||||
#region PRIVATE METHODS
|
#region PRIVATE METHODS
|
||||||
|
|
||||||
protected void CreateTasks(bool download)
|
protected async Task CreateTasks(bool download)
|
||||||
{
|
{
|
||||||
|
if (download && _networkService.IsMetered)
|
||||||
|
{
|
||||||
|
string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle");
|
||||||
|
string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage");
|
||||||
|
DialogResultYesNo result = await _dialogsService.ShowYesNo(title, message);
|
||||||
|
download = result == DialogResultYesNo.Yes;
|
||||||
|
}
|
||||||
|
|
||||||
IEnumerable<VideoViewModel> videos = Videos.Cast<ObservableKeyValuePair<VideoViewModel, bool>>()
|
IEnumerable<VideoViewModel> videos = Videos.Cast<ObservableKeyValuePair<VideoViewModel, bool>>()
|
||||||
.Where(x => x.Value)
|
.Where(x => x.Value)
|
||||||
.Select(x => x.Key);
|
.Select(x => x.Key);
|
||||||
|
|||||||
@@ -10,8 +10,11 @@ using System.Threading.Tasks;
|
|||||||
using VDownload.Core.Tasks;
|
using VDownload.Core.Tasks;
|
||||||
using VDownload.Models;
|
using VDownload.Models;
|
||||||
using VDownload.Services.Data.Settings;
|
using VDownload.Services.Data.Settings;
|
||||||
|
using VDownload.Services.UI.Dialogs;
|
||||||
using VDownload.Services.UI.StoragePicker;
|
using VDownload.Services.UI.StoragePicker;
|
||||||
|
using VDownload.Services.UI.StringResources;
|
||||||
using VDownload.Services.Utility.Filename;
|
using VDownload.Services.Utility.Filename;
|
||||||
|
using VDownload.Services.Utility.Network;
|
||||||
|
|
||||||
namespace VDownload.Core.ViewModels.Home
|
namespace VDownload.Core.ViewModels.Home
|
||||||
{
|
{
|
||||||
@@ -24,6 +27,9 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
protected readonly ISettingsService _settingsService;
|
protected readonly ISettingsService _settingsService;
|
||||||
protected readonly IStoragePickerService _storagePickerService;
|
protected readonly IStoragePickerService _storagePickerService;
|
||||||
protected readonly IFilenameService _filenameService;
|
protected readonly IFilenameService _filenameService;
|
||||||
|
protected readonly INetworkService _networkService;
|
||||||
|
protected readonly IDialogsService _dialogsService;
|
||||||
|
protected readonly IStringResourcesService _stringResourcesService;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -91,12 +97,15 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
|
|
||||||
#region CONSTRUCTORS
|
#region CONSTRUCTORS
|
||||||
|
|
||||||
public HomeVideoViewModel(IDownloadTaskManager tasksManager, ISettingsService settingsService, IStoragePickerService storagePickerService, IFilenameService filenameService)
|
public HomeVideoViewModel(IDownloadTaskManager tasksManager, ISettingsService settingsService, IStoragePickerService storagePickerService, IFilenameService filenameService, INetworkService networkService, IDialogsService dialogsService, IStringResourcesService stringResourcesService)
|
||||||
{
|
{
|
||||||
_tasksManager = tasksManager;
|
_tasksManager = tasksManager;
|
||||||
_settingsService = settingsService;
|
_settingsService = settingsService;
|
||||||
_storagePickerService = storagePickerService;
|
_storagePickerService = storagePickerService;
|
||||||
_filenameService = filenameService;
|
_filenameService = filenameService;
|
||||||
|
_networkService = networkService;
|
||||||
|
_dialogsService = dialogsService;
|
||||||
|
_stringResourcesService = stringResourcesService;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -141,19 +150,10 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
public void CreateTask()
|
public async Task CreateTask() => await CreateTask(false);
|
||||||
{
|
|
||||||
_tasksManager.AddTask(_video, BuildDownloadOptions());
|
|
||||||
CloseRequested?.Invoke(this, EventArgs.Empty);
|
|
||||||
}
|
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
public void CreateTaskAndDownload()
|
public async Task CreateTaskAndDownload() => await CreateTask(true);
|
||||||
{
|
|
||||||
DownloadTask task = _tasksManager.AddTask(_video, BuildDownloadOptions());
|
|
||||||
CloseRequested?.Invoke(this, EventArgs.Empty);
|
|
||||||
task.Enqueue();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -161,6 +161,24 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
|
|
||||||
#region PRIVATE METHODS
|
#region PRIVATE METHODS
|
||||||
|
|
||||||
|
protected async Task CreateTask(bool download)
|
||||||
|
{
|
||||||
|
if (download && _networkService.IsMetered)
|
||||||
|
{
|
||||||
|
string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle");
|
||||||
|
string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage");
|
||||||
|
DialogResultYesNo result = await _dialogsService.ShowYesNo(title, message);
|
||||||
|
download = result == DialogResultYesNo.Yes;
|
||||||
|
}
|
||||||
|
|
||||||
|
DownloadTask task = _tasksManager.AddTask(_video, BuildDownloadOptions());
|
||||||
|
CloseRequested?.Invoke(this, EventArgs.Empty);
|
||||||
|
if (download)
|
||||||
|
{
|
||||||
|
task.Enqueue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected VideoDownloadOptions BuildDownloadOptions()
|
protected VideoDownloadOptions BuildDownloadOptions()
|
||||||
{
|
{
|
||||||
return new VideoDownloadOptions(Duration)
|
return new VideoDownloadOptions(Duration)
|
||||||
|
|||||||
@@ -9,9 +9,12 @@ using VDownload.Core.Tasks;
|
|||||||
using VDownload.Models;
|
using VDownload.Models;
|
||||||
using VDownload.Services.Data.Configuration;
|
using VDownload.Services.Data.Configuration;
|
||||||
using VDownload.Services.Data.Settings;
|
using VDownload.Services.Data.Settings;
|
||||||
|
using VDownload.Services.UI.Dialogs;
|
||||||
using VDownload.Services.UI.StringResources;
|
using VDownload.Services.UI.StringResources;
|
||||||
|
using VDownload.Services.Utility.Network;
|
||||||
using VDownload.Sources;
|
using VDownload.Sources;
|
||||||
using VDownload.Sources.Common;
|
using VDownload.Sources.Common;
|
||||||
|
using VDownload.Sources.Twitch.Configuration.Models;
|
||||||
|
|
||||||
namespace VDownload.Core.ViewModels.Home
|
namespace VDownload.Core.ViewModels.Home
|
||||||
{
|
{
|
||||||
@@ -49,6 +52,8 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
protected readonly ISettingsService _settingsService;
|
protected readonly ISettingsService _settingsService;
|
||||||
protected readonly IStringResourcesService _stringResourcesService;
|
protected readonly IStringResourcesService _stringResourcesService;
|
||||||
protected readonly ISearchService _searchService;
|
protected readonly ISearchService _searchService;
|
||||||
|
protected readonly INetworkService _networkService;
|
||||||
|
protected readonly IDialogsService _dialogsService;
|
||||||
|
|
||||||
protected readonly IDownloadTaskManager _downloadTaskManager;
|
protected readonly IDownloadTaskManager _downloadTaskManager;
|
||||||
|
|
||||||
@@ -108,12 +113,14 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
|
|
||||||
#region CONSTRUCTORS
|
#region CONSTRUCTORS
|
||||||
|
|
||||||
public HomeViewModel(IConfigurationService configurationService, ISettingsService settingsService, IStringResourcesService stringResourcesService, ISearchService searchService, IDownloadTaskManager downloadTaskManager, HomeVideoViewModel videoViewModel, HomePlaylistViewModel playlistViewModel)
|
public HomeViewModel(IConfigurationService configurationService, ISettingsService settingsService, IStringResourcesService stringResourcesService, ISearchService searchService, INetworkService networkService, IDialogsService dialogsService, IDownloadTaskManager downloadTaskManager, HomeVideoViewModel videoViewModel, HomePlaylistViewModel playlistViewModel)
|
||||||
{
|
{
|
||||||
_configurationService = configurationService;
|
_configurationService = configurationService;
|
||||||
_settingsService = settingsService;
|
_settingsService = settingsService;
|
||||||
_stringResourcesService = stringResourcesService;
|
_stringResourcesService = stringResourcesService;
|
||||||
_searchService = searchService;
|
_searchService = searchService;
|
||||||
|
_networkService = networkService;
|
||||||
|
_dialogsService = dialogsService;
|
||||||
|
|
||||||
_downloadTaskManager = downloadTaskManager;
|
_downloadTaskManager = downloadTaskManager;
|
||||||
|
|
||||||
@@ -258,8 +265,19 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
public void Download()
|
public async Task Download()
|
||||||
{
|
{
|
||||||
|
if (_downloadTaskManager.Tasks.Count > 0 && _networkService.IsMetered)
|
||||||
|
{
|
||||||
|
string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle");
|
||||||
|
string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage");
|
||||||
|
DialogResultYesNo result = await _dialogsService.ShowYesNo(title, message);
|
||||||
|
if (result == DialogResultYesNo.No)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach (DownloadTask task in _downloadTaskManager.Tasks)
|
foreach (DownloadTask task in _downloadTaskManager.Tasks)
|
||||||
{
|
{
|
||||||
task.Enqueue();
|
task.Enqueue();
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\VDownload.Services.Utility.Network\VDownload.Services.Utility.Network.csproj" />
|
||||||
<ProjectReference Include="..\..\VDownload.Services\VDownload.Services.Data\VDownload.Services.Data.Settings\VDownload.Services.Data.Settings.csproj" />
|
<ProjectReference Include="..\..\VDownload.Services\VDownload.Services.Data\VDownload.Services.Data.Settings\VDownload.Services.Data.Settings.csproj" />
|
||||||
<ProjectReference Include="..\..\VDownload.Services\VDownload.Services.UI\VDownload.Services.UI.Dialogs\VDownload.Services.UI.Dialogs.csproj" />
|
<ProjectReference Include="..\..\VDownload.Services\VDownload.Services.UI\VDownload.Services.UI.Dialogs\VDownload.Services.UI.Dialogs.csproj" />
|
||||||
<ProjectReference Include="..\..\VDownload.Services\VDownload.Services.UI\VDownload.Services.UI.DictionaryResources\VDownload.Services.UI.DictionaryResources.csproj" />
|
<ProjectReference Include="..\..\VDownload.Services\VDownload.Services.UI\VDownload.Services.UI.DictionaryResources\VDownload.Services.UI.DictionaryResources.csproj" />
|
||||||
|
|||||||
36
VDownload.Services.Utility.Network/NetworkService.cs
Normal file
36
VDownload.Services.Utility.Network/NetworkService.cs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Windows.Networking.Connectivity;
|
||||||
|
|
||||||
|
namespace VDownload.Services.Utility.Network
|
||||||
|
{
|
||||||
|
public interface INetworkService
|
||||||
|
{
|
||||||
|
bool IsMetered { get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class NetworkService : INetworkService
|
||||||
|
{
|
||||||
|
#region FIELDS
|
||||||
|
|
||||||
|
protected readonly IEnumerable<NetworkCostType> _notMeteredTypes = [
|
||||||
|
NetworkCostType.Unknown,
|
||||||
|
NetworkCostType.Unrestricted
|
||||||
|
];
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region PROPERTIES
|
||||||
|
|
||||||
|
public bool IsMetered => !_notMeteredTypes.Contains(NetworkInformation.GetInternetConnectionProfile().GetConnectionCost().NetworkCostType);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.22621.3233" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -13,6 +13,7 @@ namespace VDownload.Services.UI.StringResources
|
|||||||
StringResources AuthenticationViewResources { get; }
|
StringResources AuthenticationViewResources { get; }
|
||||||
StringResources NotificationsResources { get; }
|
StringResources NotificationsResources { get; }
|
||||||
StringResources SearchResources { get; }
|
StringResources SearchResources { get; }
|
||||||
|
StringResources CommonResources { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -37,6 +38,7 @@ namespace VDownload.Services.UI.StringResources
|
|||||||
public StringResources AuthenticationViewResources { get; protected set; }
|
public StringResources AuthenticationViewResources { get; protected set; }
|
||||||
public StringResources NotificationsResources { get; protected set; }
|
public StringResources NotificationsResources { get; protected set; }
|
||||||
public StringResources SearchResources { get; protected set; }
|
public StringResources SearchResources { get; protected set; }
|
||||||
|
public StringResources CommonResources { get; protected set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -56,6 +58,7 @@ namespace VDownload.Services.UI.StringResources
|
|||||||
AuthenticationViewResources = BuildResource("AuthenticationViewResources");
|
AuthenticationViewResources = BuildResource("AuthenticationViewResources");
|
||||||
NotificationsResources = BuildResource("NotificationsResources");
|
NotificationsResources = BuildResource("NotificationsResources");
|
||||||
SearchResources = BuildResource("SearchResources");
|
SearchResources = BuildResource("SearchResources");
|
||||||
|
CommonResources = BuildResource("CommonResources");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -69,7 +69,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VDownload.Core.Tasks", "VDo
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VDownload.Services.Utility.FFmpeg", "VDownload.Services\VDownload.Services.Utility\VDownload.Services.Utility.FFmpeg\VDownload.Services.Utility.FFmpeg.csproj", "{A3166F8A-ECAD-4D4B-9BE3-96FEC799B27B}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VDownload.Services.Utility.FFmpeg", "VDownload.Services\VDownload.Services.Utility\VDownload.Services.Utility.FFmpeg\VDownload.Services.Utility.FFmpeg.csproj", "{A3166F8A-ECAD-4D4B-9BE3-96FEC799B27B}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VDownload.Services.Utility.Filename", "VDownload.Services\VDownload.Services.Utility\VDownload.Services.Utility.Filename\VDownload.Services.Utility.Filename.csproj", "{4647EFB5-A206-4F47-976D-BAED11B52579}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VDownload.Services.Utility.Filename", "VDownload.Services\VDownload.Services.Utility\VDownload.Services.Utility.Filename\VDownload.Services.Utility.Filename.csproj", "{4647EFB5-A206-4F47-976D-BAED11B52579}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VDownload.Services.Utility.Network", "VDownload.Services.Utility.Network\VDownload.Services.Utility.Network.csproj", "{08AEC43D-34C3-4B19-A577-B69FF755BD7F}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@@ -521,6 +523,22 @@ Global
|
|||||||
{4647EFB5-A206-4F47-976D-BAED11B52579}.Release|x64.Build.0 = Release|Any CPU
|
{4647EFB5-A206-4F47-976D-BAED11B52579}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{4647EFB5-A206-4F47-976D-BAED11B52579}.Release|x86.ActiveCfg = Release|Any CPU
|
{4647EFB5-A206-4F47-976D-BAED11B52579}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{4647EFB5-A206-4F47-976D-BAED11B52579}.Release|x86.Build.0 = Release|Any CPU
|
{4647EFB5-A206-4F47-976D-BAED11B52579}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||||
|
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||||
|
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||||
|
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Release|ARM64.Build.0 = Release|Any CPU
|
||||||
|
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{08AEC43D-34C3-4B19-A577-B69FF755BD7F}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -555,6 +573,7 @@ Global
|
|||||||
{3BE998A3-1126-4496-BF60-80D0CEA4D24F} = {8539067C-9968-4AEB-928C-FEDC43989A79}
|
{3BE998A3-1126-4496-BF60-80D0CEA4D24F} = {8539067C-9968-4AEB-928C-FEDC43989A79}
|
||||||
{A3166F8A-ECAD-4D4B-9BE3-96FEC799B27B} = {1020167A-4101-496E-82CF-41B65769DD28}
|
{A3166F8A-ECAD-4D4B-9BE3-96FEC799B27B} = {1020167A-4101-496E-82CF-41B65769DD28}
|
||||||
{4647EFB5-A206-4F47-976D-BAED11B52579} = {1020167A-4101-496E-82CF-41B65769DD28}
|
{4647EFB5-A206-4F47-976D-BAED11B52579} = {1020167A-4101-496E-82CF-41B65769DD28}
|
||||||
|
{08AEC43D-34C3-4B19-A577-B69FF755BD7F} = {1020167A-4101-496E-82CF-41B65769DD28}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {9FD7B842-C3E2-4FD0-AD8A-C8E619280AB7}
|
SolutionGuid = {9FD7B842-C3E2-4FD0-AD8A-C8E619280AB7}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ using VDownload.Services.Utility.Encryption;
|
|||||||
using VDownload.Services.Utility.FFmpeg;
|
using VDownload.Services.Utility.FFmpeg;
|
||||||
using VDownload.Services.Utility.Filename;
|
using VDownload.Services.Utility.Filename;
|
||||||
using VDownload.Services.Utility.HttpClient;
|
using VDownload.Services.Utility.HttpClient;
|
||||||
|
using VDownload.Services.Utility.Network;
|
||||||
using VDownload.Sources;
|
using VDownload.Sources;
|
||||||
using VDownload.Sources.Twitch;
|
using VDownload.Sources.Twitch;
|
||||||
using VDownload.Sources.Twitch.Api;
|
using VDownload.Sources.Twitch.Api;
|
||||||
@@ -122,6 +123,7 @@ namespace VDownload
|
|||||||
services.AddSingleton<IHttpClientService, HttpClientService>();
|
services.AddSingleton<IHttpClientService, HttpClientService>();
|
||||||
services.AddSingleton<IFFmpegService, FFmpegService>();
|
services.AddSingleton<IFFmpegService, FFmpegService>();
|
||||||
services.AddSingleton<IFilenameService, FilenameService>();
|
services.AddSingleton<IFilenameService, FilenameService>();
|
||||||
|
services.AddSingleton<INetworkService, NetworkService>();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void BuildSourcesServices(IServiceCollection services)
|
protected void BuildSourcesServices(IServiceCollection services)
|
||||||
|
|||||||
@@ -170,6 +170,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\VDownload.Core\VDownload.Core.ViewModels\VDownload.Core.ViewModels.csproj" />
|
<ProjectReference Include="..\VDownload.Core\VDownload.Core.ViewModels\VDownload.Core.ViewModels.csproj" />
|
||||||
<ProjectReference Include="..\VDownload.Core\VDownload.Core.Views\VDownload.Core.Views.csproj" />
|
<ProjectReference Include="..\VDownload.Core\VDownload.Core.Views\VDownload.Core.Views.csproj" />
|
||||||
|
<ProjectReference Include="..\VDownload.Services.Utility.Network\VDownload.Services.Utility.Network.csproj" />
|
||||||
<ProjectReference Include="..\VDownload.Services\VDownload.Services.Data\VDownload.Services.Data.Authentication\VDownload.Services.Data.Authentication.csproj" />
|
<ProjectReference Include="..\VDownload.Services\VDownload.Services.Data\VDownload.Services.Data.Authentication\VDownload.Services.Data.Authentication.csproj" />
|
||||||
<ProjectReference Include="..\VDownload.Services\VDownload.Services.Data\VDownload.Services.Data.Configuration\VDownload.Services.Data.Configuration.csproj" />
|
<ProjectReference Include="..\VDownload.Services\VDownload.Services.Data\VDownload.Services.Data.Configuration\VDownload.Services.Data.Configuration.csproj" />
|
||||||
<ProjectReference Include="..\VDownload.Services\VDownload.Services.Data\VDownload.Services.Data.Settings\VDownload.Services.Data.Settings.csproj" />
|
<ProjectReference Include="..\VDownload.Services\VDownload.Services.Data\VDownload.Services.Data.Settings\VDownload.Services.Data.Settings.csproj" />
|
||||||
|
|||||||
Reference in New Issue
Block a user