1.0-dev13 (Scheduling feature added, warnings about metered connection added, tasks list placeholder added)
This commit is contained in:
@@ -35,7 +35,9 @@ namespace VDownload.Core.Services
|
|||||||
{ "remove_task_when_successfully_ended", false },
|
{ "remove_task_when_successfully_ended", false },
|
||||||
{ "delete_task_temp_when_ended_with_error", false },
|
{ "delete_task_temp_when_ended_with_error", false },
|
||||||
{ "show_notification_when_task_ended_successfully", false },
|
{ "show_notification_when_task_ended_successfully", false },
|
||||||
{ "show_notification_when_task_ended_unsuccessfully", false }
|
{ "show_notification_when_task_ended_unsuccessfully", false },
|
||||||
|
{ "show_warning_when_task_starts_on_metered_network", true },
|
||||||
|
{ "delay_task_when_queued_task_starts_on_metered_network", true }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 1600 1600">
|
||||||
|
<g id="surface103053526" transform="matrix(1.14286,0,0,1.14286,-114.286,-114.286)">
|
||||||
|
<path d="M283.332,233.332C182.676,233.332 100,316.008 100,416.668L100,1183.33C100,1283.99 182.676,1366.67 283.332,1366.67L1316.67,1366.67C1417.32,1366.67 1500,1283.99 1500,1183.33L1500,416.668C1500,316.008 1417.32,233.332 1316.67,233.332L283.332,233.332ZM283.332,333.332L1316.67,333.332C1363.27,333.332 1400,370.059 1400,416.668L1400,1183.33C1400,1229.94 1363.27,1266.67 1316.67,1266.67L283.332,1266.67C236.727,1266.67 200,1229.94 200,1183.33L200,416.668C200,370.059 236.727,333.332 283.332,333.332ZM699.152,566.668C687.734,566.813 676.379,569.863 666.211,575.848C645.844,587.848 633.332,609.734 633.332,633.332L633.332,966.668C633.332,990.266 645.844,1012.15 666.211,1024.15C676.609,1030.29 688.301,1033.33 700,1033.33C711.133,1033.33 722.289,1030.5 732.355,1024.93L1032.36,858.27C1053.52,846.5 1066.67,824.234 1066.67,800C1066.67,775.766 1053.52,753.5 1032.36,741.73L732.355,575.066C722.039,569.332 710.574,566.52 699.152,566.668Z" style="fill:rgb(170,170,170);fill-rule:nonzero;"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 154 KiB After Width: | Height: | Size: 50 KiB |
@@ -11,4 +11,5 @@
|
|||||||
<SolidColorBrush x:Key="HomeOptionBarBackgroundColor" Color="#1B1B1B"/>
|
<SolidColorBrush x:Key="HomeOptionBarBackgroundColor" Color="#1B1B1B"/>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</ResourceDictionary.ThemeDictionaries>
|
</ResourceDictionary.ThemeDictionaries>
|
||||||
|
<SolidColorBrush x:Key="HomeTasksListPlaceholderTextColor" Color="#AAAAAA"/>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
|
|||||||
@@ -2,4 +2,5 @@
|
|||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
<BitmapImage x:Name="UnknownThumbnailImage" UriSource="ms-appx:///Assets/Images/UnknownThumbnail.png"/>
|
<BitmapImage x:Name="UnknownThumbnailImage" UriSource="ms-appx:///Assets/Images/UnknownThumbnail.png"/>
|
||||||
|
<SvgImageSource x:Name="HomeTasksListPlaceholderImage" UriSource="ms-appx:///Assets/Images/HomeTasksListPlaceholderImage.svg"/>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
|
|||||||
@@ -120,6 +120,21 @@
|
|||||||
<data name="CloseErrorDialogButtonText" xml:space="preserve">
|
<data name="CloseErrorDialogButtonText" xml:space="preserve">
|
||||||
<value>OK</value>
|
<value>OK</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="HomeDownloadAllButtonMeteredConnectionDialogCancel" xml:space="preserve">
|
||||||
|
<value>No</value>
|
||||||
|
</data>
|
||||||
|
<data name="HomeDownloadAllButtonMeteredConnectionDialogDescription" xml:space="preserve">
|
||||||
|
<value>You are on the metered connection now. You can delay tasks until the network changes. Do you want to start the tasks?</value>
|
||||||
|
</data>
|
||||||
|
<data name="HomeDownloadAllButtonMeteredConnectionDialogStartAndDelayText" xml:space="preserve">
|
||||||
|
<value>Yes (With delay)</value>
|
||||||
|
</data>
|
||||||
|
<data name="HomeDownloadAllButtonMeteredConnectionDialogStartWithoutDelayText" xml:space="preserve">
|
||||||
|
<value>Yes (Without delay)</value>
|
||||||
|
</data>
|
||||||
|
<data name="HomeDownloadAllButtonMeteredConnectionDialogTitle" xml:space="preserve">
|
||||||
|
<value>Metered connection detected</value>
|
||||||
|
</data>
|
||||||
<data name="HomeOptionsBarAddPlaylistButton.Label" xml:space="preserve">
|
<data name="HomeOptionsBarAddPlaylistButton.Label" xml:space="preserve">
|
||||||
<value>Add playlist</value>
|
<value>Add playlist</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -217,9 +232,30 @@ The number in the numberbox indicades how many videos will be got from playlist.
|
|||||||
<data name="HomeTaskPanelStateTextProcessing" xml:space="preserve">
|
<data name="HomeTaskPanelStateTextProcessing" xml:space="preserve">
|
||||||
<value>Processing</value>
|
<value>Processing</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="HomeTaskPanelStateTextScheduled" xml:space="preserve">
|
||||||
|
<value>Scheduled</value>
|
||||||
|
</data>
|
||||||
<data name="HomeTaskPanelStateTextWaiting" xml:space="preserve">
|
<data name="HomeTaskPanelStateTextWaiting" xml:space="preserve">
|
||||||
<value>Queued</value>
|
<value>Queued</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="HomeTaskPanelTaskStartMeteredConnectionDialogCancel" xml:space="preserve">
|
||||||
|
<value>No</value>
|
||||||
|
</data>
|
||||||
|
<data name="HomeTaskPanelTaskStartMeteredConnectionDialogDescription" xml:space="preserve">
|
||||||
|
<value>You are on the metered connection now. You can delay task until the network changes. Do you want to start the task?</value>
|
||||||
|
</data>
|
||||||
|
<data name="HomeTaskPanelTaskStartMeteredConnectionDialogStartAndDelayText" xml:space="preserve">
|
||||||
|
<value>Yes (With delay)</value>
|
||||||
|
</data>
|
||||||
|
<data name="HomeTaskPanelTaskStartMeteredConnectionDialogStartWithoutDelayText" xml:space="preserve">
|
||||||
|
<value>Yes (Without delay)</value>
|
||||||
|
</data>
|
||||||
|
<data name="HomeTaskPanelTaskStartMeteredConnectionDialogTitle" xml:space="preserve">
|
||||||
|
<value>Metered connection detected</value>
|
||||||
|
</data>
|
||||||
|
<data name="HomeTasksListPlaceholderTextBlock.Text" xml:space="preserve">
|
||||||
|
<value>Click "Add video/playlist" button to start</value>
|
||||||
|
</data>
|
||||||
<data name="HomeVideoAddingDownloadingOptionsHeaderTextBlock.Text" xml:space="preserve">
|
<data name="HomeVideoAddingDownloadingOptionsHeaderTextBlock.Text" xml:space="preserve">
|
||||||
<value>Downloading options</value>
|
<value>Downloading options</value>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@@ -137,6 +137,9 @@
|
|||||||
<Compile Include="Views\Home\HomeMain.xaml.cs">
|
<Compile Include="Views\Home\HomeMain.xaml.cs">
|
||||||
<DependentUpon>HomeMain.xaml</DependentUpon>
|
<DependentUpon>HomeMain.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Views\Home\HomeTasksListPlaceholder.xaml.cs">
|
||||||
|
<DependentUpon>HomeTasksListPlaceholder.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Views\Home\HomeVideoAddingPanel.xaml.cs">
|
<Compile Include="Views\Home\HomeVideoAddingPanel.xaml.cs">
|
||||||
<DependentUpon>HomeVideoAddingPanel.xaml</DependentUpon>
|
<DependentUpon>HomeVideoAddingPanel.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -202,6 +205,8 @@
|
|||||||
<Content Include="Assets\Icons\Twitch.svg" />
|
<Content Include="Assets\Icons\Twitch.svg" />
|
||||||
<Content Include="Assets\Icons\ViewsDark.svg" />
|
<Content Include="Assets\Icons\ViewsDark.svg" />
|
||||||
<Content Include="Assets\Icons\ViewsLight.svg" />
|
<Content Include="Assets\Icons\ViewsLight.svg" />
|
||||||
|
<Content Include="Assets\Images\HomeTasksListPlaceholderImage.svg" />
|
||||||
|
<Content Include="Assets\Images\UnknownThumbnail.png" />
|
||||||
<Content Include="Assets\Logo\Logo.png" />
|
<Content Include="Assets\Logo\Logo.png" />
|
||||||
<Content Include="Assets\Logo\LargeTile.scale-100.png" />
|
<Content Include="Assets\Logo\LargeTile.scale-100.png" />
|
||||||
<Content Include="Assets\Logo\LargeTile.scale-125.png" />
|
<Content Include="Assets\Logo\LargeTile.scale-125.png" />
|
||||||
@@ -253,7 +258,6 @@
|
|||||||
<Content Include="Assets\Logo\Wide310x150Logo.scale-150.png" />
|
<Content Include="Assets\Logo\Wide310x150Logo.scale-150.png" />
|
||||||
<Content Include="Assets\Logo\Wide310x150Logo.scale-200.png" />
|
<Content Include="Assets\Logo\Wide310x150Logo.scale-200.png" />
|
||||||
<Content Include="Assets\Logo\Wide310x150Logo.scale-400.png" />
|
<Content Include="Assets\Logo\Wide310x150Logo.scale-400.png" />
|
||||||
<Content Include="Assets\Images\UnknownThumbnail.png" />
|
|
||||||
<Content Include="Assets\Sources\Twitch.png" />
|
<Content Include="Assets\Sources\Twitch.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -297,6 +301,10 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="Views\Home\HomeTasksListPlaceholder.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="Views\Home\HomeVideoAddingPanel.xaml">
|
<Page Include="Views\Home\HomeVideoAddingPanel.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
@@ -326,6 +334,9 @@
|
|||||||
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
|
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
|
||||||
<Version>6.2.13</Version>
|
<Version>6.2.13</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.Toolkit.Uwp.Connectivity">
|
||||||
|
<Version>7.1.2</Version>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications">
|
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications">
|
||||||
<Version>7.1.2</Version>
|
<Version>7.1.2</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
|
|
||||||
<!-- VIDEOS LIST -->
|
<!-- VIDEOS LIST -->
|
||||||
<ScrollViewer Margin="0,0,0,10" CornerRadius="{ThemeResource ControlCornerRadius}">
|
<ScrollViewer Margin="0,0,0,10" CornerRadius="{ThemeResource ControlCornerRadius}">
|
||||||
<StackPanel x:Name="HomeTasksList" Spacing="10"/>
|
<ContentControl x:Name="HomeTasksListPlace" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"/>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
|
|
||||||
<!-- OPTIONS BAR AND ADDING PANEL -->
|
<!-- OPTIONS BAR AND ADDING PANEL -->
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
<RowDefinition/>
|
<RowDefinition/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<ContentControl x:Name="HomeAddingPanel" Grid.Row="0" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"/> <!-- Adding Panel -->
|
<ContentControl x:Name="HomeAddingPanel" Grid.Row="0" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"/> <!-- Adding Panel -->
|
||||||
<Grid x:Name="HomeOptionsBar" Grid.Row="1" Background="{ThemeResource HomeOptionBarBackgroundColor}"> <!-- Options Bar -->
|
<Grid x:Name="HomeOptionsBar" Grid.Row="1" Background="{ThemeResource HomeOptionBarBackgroundColor}"> <!-- Options Bar -->
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using Microsoft.Toolkit.Uwp.Connectivity;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -40,8 +41,12 @@ namespace VDownload.Views.Home
|
|||||||
// CANCELLATON TOKEN
|
// CANCELLATON TOKEN
|
||||||
private CancellationTokenSource SearchingCancellationToken = new CancellationTokenSource();
|
private CancellationTokenSource SearchingCancellationToken = new CancellationTokenSource();
|
||||||
|
|
||||||
|
// HOME TASKS LIST PLACEHOLDER
|
||||||
|
private readonly HomeTasksListPlaceholder HomeTasksListPlaceholder = new HomeTasksListPlaceholder();
|
||||||
|
|
||||||
// HOME VIDEOS LIST
|
// HOME VIDEOS LIST
|
||||||
private static StackPanel HomeTasksListParent = null;
|
private static ContentControl HomeTasksListPlaceCurrent = null;
|
||||||
|
private static StackPanel HomeTasksList = null;
|
||||||
public static List<HomeTaskPanel> TaskPanelsList = new List<HomeTaskPanel>();
|
public static List<HomeTaskPanel> TaskPanelsList = new List<HomeTaskPanel>();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -53,9 +58,18 @@ namespace VDownload.Views.Home
|
|||||||
// ON NAVIGATED TO
|
// ON NAVIGATED TO
|
||||||
protected override async void OnNavigatedTo(NavigationEventArgs e)
|
protected override async void OnNavigatedTo(NavigationEventArgs e)
|
||||||
{
|
{
|
||||||
if (HomeTasksListParent != null) HomeTasksListParent.Children.Clear();
|
HomeTasksListPlaceCurrent = HomeTasksListPlace;
|
||||||
HomeTasksListParent = HomeTasksList;
|
if (HomeTasksList != null) HomeTasksList.Children.Clear();
|
||||||
foreach (HomeTaskPanel homeVideoPanel in TaskPanelsList) HomeTasksList.Children.Add(homeVideoPanel);
|
HomeTasksList = new StackPanel { Spacing = 10 };
|
||||||
|
if (TaskPanelsList.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (HomeTaskPanel homeVideoPanel in TaskPanelsList) HomeTasksList.Children.Add(homeVideoPanel);
|
||||||
|
HomeTasksListPlace.Content = HomeTasksList;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HomeTasksListPlace.Content = HomeTasksListPlaceholder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ADD VIDEO BUTTON CHECKED
|
// ADD VIDEO BUTTON CHECKED
|
||||||
@@ -73,6 +87,9 @@ namespace VDownload.Views.Home
|
|||||||
// ADD VIDEO SEARCH BUTTON CLICKED
|
// ADD VIDEO SEARCH BUTTON CLICKED
|
||||||
private async void HomeOptionsBarAddVideoControl_SearchButtonClicked(object sender, VideoSearchEventArgs e)
|
private async void HomeOptionsBarAddVideoControl_SearchButtonClicked(object sender, VideoSearchEventArgs e)
|
||||||
{
|
{
|
||||||
|
HomeOptionBarAndAddingPanelRow.Height = GridLength.Auto;
|
||||||
|
HomeTasksListRow.Height = new GridLength(1, GridUnitType.Star);
|
||||||
|
|
||||||
HomeAddingPanel.Content = null;
|
HomeAddingPanel.Content = null;
|
||||||
|
|
||||||
// Cancel previous operations
|
// Cancel previous operations
|
||||||
@@ -166,6 +183,9 @@ namespace VDownload.Views.Home
|
|||||||
|
|
||||||
private void HomeVideoAddingPanel_VideoAddRequest(object sender, VideoAddEventArgs e)
|
private void HomeVideoAddingPanel_VideoAddRequest(object sender, VideoAddEventArgs e)
|
||||||
{
|
{
|
||||||
|
// Replace placeholder
|
||||||
|
HomeTasksListPlace.Content = HomeTasksList;
|
||||||
|
|
||||||
// Uncheck video button
|
// Uncheck video button
|
||||||
HomeOptionsBarAddVideoButton.IsChecked = false;
|
HomeOptionsBarAddVideoButton.IsChecked = false;
|
||||||
|
|
||||||
@@ -177,6 +197,7 @@ namespace VDownload.Views.Home
|
|||||||
// Remove task from tasks lists
|
// Remove task from tasks lists
|
||||||
TaskPanelsList.Remove(taskPanel);
|
TaskPanelsList.Remove(taskPanel);
|
||||||
HomeTasksList.Children.Remove(taskPanel);
|
HomeTasksList.Children.Remove(taskPanel);
|
||||||
|
if (TaskPanelsList.Count <= 0) HomeTasksListPlace.Content = HomeTasksListPlaceholder;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add task to tasks lists
|
// Add task to tasks lists
|
||||||
@@ -297,10 +318,30 @@ namespace VDownload.Views.Home
|
|||||||
// DOWNLOAD ALL BUTTON CLICKED
|
// DOWNLOAD ALL BUTTON CLICKED
|
||||||
private async void HomeOptionsBarDownloadAllButton_Click(object sender, RoutedEventArgs e)
|
private async void HomeOptionsBarDownloadAllButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
foreach (HomeTaskPanel videoPanel in HomeTasksList.Children.Where((object video) => ((HomeTaskPanel)video).TaskStatus == Core.Enums.TaskStatus.Idle))
|
HomeTaskPanel[] idleTasks = TaskPanelsList.Where((HomeTaskPanel video) => video.TaskStatus == Core.Enums.TaskStatus.Idle).ToArray();
|
||||||
|
if (idleTasks.Count() > 0)
|
||||||
{
|
{
|
||||||
await Task.Delay(50);
|
bool delay = (bool)Config.GetValue("delay_task_when_queued_task_starts_on_metered_network");
|
||||||
videoPanel.Start();
|
ContentDialogResult dialogResult = await new ContentDialog
|
||||||
|
{
|
||||||
|
Title = ResourceLoader.GetForCurrentView().GetString("HomeDownloadAllButtonMeteredConnectionDialogTitle"),
|
||||||
|
Content = ResourceLoader.GetForCurrentView().GetString("HomeDownloadAllButtonMeteredConnectionDialogDescription"),
|
||||||
|
PrimaryButtonText = ResourceLoader.GetForCurrentView().GetString("HomeDownloadAllButtonMeteredConnectionDialogStartAndDelayText"),
|
||||||
|
SecondaryButtonText = ResourceLoader.GetForCurrentView().GetString("HomeDownloadAllButtonMeteredConnectionDialogStartWithoutDelayText"),
|
||||||
|
CloseButtonText = ResourceLoader.GetForCurrentView().GetString("HomeDownloadAllButtonMeteredConnectionDialogCancel"),
|
||||||
|
}.ShowAsync();
|
||||||
|
switch (dialogResult)
|
||||||
|
{
|
||||||
|
case ContentDialogResult.Primary: delay = true; break;
|
||||||
|
case ContentDialogResult.Secondary: delay = false; break;
|
||||||
|
case ContentDialogResult.None: return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (HomeTaskPanel videoPanel in idleTasks)
|
||||||
|
{
|
||||||
|
await Task.Delay(50);
|
||||||
|
videoPanel.Start(delay);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,11 +352,11 @@ namespace VDownload.Views.Home
|
|||||||
#region METHODS
|
#region METHODS
|
||||||
|
|
||||||
// WAIT IN QUEUE
|
// WAIT IN QUEUE
|
||||||
public static async Task WaitInQueue(CancellationToken token)
|
public static async Task WaitInQueue(bool delayWhenOnMeteredConnection, CancellationToken token)
|
||||||
{
|
{
|
||||||
while (TaskPanelsList.Where((HomeTaskPanel video) => video.TaskStatus == Core.Enums.TaskStatus.InProgress).Count() >= (int)Config.GetValue("max_active_video_task") && !token.IsCancellationRequested)
|
while ((TaskPanelsList.Where((HomeTaskPanel video) => video.TaskStatus == Core.Enums.TaskStatus.InProgress).Count() >= (int)Config.GetValue("max_active_video_task") || (delayWhenOnMeteredConnection && NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection)) && !token.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
await Task.Delay(50);
|
await Task.Delay(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Microsoft.Toolkit.Uwp.Notifications;
|
using Microsoft.Toolkit.Uwp.Notifications;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@@ -113,7 +114,7 @@ namespace VDownload.Views.Home
|
|||||||
|
|
||||||
#region METHODS
|
#region METHODS
|
||||||
|
|
||||||
public async Task Start()
|
public async Task Start(bool delayWhenOnMeteredConnection)
|
||||||
{
|
{
|
||||||
// Change icon
|
// Change icon
|
||||||
HomeTaskPanelStartStopButton.Icon = new SymbolIcon(Symbol.Stop);
|
HomeTaskPanelStartStopButton.Icon = new SymbolIcon(Symbol.Stop);
|
||||||
@@ -121,6 +122,22 @@ namespace VDownload.Views.Home
|
|||||||
// Create cancellation token
|
// Create cancellation token
|
||||||
CancellationTokenSource = new CancellationTokenSource();
|
CancellationTokenSource = new CancellationTokenSource();
|
||||||
|
|
||||||
|
// Scheduling
|
||||||
|
if (Schedule > 0)
|
||||||
|
{
|
||||||
|
DateTime ScheduledDateTime = DateTime.Now.AddMinutes(Schedule);
|
||||||
|
|
||||||
|
// Set task status
|
||||||
|
TaskStatus = Core.Enums.TaskStatus.Scheduled;
|
||||||
|
|
||||||
|
// Set state controls
|
||||||
|
HomeTaskPanelStateIcon.Source = (SvgImageSource)IconsRes["StateScheduledIcon"];
|
||||||
|
HomeTaskPanelStateText.Text = $"{ResourceLoader.GetForCurrentView().GetString("HomeTaskPanelStateTextScheduled")} ({ScheduledDateTime.ToString(CultureInfo.InstalledUICulture.DateTimeFormat.ShortDatePattern)} {ScheduledDateTime.ToString(CultureInfo.InstalledUICulture.DateTimeFormat.ShortTimePattern)})";
|
||||||
|
HomeTaskPanelStateProgressBar.Visibility = Visibility.Collapsed;
|
||||||
|
|
||||||
|
while (DateTime.Now < ScheduledDateTime && !CancellationTokenSource.IsCancellationRequested) await Task.Delay(100);
|
||||||
|
}
|
||||||
|
|
||||||
// Set task status
|
// Set task status
|
||||||
TaskStatus = Core.Enums.TaskStatus.Waiting;
|
TaskStatus = Core.Enums.TaskStatus.Waiting;
|
||||||
|
|
||||||
@@ -131,7 +148,7 @@ namespace VDownload.Views.Home
|
|||||||
HomeTaskPanelStateProgressBar.IsIndeterminate = true;
|
HomeTaskPanelStateProgressBar.IsIndeterminate = true;
|
||||||
|
|
||||||
// Wait in queue
|
// Wait in queue
|
||||||
await HomeMain.WaitInQueue(CancellationTokenSource.Token);
|
await HomeMain.WaitInQueue(delayWhenOnMeteredConnection, CancellationTokenSource.Token);
|
||||||
if (!CancellationTokenSource.IsCancellationRequested)
|
if (!CancellationTokenSource.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
// Set task status
|
// Set task status
|
||||||
@@ -280,6 +297,9 @@ namespace VDownload.Views.Home
|
|||||||
HomeTaskPanelStateIcon.Source = (SvgImageSource)IconsRes["StateCancelledIcon"];
|
HomeTaskPanelStateIcon.Source = (SvgImageSource)IconsRes["StateCancelledIcon"];
|
||||||
HomeTaskPanelStateText.Text = ResourceLoader.GetForCurrentView().GetString("HomeTaskPanelStateTextCancelled");
|
HomeTaskPanelStateText.Text = ResourceLoader.GetForCurrentView().GetString("HomeTaskPanelStateTextCancelled");
|
||||||
HomeTaskPanelStateProgressBar.Visibility = Visibility.Collapsed;
|
HomeTaskPanelStateProgressBar.Visibility = Visibility.Collapsed;
|
||||||
|
|
||||||
|
// Change icon
|
||||||
|
HomeTaskPanelStartStopButton.Icon = new SymbolIcon(Symbol.Download);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,7 +320,25 @@ namespace VDownload.Views.Home
|
|||||||
private async void HomeTaskPanelStartStopButton_Click(object sender, RoutedEventArgs e)
|
private async void HomeTaskPanelStartStopButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (TaskStatus == Core.Enums.TaskStatus.InProgress || TaskStatus == Core.Enums.TaskStatus.Waiting || TaskStatus == Core.Enums.TaskStatus.Scheduled) CancellationTokenSource.Cancel();
|
if (TaskStatus == Core.Enums.TaskStatus.InProgress || TaskStatus == Core.Enums.TaskStatus.Waiting || TaskStatus == Core.Enums.TaskStatus.Scheduled) CancellationTokenSource.Cancel();
|
||||||
else await Start();
|
else
|
||||||
|
{
|
||||||
|
bool delay = (bool)Config.GetValue("delay_task_when_queued_task_starts_on_metered_network");
|
||||||
|
ContentDialogResult dialogResult = await new ContentDialog
|
||||||
|
{
|
||||||
|
Title = ResourceLoader.GetForCurrentView().GetString("HomeTaskPanelTaskStartMeteredConnectionDialogTitle"),
|
||||||
|
Content = ResourceLoader.GetForCurrentView().GetString("HomeTaskPanelTaskStartMeteredConnectionDialogDescription"),
|
||||||
|
PrimaryButtonText = ResourceLoader.GetForCurrentView().GetString("HomeTaskPanelTaskStartMeteredConnectionDialogStartAndDelayText"),
|
||||||
|
SecondaryButtonText = ResourceLoader.GetForCurrentView().GetString("HomeTaskPanelTaskStartMeteredConnectionDialogStartWithoutDelayText"),
|
||||||
|
CloseButtonText = ResourceLoader.GetForCurrentView().GetString("HomeTaskPanelTaskStartMeteredConnectionDialogCancel"),
|
||||||
|
}.ShowAsync();
|
||||||
|
switch (dialogResult)
|
||||||
|
{
|
||||||
|
case ContentDialogResult.Primary: delay = true; break;
|
||||||
|
case ContentDialogResult.Secondary: delay = false; break;
|
||||||
|
case ContentDialogResult.None: return;
|
||||||
|
}
|
||||||
|
await Start(delay);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// REMOVE BUTTON CLICKED
|
// REMOVE BUTTON CLICKED
|
||||||
|
|||||||
33
VDownload/Views/Home/HomeTasksListPlaceholder.xaml
Normal file
33
VDownload/Views/Home/HomeTasksListPlaceholder.xaml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<UserControl
|
||||||
|
x:Class="VDownload.Views.Home.HomeTasksListPlaceholder"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="using:VDownload.Views.Home"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="300"
|
||||||
|
d:DesignWidth="400">
|
||||||
|
|
||||||
|
|
||||||
|
<UserControl.Resources>
|
||||||
|
<ResourceDictionary>
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<ResourceDictionary Source="ms-appx:///Resources/Images.xaml"/>
|
||||||
|
<ResourceDictionary Source="ms-appx:///Resources/Colors.xaml"/>
|
||||||
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
</ResourceDictionary>
|
||||||
|
</UserControl.Resources>
|
||||||
|
|
||||||
|
|
||||||
|
<Viewbox Width="250">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Image Grid.Row="0" Source="{StaticResource HomeTasksListPlaceholderImage}" Width="120"/>
|
||||||
|
<TextBlock Grid.Row="1" x:Uid="HomeTasksListPlaceholderTextBlock" Foreground="{StaticResource HomeTasksListPlaceholderTextColor}"/>
|
||||||
|
</Grid>
|
||||||
|
</Viewbox>
|
||||||
|
</UserControl>
|
||||||
27
VDownload/Views/Home/HomeTasksListPlaceholder.xaml.cs
Normal file
27
VDownload/Views/Home/HomeTasksListPlaceholder.xaml.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices.WindowsRuntime;
|
||||||
|
using Windows.Foundation;
|
||||||
|
using Windows.Foundation.Collections;
|
||||||
|
using Windows.UI.Xaml;
|
||||||
|
using Windows.UI.Xaml.Controls;
|
||||||
|
using Windows.UI.Xaml.Controls.Primitives;
|
||||||
|
using Windows.UI.Xaml.Data;
|
||||||
|
using Windows.UI.Xaml.Input;
|
||||||
|
using Windows.UI.Xaml.Media;
|
||||||
|
using Windows.UI.Xaml.Navigation;
|
||||||
|
|
||||||
|
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
||||||
|
|
||||||
|
namespace VDownload.Views.Home
|
||||||
|
{
|
||||||
|
public sealed partial class HomeTasksListPlaceholder : UserControl
|
||||||
|
{
|
||||||
|
public HomeTasksListPlaceholder()
|
||||||
|
{
|
||||||
|
this.InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,9 +8,7 @@
|
|||||||
xmlns:ex="using:Microsoft.Toolkit.Uwp.UI"
|
xmlns:ex="using:Microsoft.Toolkit.Uwp.UI"
|
||||||
xmlns:cc="using:VDownload.Controls"
|
xmlns:cc="using:VDownload.Controls"
|
||||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d">
|
||||||
d:DesignHeight="300"
|
|
||||||
d:DesignWidth="400">
|
|
||||||
|
|
||||||
|
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user