1.0-dev14 (Playlist adding added)
This commit is contained in:
23
VDownload.Core/EventArgs/PlaylistAddEventArgs.cs
Normal file
23
VDownload.Core/EventArgs/PlaylistAddEventArgs.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using VDownload.Core.Enums;
|
||||
using VDownload.Core.Interfaces;
|
||||
using VDownload.Core.Objects;
|
||||
using Windows.Storage;
|
||||
|
||||
namespace VDownload.Core.EventArgs
|
||||
{
|
||||
public class PlaylistAddEventArgs : System.EventArgs
|
||||
{
|
||||
public (
|
||||
IVideoService VideoService,
|
||||
MediaType MediaType,
|
||||
IBaseStream Stream,
|
||||
TimeSpan TrimStart,
|
||||
TimeSpan TrimEnd,
|
||||
string Filename,
|
||||
MediaFileExtension Extension,
|
||||
StorageFolder Location,
|
||||
double Schedule
|
||||
)[] Videos { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Threading;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VDownload.Core.Interfaces
|
||||
@@ -9,7 +10,9 @@ namespace VDownload.Core.Interfaces
|
||||
|
||||
// PLAYLIST PROPERTIES
|
||||
string ID { get; }
|
||||
Uri PlaylistUrl { get; }
|
||||
string Name { get; }
|
||||
IVideoService[] Videos { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -28,8 +28,9 @@ namespace VDownload.Core.Services.Sources.Twitch
|
||||
#region PROPERTIES
|
||||
|
||||
public string ID { get; private set; }
|
||||
public Uri PlaylistUrl { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
public Vod[] Videos { get; private set; }
|
||||
public IVideoService[] Videos { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -60,6 +61,9 @@ namespace VDownload.Core.Services.Sources.Twitch
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
JToken response = JObject.Parse(await client.DownloadStringTaskAsync("https://api.twitch.tv/helix/users"))["data"][0];
|
||||
|
||||
// Create unified playlist url
|
||||
PlaylistUrl = new Uri($"https://twitch.tv/{ID}");
|
||||
|
||||
// Set parameters
|
||||
if (!ID.All(char.IsDigit)) ID = (string)response["id"];
|
||||
Name = (string)response["display_name"];
|
||||
@@ -79,6 +83,9 @@ namespace VDownload.Core.Services.Sources.Twitch
|
||||
// Set array of videos
|
||||
List<Vod> videos = new List<Vod>();
|
||||
|
||||
// Get all
|
||||
bool getAll = numberOfVideos == 0;
|
||||
|
||||
// Get videos
|
||||
int count;
|
||||
JToken[] videosData;
|
||||
@@ -96,7 +103,7 @@ namespace VDownload.Core.Services.Sources.Twitch
|
||||
client.Headers.Add("Client-Id", Auth.ClientID);
|
||||
|
||||
// Set number of videos to get in this iteration
|
||||
count = numberOfVideos < 100 ? numberOfVideos : 100;
|
||||
count = numberOfVideos < 100 && !getAll ? numberOfVideos : 100;
|
||||
|
||||
// Get response
|
||||
client.QueryString.Add("user_id", ID);
|
||||
@@ -119,7 +126,7 @@ namespace VDownload.Core.Services.Sources.Twitch
|
||||
numberOfVideos--;
|
||||
}
|
||||
}
|
||||
while (numberOfVideos > 0 && count == videosData.Length);
|
||||
while ((getAll || numberOfVideos > 0) && count == videosData.Length);
|
||||
|
||||
// Wait for all getStreams tasks
|
||||
await Task.WhenAll(getStreamsTasks);
|
||||
|
||||
@@ -128,6 +128,7 @@
|
||||
<Compile Include="Enums\VideoFileExtension.cs" />
|
||||
<Compile Include="Enums\VideoSource.cs" />
|
||||
<Compile Include="Enums\TaskStatus.cs" />
|
||||
<Compile Include="EventArgs\PlaylistAddEventArgs.cs" />
|
||||
<Compile Include="EventArgs\VideoAddEventArgs.cs" />
|
||||
<Compile Include="EventArgs\VideoSearchEventArgs.cs" />
|
||||
<Compile Include="EventArgs\PlaylistSearchEventArgs.cs" />
|
||||
|
||||
3
VDownload/Assets/Icons/ApplyToAllOptionsDark.svg
Normal file
3
VDownload/Assets/Icons/ApplyToAllOptionsDark.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg fill="#FFFFFF" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1600 1600"><g transform="matrix(1.198,0,0,1.198,-158.4,-158.4)">
|
||||
<path d="M800,133.333C747.437,133.333 696.755,139.981 648.372,151.237C627.745,156.052 612.314,173.474 610.026,194.531L599.414,291.276C595.943,322.979 577.63,351.028 550,366.992C522.425,382.924 488.954,384.689 459.766,371.875L459.701,371.875L370.833,332.747C351.454,324.219 328.665,328.882 314.193,344.336C245.11,417.986 192.089,507.169 161.979,606.706C155.847,626.96 163.207,649.011 180.273,661.523L259.115,719.336C284.86,738.264 300,768.093 300,800C300,831.924 284.86,861.778 259.115,880.664L180.273,938.411C163.207,950.923 155.847,972.975 161.979,993.229C192.086,1092.76 245.064,1182 314.193,1255.66C328.681,1271.1 351.468,1275.73 370.833,1267.19L459.701,1228.06C488.903,1215.22 522.406,1217.07 550,1233.01C577.63,1248.97 595.943,1277.02 599.414,1308.72L610.026,1405.47C612.331,1426.48 627.726,1443.87 648.307,1448.7C696.712,1460 747.437,1466.67 800,1466.67C852.563,1466.67 903.245,1460.02 951.628,1448.76C972.255,1443.95 987.686,1426.53 989.974,1405.47L1000.59,1308.72C1004.06,1277.02 1022.37,1248.97 1050,1233.01C1077.58,1217.08 1111.05,1215.25 1140.23,1228.06L1229.17,1267.19C1248.53,1275.73 1271.32,1271.1 1285.81,1255.66C1354.89,1182.01 1407.91,1092.77 1438.02,993.229C1444.15,972.975 1436.79,950.923 1419.73,938.411L1340.88,880.664C1315.14,861.778 1300,831.924 1300,800C1300,768.076 1315.14,738.222 1340.88,719.336L1419.73,661.589C1436.79,649.077 1444.15,627.025 1438.02,606.771C1407.91,507.234 1354.89,417.986 1285.81,344.336C1271.32,328.904 1248.53,324.268 1229.17,332.813L1140.23,371.94C1111.05,384.754 1077.58,382.924 1050,366.992C1022.37,351.028 1004.06,322.979 1000.59,291.276L989.974,194.531C987.669,173.516 972.274,156.133 951.693,151.302C903.288,140.005 852.563,133.333 800,133.333ZM800,233.333C832.477,233.333 863.664,239.163 894.922,244.661L901.172,302.148C908.101,365.446 944.897,421.745 1000,453.581C1055.14,485.438 1122.27,489.1 1180.53,463.477L1233.4,440.234C1273.99,488.98 1306.13,544.039 1328.58,604.362L1281.71,638.737C1230.38,676.384 1200,736.324 1200,800C1200,863.676 1230.38,923.616 1281.71,961.263L1328.58,995.638C1306.13,1055.96 1273.99,1111.02 1233.4,1159.77L1180.53,1136.52C1122.27,1110.9 1055.14,1114.56 1000,1146.42C944.897,1178.26 908.101,1234.55 901.172,1297.85L894.922,1355.34C863.667,1360.82 832.461,1366.67 800,1366.67C767.523,1366.67 736.336,1360.84 705.078,1355.34L698.828,1297.85C691.899,1234.55 655.103,1178.26 600,1146.42C544.861,1114.56 477.73,1110.9 419.466,1136.52L366.602,1159.77C325.999,1111.03 293.865,1055.96 271.419,995.638L318.294,961.263C369.615,923.616 400,863.676 400,800C400,736.324 369.591,676.345 318.294,638.672L271.419,604.297C293.878,543.951 326.048,488.928 366.667,440.169L419.466,463.411C477.73,489.035 544.861,485.438 600,453.581C655.103,421.745 691.899,365.446 698.828,302.148L705.078,244.661C736.333,239.178 767.539,233.333 800,233.333ZM800,533.333C653.316,533.333 533.333,653.316 533.333,800C533.333,946.684 653.316,1066.67 800,1066.67C946.684,1066.67 1066.67,946.684 1066.67,800C1066.67,653.316 946.684,533.333 800,533.333ZM800,633.333C892.64,633.333 966.667,707.36 966.667,800C966.667,892.64 892.64,966.667 800,966.667C707.36,966.667 633.333,892.64 633.333,800C633.333,707.36 707.36,633.333 800,633.333Z" style="fill-rule:nonzero;"/>
|
||||
</g></svg>
|
||||
|
After Width: | Height: | Size: 3.3 KiB |
3
VDownload/Assets/Icons/ApplyToAllOptionsLight.svg
Normal file
3
VDownload/Assets/Icons/ApplyToAllOptionsLight.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg fill="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1600 1600"><g transform="matrix(1.198,0,0,1.198,-158.4,-158.4)">
|
||||
<path d="M800,133.333C747.437,133.333 696.755,139.981 648.372,151.237C627.745,156.052 612.314,173.474 610.026,194.531L599.414,291.276C595.943,322.979 577.63,351.028 550,366.992C522.425,382.924 488.954,384.689 459.766,371.875L459.701,371.875L370.833,332.747C351.454,324.219 328.665,328.882 314.193,344.336C245.11,417.986 192.089,507.169 161.979,606.706C155.847,626.96 163.207,649.011 180.273,661.523L259.115,719.336C284.86,738.264 300,768.093 300,800C300,831.924 284.86,861.778 259.115,880.664L180.273,938.411C163.207,950.923 155.847,972.975 161.979,993.229C192.086,1092.76 245.064,1182 314.193,1255.66C328.681,1271.1 351.468,1275.73 370.833,1267.19L459.701,1228.06C488.903,1215.22 522.406,1217.07 550,1233.01C577.63,1248.97 595.943,1277.02 599.414,1308.72L610.026,1405.47C612.331,1426.48 627.726,1443.87 648.307,1448.7C696.712,1460 747.437,1466.67 800,1466.67C852.563,1466.67 903.245,1460.02 951.628,1448.76C972.255,1443.95 987.686,1426.53 989.974,1405.47L1000.59,1308.72C1004.06,1277.02 1022.37,1248.97 1050,1233.01C1077.58,1217.08 1111.05,1215.25 1140.23,1228.06L1229.17,1267.19C1248.53,1275.73 1271.32,1271.1 1285.81,1255.66C1354.89,1182.01 1407.91,1092.77 1438.02,993.229C1444.15,972.975 1436.79,950.923 1419.73,938.411L1340.88,880.664C1315.14,861.778 1300,831.924 1300,800C1300,768.076 1315.14,738.222 1340.88,719.336L1419.73,661.589C1436.79,649.077 1444.15,627.025 1438.02,606.771C1407.91,507.234 1354.89,417.986 1285.81,344.336C1271.32,328.904 1248.53,324.268 1229.17,332.813L1140.23,371.94C1111.05,384.754 1077.58,382.924 1050,366.992C1022.37,351.028 1004.06,322.979 1000.59,291.276L989.974,194.531C987.669,173.516 972.274,156.133 951.693,151.302C903.288,140.005 852.563,133.333 800,133.333ZM800,233.333C832.477,233.333 863.664,239.163 894.922,244.661L901.172,302.148C908.101,365.446 944.897,421.745 1000,453.581C1055.14,485.438 1122.27,489.1 1180.53,463.477L1233.4,440.234C1273.99,488.98 1306.13,544.039 1328.58,604.362L1281.71,638.737C1230.38,676.384 1200,736.324 1200,800C1200,863.676 1230.38,923.616 1281.71,961.263L1328.58,995.638C1306.13,1055.96 1273.99,1111.02 1233.4,1159.77L1180.53,1136.52C1122.27,1110.9 1055.14,1114.56 1000,1146.42C944.897,1178.26 908.101,1234.55 901.172,1297.85L894.922,1355.34C863.667,1360.82 832.461,1366.67 800,1366.67C767.523,1366.67 736.336,1360.84 705.078,1355.34L698.828,1297.85C691.899,1234.55 655.103,1178.26 600,1146.42C544.861,1114.56 477.73,1110.9 419.466,1136.52L366.602,1159.77C325.999,1111.03 293.865,1055.96 271.419,995.638L318.294,961.263C369.615,923.616 400,863.676 400,800C400,736.324 369.591,676.345 318.294,638.672L271.419,604.297C293.878,543.951 326.048,488.928 366.667,440.169L419.466,463.411C477.73,489.035 544.861,485.438 600,453.581C655.103,421.745 691.899,365.446 698.828,302.148L705.078,244.661C736.333,239.178 767.539,233.333 800,233.333ZM800,533.333C653.316,533.333 533.333,653.316 533.333,800C533.333,946.684 653.316,1066.67 800,1066.67C946.684,1066.67 1066.67,946.684 1066.67,800C1066.67,653.316 946.684,533.333 800,533.333ZM800,633.333C892.64,633.333 966.667,707.36 966.667,800C966.667,892.64 892.64,966.667 800,966.667C707.36,966.667 633.333,892.64 633.333,800C633.333,707.36 707.36,633.333 800,633.333Z" style="fill-rule:nonzero;"/>
|
||||
</g></svg>
|
||||
|
After Width: | Height: | Size: 3.3 KiB |
3
VDownload/Assets/Icons/FilterDark.svg
Normal file
3
VDownload/Assets/Icons/FilterDark.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg fill="#FFFFFF" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1600 1600"><g transform="matrix(1.33333,0,0,1.33333,-266.667,-266.663)">
|
||||
<path d="M283.333,200C237.88,200 200,237.88 200,283.333L200,386.328C200,462.883 235.183,535.295 295.313,582.682L633.333,849.023L633.333,1350C633.347,1377.42 655.916,1399.98 683.338,1399.98C693.745,1399.98 703.897,1396.73 712.37,1390.69L945.703,1224.02C958.842,1214.65 966.661,1199.47 966.667,1183.33L966.667,848.958L1304.69,582.682C1364.82,535.295 1400,462.883 1400,386.328L1400,283.333C1400,237.88 1362.12,200 1316.67,200L283.333,200ZM300,300L1300,300L1300,386.328C1300,432.306 1278.98,475.623 1242.84,504.102L909.57,766.667L690.43,766.667L357.161,504.102C321.025,475.623 300,432.306 300,386.328L300,300ZM733.333,866.667L866.667,866.667L866.667,1157.62L733.333,1252.87L733.333,866.667Z" style="fill-rule:nonzero;"/>
|
||||
</g></svg>
|
||||
|
After Width: | Height: | Size: 881 B |
3
VDownload/Assets/Icons/FilterLight.svg
Normal file
3
VDownload/Assets/Icons/FilterLight.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg fill="#000000" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1600 1600"><g transform="matrix(1.33333,0,0,1.33333,-266.667,-266.663)">
|
||||
<path d="M283.333,200C237.88,200 200,237.88 200,283.333L200,386.328C200,462.883 235.183,535.295 295.313,582.682L633.333,849.023L633.333,1350C633.347,1377.42 655.916,1399.98 683.338,1399.98C693.745,1399.98 703.897,1396.73 712.37,1390.69L945.703,1224.02C958.842,1214.65 966.661,1199.47 966.667,1183.33L966.667,848.958L1304.69,582.682C1364.82,535.295 1400,462.883 1400,386.328L1400,283.333C1400,237.88 1362.12,200 1316.67,200L283.333,200ZM300,300L1300,300L1300,386.328C1300,432.306 1278.98,475.623 1242.84,504.102L909.57,766.667L690.43,766.667L357.161,504.102C321.025,475.623 300,432.306 300,386.328L300,300ZM733.333,866.667L866.667,866.667L866.667,1157.62L733.333,1252.87L733.333,866.667Z" style="fill-rule:nonzero;"/>
|
||||
</g></svg>
|
||||
|
After Width: | Height: | Size: 881 B |
@@ -27,12 +27,10 @@
|
||||
</UserControl.Resources>
|
||||
|
||||
|
||||
<Grid MinHeight="65" Padding="18" CornerRadius="{ThemeResource ControlCornerRadius}" Background="{ThemeResource SettingControlBackgroundColor}">
|
||||
<Grid MinHeight="65" Padding="18" CornerRadius="{ThemeResource ControlCornerRadius}" Background="{ThemeResource SettingControlBackgroundColor}" ColumnSpacing="18">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="18"/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="18"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
@@ -40,7 +38,7 @@
|
||||
<Image Grid.Column="0" VerticalAlignment="Center" Width="20" Source="{x:Bind Icon, Mode=OneWay}"/>
|
||||
|
||||
<!-- TITLE & DESCRIPTION -->
|
||||
<Grid Grid.Column="2" VerticalAlignment="Center">
|
||||
<Grid Grid.Column="1" VerticalAlignment="Center">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
@@ -50,6 +48,6 @@
|
||||
</Grid>
|
||||
|
||||
<!-- SETTING CONTROL -->
|
||||
<ContentPresenter Grid.Column="4" HorizontalAlignment="Right" VerticalAlignment="Center" Content="{x:Bind SettingContent, Mode=OneWay}"/>
|
||||
<ContentPresenter Grid.Column="2" VerticalAlignment="Center" Content="{x:Bind SettingContent, Mode=OneWay}"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -5,10 +5,14 @@
|
||||
<ResourceDictionary x:Key="Light">
|
||||
<SolidColorBrush x:Key="HomeBackgroundColor" Color="#F5F5F5"/>
|
||||
<SolidColorBrush x:Key="HomeOptionBarBackgroundColor" Color="#F5F5F5"/>
|
||||
<SolidColorBrush x:Key="HomePlaylistAddingVideoPanelContentBackgroundColor" Color="#F5F5F5"/>
|
||||
<SolidColorBrush x:Key="HomePlaylistAddingApplyToAllContentBackgroundColor" Color="#F5F5F5"/>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Key="Dark">
|
||||
<SolidColorBrush x:Key="HomeBackgroundColor" Color="#252525"/>
|
||||
<SolidColorBrush x:Key="HomeBackgroundColor" Color="#242424"/>
|
||||
<SolidColorBrush x:Key="HomeOptionBarBackgroundColor" Color="#1B1B1B"/>
|
||||
<SolidColorBrush x:Key="HomePlaylistAddingVideoPanelContentBackgroundColor" Color="#272727"/>
|
||||
<SolidColorBrush x:Key="HomePlaylistAddingApplyToAllContentBackgroundColor" Color="#272727"/>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
<SolidColorBrush x:Key="HomeTasksListPlaceholderTextColor" Color="#AAAAAA"/>
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
<SvgImageSource x:Key="StateFinalizingIcon" UriSource="ms-appx:///Assets/Icons/StateFinalizingLight.svg"/>
|
||||
<SvgImageSource x:Key="StateProcessingIcon" UriSource="ms-appx:///Assets/Icons/StateProcessingLight.svg"/>
|
||||
<SvgImageSource x:Key="StateScheduledIcon" UriSource="ms-appx:///Assets/Icons/StateScheduledLight.svg"/>
|
||||
<SvgImageSource x:Key="ApplyToAllOptionsIcon" UriSource="ms-appx:///Assets/Icons/ApplyToAllOptionsLight.svg"/>
|
||||
<SvgImageSource x:Key="FilterIcon" UriSource="ms-appx:///Assets/Icons/FilterLight.svg"/>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Key="Dark">
|
||||
<SvgImageSource x:Key="AuthorIcon" UriSource="ms-appx:///Assets/Icons/AuthorDark.svg"/>
|
||||
@@ -43,6 +45,8 @@
|
||||
<SvgImageSource x:Key="StateFinalizingIcon" UriSource="ms-appx:///Assets/Icons/StateFinalizingDark.svg"/>
|
||||
<SvgImageSource x:Key="StateProcessingIcon" UriSource="ms-appx:///Assets/Icons/StateProcessingDark.svg"/>
|
||||
<SvgImageSource x:Key="StateScheduledIcon" UriSource="ms-appx:///Assets/Icons/StateScheduledDark.svg"/>
|
||||
<SvgImageSource x:Key="ApplyToAllOptionsIcon" UriSource="ms-appx:///Assets/Icons/ApplyToAllOptionsDark.svg"/>
|
||||
<SvgImageSource x:Key="FilterIcon" UriSource="ms-appx:///Assets/Icons/FilterDark.svg"/>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
<SvgImageSource x:Key="TwitchIcon" UriSource="ms-appx:///Assets/Icons/Twitch.svg"/>
|
||||
|
||||
@@ -211,6 +211,93 @@ The number in the numberbox indicades how many videos will be got from playlist.
|
||||
<data name="HomeOptionsBarVideoSearchingTwitchAccessTokenNotValidErrorDialogDescription" xml:space="preserve">
|
||||
<value>There is a problem with linked Twitch account. Check Twitch login status in Sources page.</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingApplyToAllApplyButton.Content" xml:space="preserve">
|
||||
<value>Apply</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingApplyToAllLocationBrowseButton.Content" xml:space="preserve">
|
||||
<value>Browse</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingApplyToAllLocationSettingControl.Title" xml:space="preserve">
|
||||
<value>Location</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingApplyToAllScheduleSettingControl.Description" xml:space="preserve">
|
||||
<value>Number of minutes to start the task (after clicking downloading button).</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingApplyToAllScheduleSettingControl.Title" xml:space="preserve">
|
||||
<value>Schedule</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingPanelApplyToAllOptionsHeaderTextBlock.Text" xml:space="preserve">
|
||||
<value>Apply to all options</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingPanelFilterAuthorTextBlock.Text" xml:space="preserve">
|
||||
<value>Author</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingPanelFilterAuthorTextBoxPlaceholderText" xml:space="preserve">
|
||||
<value>Enter regular expression</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingPanelFilterDateTextBlock.Text" xml:space="preserve">
|
||||
<value>Date</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingPanelFilterDurationTextBlock.Text" xml:space="preserve">
|
||||
<value>Duration</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingPanelFilterHeaderApplyButton.Content" xml:space="preserve">
|
||||
<value>Apply</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingPanelFilterHeaderCountTextBlockPrefix" xml:space="preserve">
|
||||
<value>Hidden</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingPanelFilterHeaderTextBlock.Text" xml:space="preserve">
|
||||
<value>Filter</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingPanelFilterRemovedRestoreButton.Content" xml:space="preserve">
|
||||
<value>Restore</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingPanelFilterRemovedTextBlock.Text" xml:space="preserve">
|
||||
<value>Removed</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingPanelFilterTitleTextBlock.Text" xml:space="preserve">
|
||||
<value>Title</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingPanelFilterTitleTextBoxPlaceholderText" xml:space="preserve">
|
||||
<value>Enter regular expression</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingPanelFilterViewsTextBlock.Text" xml:space="preserve">
|
||||
<value>Views</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingVideoPanelDownloadingOptionsHeaderTextBlock.Text" xml:space="preserve">
|
||||
<value>Downloading options</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingVideoPanelFileOptionsHeaderTextBlock.Text" xml:space="preserve">
|
||||
<value>File options</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingVideoPanelFileSettingControl.Title" xml:space="preserve">
|
||||
<value>File</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingVideoPanelLocationBrowseButton.Content" xml:space="preserve">
|
||||
<value>Browse</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingVideoPanelLocationSettingControl.Title" xml:space="preserve">
|
||||
<value>Location</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingVideoPanelMediaTypeSettingControl.Title" xml:space="preserve">
|
||||
<value>Media type</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingVideoPanelQualitySettingControl.Title" xml:space="preserve">
|
||||
<value>Quality</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingVideoPanelScheduleSettingControl.Description" xml:space="preserve">
|
||||
<value>Number of minutes to start the task (after clicking downloading button).</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingVideoPanelScheduleSettingControl.Title" xml:space="preserve">
|
||||
<value>Schedule</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingVideoPanelTaskOptionsHeaderTextBlock.Text" xml:space="preserve">
|
||||
<value>Task options</value>
|
||||
</data>
|
||||
<data name="HomePlaylistAddingVideoPanelTrimSettingControl.Title" xml:space="preserve">
|
||||
<value>Trim</value>
|
||||
</data>
|
||||
<data name="HomeTaskPanelStateTextCancelled" xml:space="preserve">
|
||||
<value>Cancelled</value>
|
||||
</data>
|
||||
|
||||
@@ -137,6 +137,12 @@
|
||||
<Compile Include="Views\Home\HomeMain.xaml.cs">
|
||||
<DependentUpon>HomeMain.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\Home\HomePlaylistAddingPanel.xaml.cs">
|
||||
<DependentUpon>HomePlaylistAddingPanel.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\Home\HomePlaylistAddingPanelVideoPanel.xaml.cs">
|
||||
<DependentUpon>HomePlaylistAddingPanelVideoPanel.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\Home\HomeTasksListPlaceholder.xaml.cs">
|
||||
<DependentUpon>HomeTasksListPlaceholder.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -165,6 +171,8 @@
|
||||
</AppxManifest>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Assets\Icons\ApplyToAllOptionsDark.svg" />
|
||||
<Content Include="Assets\Icons\ApplyToAllOptionsLight.svg" />
|
||||
<Content Include="Assets\Icons\AuthorDark.svg" />
|
||||
<Content Include="Assets\Icons\AuthorLight.svg" />
|
||||
<Content Include="Assets\Icons\DateDark.svg" />
|
||||
@@ -174,6 +182,8 @@
|
||||
<Content Include="Assets\Icons\Error.svg" />
|
||||
<Content Include="Assets\Icons\FileDark.svg" />
|
||||
<Content Include="Assets\Icons\FileLight.svg" />
|
||||
<Content Include="Assets\Icons\FilterDark.svg" />
|
||||
<Content Include="Assets\Icons\FilterLight.svg" />
|
||||
<Content Include="Assets\Icons\LocationDark.svg" />
|
||||
<Content Include="Assets\Icons\LocationLight.svg" />
|
||||
<Content Include="Assets\Icons\MediaTypeDark.svg" />
|
||||
@@ -301,6 +311,14 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\Home\HomePlaylistAddingPanel.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\Home\HomePlaylistAddingPanelVideoPanel.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\Home\HomeTasksListPlaceholder.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace VDownload.Views.Home
|
||||
private readonly HomeTasksListPlaceholder HomeTasksListPlaceholder = new HomeTasksListPlaceholder();
|
||||
|
||||
// HOME VIDEOS LIST
|
||||
private static ContentControl HomeTasksListPlaceCurrent = null;
|
||||
private static ContentControl HomeTasksListPlaceCurrent { get; set; }
|
||||
private static StackPanel HomeTasksList = null;
|
||||
public static List<HomeTaskPanel> TaskPanelsList = new List<HomeTaskPanel>();
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace VDownload.Views.Home
|
||||
#region EVENT HANDLERS VOIDS
|
||||
|
||||
// ON NAVIGATED TO
|
||||
protected override async void OnNavigatedTo(NavigationEventArgs e)
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
HomeTasksListPlaceCurrent = HomeTasksListPlace;
|
||||
if (HomeTasksList != null) HomeTasksList.Children.Clear();
|
||||
@@ -64,11 +64,11 @@ namespace VDownload.Views.Home
|
||||
if (TaskPanelsList.Count > 0)
|
||||
{
|
||||
foreach (HomeTaskPanel homeVideoPanel in TaskPanelsList) HomeTasksList.Children.Add(homeVideoPanel);
|
||||
HomeTasksListPlace.Content = HomeTasksList;
|
||||
HomeTasksListPlaceCurrent.Content = HomeTasksList;
|
||||
}
|
||||
else
|
||||
{
|
||||
HomeTasksListPlace.Content = HomeTasksListPlaceholder;
|
||||
HomeTasksListPlaceCurrent.Content = HomeTasksListPlaceholder;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,9 +87,9 @@ namespace VDownload.Views.Home
|
||||
// ADD VIDEO SEARCH BUTTON CLICKED
|
||||
private async void HomeOptionsBarAddVideoControl_SearchButtonClicked(object sender, VideoSearchEventArgs e)
|
||||
{
|
||||
// Set UI
|
||||
HomeOptionBarAndAddingPanelRow.Height = GridLength.Auto;
|
||||
HomeTasksListRow.Height = new GridLength(1, GridUnitType.Star);
|
||||
|
||||
HomeAddingPanel.Content = null;
|
||||
|
||||
// Cancel previous operations
|
||||
@@ -172,19 +172,21 @@ namespace VDownload.Views.Home
|
||||
// Set searching status control to done (null)
|
||||
HomeOptionsBarSearchingStatusControl.Content = null;
|
||||
|
||||
|
||||
// Set UI
|
||||
HomeOptionBarAndAddingPanelRow.Height = new GridLength(1, GridUnitType.Star);
|
||||
HomeTasksListRow.Height = new GridLength(0);
|
||||
|
||||
HomeVideoAddingPanel addingPanel = new HomeVideoAddingPanel(videoService);
|
||||
addingPanel.VideoAddRequest += HomeVideoAddingPanel_VideoAddRequest;
|
||||
HomeAddingPanel.Content = addingPanel;
|
||||
}
|
||||
}
|
||||
|
||||
// ADD VIDEO REQUEST FROM VIDEO ADDING PANEL
|
||||
private void HomeVideoAddingPanel_VideoAddRequest(object sender, VideoAddEventArgs e)
|
||||
{
|
||||
// Replace placeholder
|
||||
HomeTasksListPlace.Content = HomeTasksList;
|
||||
HomeTasksListPlaceCurrent.Content = HomeTasksList;
|
||||
|
||||
// Uncheck video button
|
||||
HomeOptionsBarAddVideoButton.IsChecked = false;
|
||||
@@ -197,7 +199,7 @@ namespace VDownload.Views.Home
|
||||
// Remove task from tasks lists
|
||||
TaskPanelsList.Remove(taskPanel);
|
||||
HomeTasksList.Children.Remove(taskPanel);
|
||||
if (TaskPanelsList.Count <= 0) HomeTasksListPlace.Content = HomeTasksListPlaceholder;
|
||||
if (TaskPanelsList.Count <= 0) HomeTasksListPlaceCurrent.Content = HomeTasksListPlaceholder;
|
||||
};
|
||||
|
||||
// Add task to tasks lists
|
||||
@@ -221,8 +223,14 @@ namespace VDownload.Views.Home
|
||||
// ADD PLAYLIST SEARCH BUTTON CLICKED
|
||||
private async void HomeOptionsBarAddPlaylistControl_SearchButtonClicked(object sender, PlaylistSearchEventArgs e)
|
||||
{
|
||||
// Set UI
|
||||
HomeOptionBarAndAddingPanelRow.Height = GridLength.Auto;
|
||||
HomeTasksListRow.Height = new GridLength(1, GridUnitType.Star);
|
||||
HomeAddingPanel.Content = null;
|
||||
|
||||
// Cancel previous operations
|
||||
SearchingCancellationToken.Cancel();
|
||||
SearchingCancellationToken = new CancellationTokenSource();
|
||||
|
||||
// Set SearchingStatusControl
|
||||
HomeOptionsBarSearchingStatusControl.Content = HomeOptionsBarSearchingStatusProgressRing;
|
||||
@@ -295,6 +303,45 @@ namespace VDownload.Views.Home
|
||||
}
|
||||
else throw;
|
||||
}
|
||||
|
||||
// Set searching status control to done (null)
|
||||
HomeOptionsBarSearchingStatusControl.Content = null;
|
||||
|
||||
// Set UI
|
||||
HomeOptionBarAndAddingPanelRow.Height = new GridLength(1, GridUnitType.Star);
|
||||
HomeTasksListRow.Height = new GridLength(0);
|
||||
|
||||
HomePlaylistAddingPanel addingPanel = new HomePlaylistAddingPanel(playlistService);
|
||||
addingPanel.PlaylistAddRequest += HomeVideoAddingPanel_PlayListAddRequest;
|
||||
HomeAddingPanel.Content = addingPanel;
|
||||
}
|
||||
}
|
||||
|
||||
// ADD PLAYLIST REQUEST FROM PLAYLIST ADDING PANEL
|
||||
private void HomeVideoAddingPanel_PlayListAddRequest(object sender, PlaylistAddEventArgs e)
|
||||
{
|
||||
// Replace placeholder
|
||||
HomeTasksListPlaceCurrent.Content = HomeTasksList;
|
||||
|
||||
// Uncheck video button
|
||||
HomeOptionsBarAddPlaylistButton.IsChecked = false;
|
||||
|
||||
// Create video tasks
|
||||
foreach (var video in e.Videos)
|
||||
{
|
||||
HomeTaskPanel taskPanel = new HomeTaskPanel(video.VideoService, video.MediaType, video.Stream, video.TrimStart, video.TrimEnd, video.Filename, video.Extension, video.Location, video.Schedule);
|
||||
|
||||
taskPanel.TaskRemovingRequested += (s, a) =>
|
||||
{
|
||||
// Remove task from tasks lists
|
||||
TaskPanelsList.Remove(taskPanel);
|
||||
HomeTasksList.Children.Remove(taskPanel);
|
||||
if (TaskPanelsList.Count <= 0) HomeTasksListPlaceCurrent.Content = HomeTasksListPlaceholder;
|
||||
};
|
||||
|
||||
// Add task to tasks lists
|
||||
HomeTasksList.Children.Add(taskPanel);
|
||||
TaskPanelsList.Add(taskPanel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,7 +387,10 @@ namespace VDownload.Views.Home
|
||||
foreach (HomeTaskPanel videoPanel in idleTasks)
|
||||
{
|
||||
await Task.Delay(50);
|
||||
|
||||
#pragma warning disable CS4014
|
||||
videoPanel.Start(delay);
|
||||
#pragma warning restore CS4014
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
159
VDownload/Views/Home/HomePlaylistAddingPanel.xaml
Normal file
159
VDownload/Views/Home/HomePlaylistAddingPanel.xaml
Normal file
@@ -0,0 +1,159 @@
|
||||
<UserControl
|
||||
x:Class="VDownload.Views.Home.HomePlaylistAddingPanel"
|
||||
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"
|
||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||
xmlns:cc="using:VDownload.Controls"
|
||||
mc:Ignorable="d">
|
||||
|
||||
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="ms-appx:///Resources/Colors.xaml"/>
|
||||
<ResourceDictionary Source="ms-appx:///Resources/Icons.xaml"/>
|
||||
<ResourceDictionary Source="ms-appx:///Resources/Converters.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
|
||||
|
||||
<Grid Padding="10" RowSpacing="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- METADATA PANEL -->
|
||||
<Grid VerticalAlignment="Stretch">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Margin="12" VerticalAlignment="Center" FontSize="18" FontWeight="SemiBold" Text="{x:Bind Name}"/>
|
||||
<AppBarButton Grid.Column="1" Width="40" Height="48" Icon="{x:Bind SourceImage}" Click="HomePlaylistAddingPanelSourceButton_Click"/>
|
||||
<AppBarButton Grid.Column="2" Width="40" Height="48" Icon="Add" Click="HomePlaylistAddingPanelAddButton_Click"/>
|
||||
</Grid>
|
||||
|
||||
<ScrollViewer Grid.Row="1" Margin="0,0,0,60">
|
||||
<StackPanel x:Name="HomePlaylistAddingPanelVideosList" Spacing="10"/>
|
||||
</ScrollViewer>
|
||||
|
||||
<Grid Grid.Row="1" ColumnSpacing="10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<muxc:Expander Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" HorizontalContentAlignment="Stretch" ExpandDirection="Up" Background="{ThemeResource HomePlaylistAddingApplyToAllContentBackgroundColor}">
|
||||
<muxc:Expander.Header>
|
||||
<StackPanel Margin="-5,0,-10,0" Spacing="10" Orientation="Horizontal">
|
||||
<Image Height="18" Source="{ThemeResource ApplyToAllOptionsIcon}"/>
|
||||
<TextBlock x:Uid="HomePlaylistAddingPanelApplyToAllOptionsHeaderTextBlock"/>
|
||||
</StackPanel>
|
||||
</muxc:Expander.Header>
|
||||
<muxc:Expander.Content>
|
||||
<StackPanel Spacing="10">
|
||||
<cc:SettingControl x:Name="HomePlaylistAddingApplyToAllLocationSettingControl" x:Uid="HomePlaylistAddingApplyToAllLocationSettingControl" Icon="{ThemeResource LocationIcon}">
|
||||
<cc:SettingControl.SettingContent>
|
||||
<StackPanel Spacing="10" Orientation="Horizontal">
|
||||
<Button x:Uid="HomePlaylistAddingApplyToAllLocationBrowseButton" Click="HomePlaylistAddingApplyToAllLocationBrowseButton_Click"/>
|
||||
<Button x:Uid="HomePlaylistAddingApplyToAllApplyButton" Click="HomePlaylistAddingApplyToAllApplyLocationButton_Click"/>
|
||||
</StackPanel>
|
||||
</cc:SettingControl.SettingContent>
|
||||
</cc:SettingControl>
|
||||
<cc:SettingControl x:Uid="HomePlaylistAddingApplyToAllScheduleSettingControl" Icon="{ThemeResource ScheduleIcon}">
|
||||
<cc:SettingControl.SettingContent>
|
||||
<StackPanel Spacing="10" Orientation="Horizontal">
|
||||
<muxc:NumberBox x:Name="HomePlaylistAddingApplyToAllScheduleNumberBox" MaxWidth="100" Value="0" Minimum="0" SpinButtonPlacementMode="Compact" ValueChanged="HomePlaylistAddingApplyToAllScheduleNumberBox_ValueChanged"/>
|
||||
<Button x:Uid="HomePlaylistAddingApplyToAllApplyButton" Click="HomePlaylistAddingApplyToAllApplyScheduleButton_Click"/>
|
||||
</StackPanel>
|
||||
</cc:SettingControl.SettingContent>
|
||||
</cc:SettingControl>
|
||||
</StackPanel>
|
||||
</muxc:Expander.Content>
|
||||
</muxc:Expander>
|
||||
<muxc:Expander Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" HorizontalContentAlignment="Stretch" ExpandDirection="Up" Background="{ThemeResource HomePlaylistAddingApplyToAllContentBackgroundColor}">
|
||||
<muxc:Expander.Header>
|
||||
<Grid Margin="-5,0,-10,0" ColumnSpacing="10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image Grid.Column="0" Height="18" Source="{ThemeResource FilterIcon}"/>
|
||||
<StackPanel Grid.Column="1" Margin="0,0,20,0" Spacing="10" Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<TextBlock x:Uid="HomePlaylistAddingPanelFilterHeaderTextBlock"/>
|
||||
<TextBlock x:Name="HomePlaylistAddingPanelFilterHeaderCountTextBlock" FontWeight="Light"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</muxc:Expander.Header>
|
||||
<muxc:Expander.Content>
|
||||
<Grid RowSpacing="8" ColumnSpacing="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" x:Uid="HomePlaylistAddingPanelFilterTitleTextBlock" FontWeight="SemiBold"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" x:Name="HomePlaylistAddingPanelFilterTitleTextBox" LostFocus="HomePlaylistAddingPanelFilterTitleAndAuthorTextBox_LostFocus"/>
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" x:Uid="HomePlaylistAddingPanelFilterAuthorTextBlock" FontWeight="SemiBold"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="1" x:Name="HomePlaylistAddingPanelFilterAuthorTextBox" LostFocus="HomePlaylistAddingPanelFilterTitleAndAuthorTextBox_LostFocus"/>
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" x:Uid="HomePlaylistAddingPanelFilterViewsTextBlock" FontWeight="SemiBold"/>
|
||||
<Grid Grid.Row="2" Grid.Column="1" ColumnSpacing="8">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="5"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<muxc:NumberBox Grid.Column="0" x:Name="HomePlaylistAddingPanelFilterMinViewsNumberBox" SpinButtonPlacementMode="Compact" LostFocus="HomePlaylistAddingPanelFilterMinViewsNumberBox_LostFocus"/>
|
||||
<TextBlock Grid.Column="1" VerticalAlignment="Center" Text="-"/>
|
||||
<muxc:NumberBox Grid.Column="2" x:Name="HomePlaylistAddingPanelFilterMaxViewsNumberBox" SpinButtonPlacementMode="Compact" LostFocus="HomePlaylistAddingPanelFilterMaxViewsNumberBox_LostFocus"/>
|
||||
</Grid>
|
||||
<TextBlock Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" x:Uid="HomePlaylistAddingPanelFilterDateTextBlock" FontWeight="SemiBold"/>
|
||||
<Grid Grid.Row="3" Grid.Column="1" ColumnSpacing="8">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="5"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<CalendarDatePicker x:Name="HomePlaylistAddingPanelFilterMinDateDatePicker" Grid.Column="0" LostFocus="HomePlaylistAddingPanelFilterMinAndMaxDateDatePicker_LostFocus"/>
|
||||
<TextBlock Grid.Column="1" VerticalAlignment="Center" Text="-"/>
|
||||
<CalendarDatePicker x:Name="HomePlaylistAddingPanelFilterMaxDateDatePicker" Grid.Column="2" LostFocus="HomePlaylistAddingPanelFilterMinAndMaxDateDatePicker_LostFocus"/>
|
||||
</Grid>
|
||||
<TextBlock Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" x:Uid="HomePlaylistAddingPanelFilterDurationTextBlock" FontWeight="SemiBold"/>
|
||||
<Grid Grid.Row="4" Grid.Column="1" ColumnSpacing="8">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="5"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox Grid.Column="0" x:Name="HomePlaylistAddingPanelFilterMinDurationTextBox" LostFocus="HomePlaylistAddingPanelFilterMinDurationTextBox_LostFocus"/>
|
||||
<TextBlock Grid.Column="1" VerticalAlignment="Center" Text="-"/>
|
||||
<TextBox Grid.Column="2" x:Name="HomePlaylistAddingPanelFilterMaxDurationTextBox" LostFocus="HomePlaylistAddingPanelFilterMaxDurationTextBox_LostFocus"/>
|
||||
</Grid>
|
||||
<TextBlock x:Name="HomePlaylistAddingPanelFilterRemovedTextBlock" Grid.Row="5" Grid.Column="0" VerticalAlignment="Center" x:Uid="HomePlaylistAddingPanelFilterRemovedTextBlock" FontWeight="SemiBold" Visibility="Collapsed"/>
|
||||
<Grid Grid.Row="5" Grid.Column="1" ColumnSpacing="8">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" x:Name="HomePlaylistAddingPanelFilterRemovedCountTextBlock" VerticalAlignment="Center" Visibility="Collapsed"/>
|
||||
<Button Grid.Column="1" x:Uid="HomePlaylistAddingPanelFilterRemovedRestoreButton" x:Name="HomePlaylistAddingPanelFilterRemovedRestoreButton" Visibility="Collapsed" Click="HomePlaylistAddingPanelFilterRemovedRestoreButton_Click"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</muxc:Expander.Content>
|
||||
</muxc:Expander>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
418
VDownload/Views/Home/HomePlaylistAddingPanel.xaml.cs
Normal file
418
VDownload/Views/Home/HomePlaylistAddingPanel.xaml.cs
Normal file
@@ -0,0 +1,418 @@
|
||||
using Microsoft.Toolkit.Uwp.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using VDownload.Converters;
|
||||
using VDownload.Core.Enums;
|
||||
using VDownload.Core.EventArgs;
|
||||
using VDownload.Core.Interfaces;
|
||||
using VDownload.Core.Services;
|
||||
using Windows.ApplicationModel.Resources;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
using Windows.Storage;
|
||||
using Windows.Storage.AccessCache;
|
||||
using Windows.Storage.Pickers;
|
||||
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;
|
||||
|
||||
namespace VDownload.Views.Home
|
||||
{
|
||||
public sealed partial class HomePlaylistAddingPanel : UserControl
|
||||
{
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public HomePlaylistAddingPanel(IPlaylistService playlistService)
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
// Set playlist service object
|
||||
PlaylistService = playlistService;
|
||||
|
||||
// Set metadata
|
||||
SourceImage = new BitmapIcon { UriSource = new Uri($"ms-appx:///Assets/Sources/{PlaylistService.GetType().Namespace.Split(".").Last()}.png"), ShowAsMonochrome = false };
|
||||
Name = PlaylistService.Name;
|
||||
|
||||
// Add videos to list and search mins and maxes
|
||||
MinViews = PlaylistService.Videos[0].Views;
|
||||
MaxViews = PlaylistService.Videos[0].Views;
|
||||
MinDate = PlaylistService.Videos[0].Date;
|
||||
MaxDate = PlaylistService.Videos[0].Date;
|
||||
MinDuration = PlaylistService.Videos[0].Duration;
|
||||
MaxDuration = PlaylistService.Videos[0].Duration;
|
||||
foreach (IVideoService video in PlaylistService.Videos)
|
||||
{
|
||||
if (video.Views < MinViews) MinViews = video.Views;
|
||||
if (video.Views > MaxViews) MaxViews = video.Views;
|
||||
if (video.Date < MinDate) MinDate = video.Date;
|
||||
if (video.Date > MaxDate) MaxDate = video.Date;
|
||||
if (video.Duration < MinDuration) MinDuration = video.Duration;
|
||||
if (video.Duration > MaxDuration) MaxDuration = video.Duration;
|
||||
HomePlaylistAddingPanelVideoPanel videoPanel = new HomePlaylistAddingPanelVideoPanel(video);
|
||||
videoPanel.DeleteRequested += (s, a) =>
|
||||
{
|
||||
DeletedVideos.Add(videoPanel);
|
||||
HomePlaylistAddingPanelFilterRemovedTextBlock.Visibility = Visibility.Visible;
|
||||
HomePlaylistAddingPanelFilterRemovedCountTextBlock.Visibility = Visibility.Visible;
|
||||
HomePlaylistAddingPanelFilterRemovedRestoreButton.Visibility = Visibility.Visible;
|
||||
HomePlaylistAddingPanelFilterRemovedCountTextBlock.Text = $"{DeletedVideos.Count}";
|
||||
HomePlaylistAddingPanelFilterHeaderCountTextBlock.Text = HiddenVideos.Count + DeletedVideos.Count > 0 ? $"{ResourceLoader.GetForCurrentView().GetString("HomePlaylistAddingPanelFilterHeaderCountTextBlockPrefix")}: {HiddenVideos.Count + DeletedVideos.Count}" : "";
|
||||
HomePlaylistAddingPanelVideosList.Children.Remove(videoPanel);
|
||||
};
|
||||
|
||||
HomePlaylistAddingPanelVideosList.Children.Add(videoPanel);
|
||||
}
|
||||
|
||||
// Set apply to all location option
|
||||
if (!(bool)Config.GetValue("custom_media_location") && StorageApplicationPermissions.FutureAccessList.ContainsItem("last_media_location"))
|
||||
{
|
||||
Task<StorageFolder> task = StorageApplicationPermissions.FutureAccessList.GetFolderAsync("last_media_location").AsTask();
|
||||
ATLLocation = task.Result;
|
||||
HomePlaylistAddingApplyToAllLocationSettingControl.Description = ATLLocation.Path;
|
||||
}
|
||||
else if ((bool)Config.GetValue("custom_media_location") && StorageApplicationPermissions.FutureAccessList.ContainsItem("custom_media_location"))
|
||||
{
|
||||
Task<StorageFolder> task = StorageApplicationPermissions.FutureAccessList.GetFolderAsync("selected_media_location").AsTask();
|
||||
ATLLocation = task.Result;
|
||||
HomePlaylistAddingApplyToAllLocationSettingControl.Description = ATLLocation.Path;
|
||||
}
|
||||
else
|
||||
{
|
||||
ATLLocation = null;
|
||||
HomePlaylistAddingApplyToAllLocationSettingControl.Description = $@"{UserDataPaths.GetDefault().Downloads}\VDownload";
|
||||
}
|
||||
|
||||
// Set apply to all schedule option
|
||||
ATLSchedule = 0;
|
||||
|
||||
// Set title and author filter option
|
||||
HomePlaylistAddingPanelFilterTitleTextBox.PlaceholderText = ResourceLoader.GetForCurrentView().GetString("HomePlaylistAddingPanelFilterTitleTextBoxPlaceholderText");
|
||||
HomePlaylistAddingPanelFilterAuthorTextBox.PlaceholderText = ResourceLoader.GetForCurrentView().GetString("HomePlaylistAddingPanelFilterAuthorTextBoxPlaceholderText");
|
||||
|
||||
// Set views filter option
|
||||
HomePlaylistAddingPanelFilterMinViewsNumberBox.Minimum = HomePlaylistAddingPanelFilterMaxViewsNumberBox.Minimum = HomePlaylistAddingPanelFilterMinViewsNumberBox.Value = MinViews;
|
||||
HomePlaylistAddingPanelFilterMinViewsNumberBox.Maximum = HomePlaylistAddingPanelFilterMaxViewsNumberBox.Maximum = HomePlaylistAddingPanelFilterMaxViewsNumberBox.Value = MaxViews;
|
||||
|
||||
// Set date filter option
|
||||
HomePlaylistAddingPanelFilterMinDateDatePicker.MinDate = HomePlaylistAddingPanelFilterMaxDateDatePicker.MinDate = (DateTimeOffset)(HomePlaylistAddingPanelFilterMinDateDatePicker.Date = MinDate);
|
||||
HomePlaylistAddingPanelFilterMinDateDatePicker.MaxDate = HomePlaylistAddingPanelFilterMaxDateDatePicker.MaxDate = (DateTimeOffset)(HomePlaylistAddingPanelFilterMaxDateDatePicker.Date = MaxDate);
|
||||
|
||||
// Set duration filter option
|
||||
TextBoxExtensions.SetMask(HomePlaylistAddingPanelFilterMinDurationTextBox, (string)new TimeSpanToTextBoxMaskConverter().Convert(MaxDuration, null, null, null));
|
||||
TextBoxExtensions.SetMask(HomePlaylistAddingPanelFilterMaxDurationTextBox, (string)new TimeSpanToTextBoxMaskConverter().Convert(MaxDuration, null, null, null));
|
||||
HashSet<int> maskElements = new HashSet<int>();
|
||||
foreach (TimeSpan ts in new List<TimeSpan>{ MinDuration, MaxDuration } )
|
||||
{
|
||||
if (Math.Floor(ts.TotalHours) > 0) maskElements.Add(int.Parse(Math.Floor(ts.TotalHours).ToString()[0].ToString()));
|
||||
if (Math.Floor(ts.TotalMinutes) > 0)
|
||||
{
|
||||
if (Math.Floor(ts.TotalHours) > 0) maskElements.Add(5);
|
||||
else maskElements.Add(int.Parse(ts.Minutes.ToString()[0].ToString()));
|
||||
}
|
||||
if (Math.Floor(ts.TotalMinutes) > 0) maskElements.Add(5);
|
||||
else maskElements.Add(int.Parse(ts.Seconds.ToString()[0].ToString()));
|
||||
}
|
||||
List<string> maskElementsString = new List<string>();
|
||||
foreach (int i in maskElements)
|
||||
{
|
||||
if (i != 9) maskElementsString.Add($"{i}:[0-{i}]");
|
||||
}
|
||||
TextBoxExtensions.SetCustomMask(HomePlaylistAddingPanelFilterMinDurationTextBox, string.Join(',', maskElementsString));
|
||||
TextBoxExtensions.SetCustomMask(HomePlaylistAddingPanelFilterMaxDurationTextBox, string.Join(',', maskElementsString));
|
||||
if (Math.Floor(MaxDuration.TotalHours) > 0) HomePlaylistAddingPanelFilterMinDurationTextBox.Text += $"{Math.Floor(MinDuration.TotalHours)}:";
|
||||
if (Math.Floor(MaxDuration.TotalMinutes) > 0) HomePlaylistAddingPanelFilterMinDurationTextBox.Text += Math.Floor(MaxDuration.TotalHours) > 0 ? $"{MinDuration.Minutes:00}:" : $"{MinDuration.Minutes}:";
|
||||
HomePlaylistAddingPanelFilterMinDurationTextBox.Text += Math.Floor(MaxDuration.TotalMinutes) > 0 ? $"{MinDuration.Seconds:00}" : $"{MinDuration.Seconds}";
|
||||
if (Math.Floor(MaxDuration.TotalHours) > 0) HomePlaylistAddingPanelFilterMaxDurationTextBox.Text += $"{Math.Floor(MaxDuration.TotalHours)}:";
|
||||
if (Math.Floor(MaxDuration.TotalMinutes) > 0) HomePlaylistAddingPanelFilterMaxDurationTextBox.Text += Math.Floor(MaxDuration.TotalHours) > 0 ? $"{MaxDuration.Minutes:00}:" : $"{MaxDuration.Minutes}:";
|
||||
HomePlaylistAddingPanelFilterMaxDurationTextBox.Text += Math.Floor(MaxDuration.TotalMinutes) > 0 ? $"{MaxDuration.Seconds:00}" : $"{MaxDuration.Seconds}";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
// BASE PLAYLIST DATA
|
||||
private IPlaylistService PlaylistService { get; set; }
|
||||
|
||||
// PLAYLIST DATA
|
||||
private IconElement SourceImage { get; set; }
|
||||
private string Name { get; set; }
|
||||
|
||||
// APPLY TO ALL OPTIONS
|
||||
public StorageFolder ATLLocation { get; set; }
|
||||
public double ATLSchedule { get; set; }
|
||||
|
||||
// DELETED VIDEOS
|
||||
public List<HomePlaylistAddingPanelVideoPanel> DeletedVideos = new List<HomePlaylistAddingPanelVideoPanel>();
|
||||
public List<HomePlaylistAddingPanelVideoPanel> HiddenVideos = new List<HomePlaylistAddingPanelVideoPanel>();
|
||||
|
||||
// FILTER MIN MAX
|
||||
private long MinViews { get; set; }
|
||||
private long MaxViews { get; set; }
|
||||
private DateTime MinDate { get; set; }
|
||||
private DateTime MaxDate { get; set; }
|
||||
private TimeSpan MinDuration { get; set; }
|
||||
private TimeSpan MaxDuration { get; set; }
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region EVENT HANDLERS VOIDS
|
||||
|
||||
// FILTER CHANGED
|
||||
private void FilterChanged()
|
||||
{
|
||||
// Min duration
|
||||
string[] minSegments = HomePlaylistAddingPanelFilterMinDurationTextBox.Text.Split(':').Reverse().ToArray();
|
||||
int.TryParse(minSegments.ElementAtOrDefault(0), out int minSeconds);
|
||||
int.TryParse(minSegments.ElementAtOrDefault(1), out int minMinutes);
|
||||
int.TryParse(minSegments.ElementAtOrDefault(2), out int minHours);
|
||||
TimeSpan minDuration = new TimeSpan(minHours, minMinutes, minSeconds);
|
||||
|
||||
// Max duration
|
||||
string[] maxSegments = HomePlaylistAddingPanelFilterMaxDurationTextBox.Text.Split(':').Reverse().ToArray();
|
||||
int.TryParse(maxSegments.ElementAtOrDefault(0), out int maxSeconds);
|
||||
int.TryParse(maxSegments.ElementAtOrDefault(1), out int maxMinutes);
|
||||
int.TryParse(maxSegments.ElementAtOrDefault(2), out int maxHours);
|
||||
TimeSpan maxDuration = new TimeSpan(maxHours, maxMinutes, maxSeconds);
|
||||
|
||||
List<HomePlaylistAddingPanelVideoPanel> allVideos = new List<HomePlaylistAddingPanelVideoPanel>();
|
||||
foreach (HomePlaylistAddingPanelVideoPanel videoPanel in HomePlaylistAddingPanelVideosList.Children) allVideos.Add(videoPanel);
|
||||
foreach (HomePlaylistAddingPanelVideoPanel videoPanel in HiddenVideos) allVideos.Add(videoPanel);
|
||||
HomePlaylistAddingPanelVideosList.Children.Clear();
|
||||
HiddenVideos.Clear();
|
||||
|
||||
foreach (HomePlaylistAddingPanelVideoPanel videoPanel in allVideos)
|
||||
{
|
||||
Regex titleRegex = new Regex("");
|
||||
Regex authorRegex = new Regex("");
|
||||
try
|
||||
{
|
||||
titleRegex = new Regex(HomePlaylistAddingPanelFilterTitleTextBox.Text);
|
||||
authorRegex = new Regex(HomePlaylistAddingPanelFilterAuthorTextBox.Text);
|
||||
}
|
||||
catch (ArgumentException) { }
|
||||
if (!titleRegex.IsMatch(videoPanel.VideoService.Title)) HiddenVideos.Add(videoPanel);
|
||||
else if (!authorRegex.IsMatch(videoPanel.VideoService.Author)) HiddenVideos.Add(videoPanel);
|
||||
else if (HomePlaylistAddingPanelFilterMinViewsNumberBox.Value > videoPanel.VideoService.Views) HiddenVideos.Add(videoPanel);
|
||||
else if (HomePlaylistAddingPanelFilterMaxViewsNumberBox.Value < videoPanel.VideoService.Views) HiddenVideos.Add(videoPanel);
|
||||
else if (HomePlaylistAddingPanelFilterMinDateDatePicker.Date > videoPanel.VideoService.Date) HiddenVideos.Add(videoPanel);
|
||||
else if (HomePlaylistAddingPanelFilterMaxDateDatePicker.Date < videoPanel.VideoService.Date) HiddenVideos.Add(videoPanel);
|
||||
else if (minDuration > videoPanel.VideoService.Duration) HiddenVideos.Add(videoPanel);
|
||||
else if (maxDuration < videoPanel.VideoService.Duration) HiddenVideos.Add(videoPanel);
|
||||
else HomePlaylistAddingPanelVideosList.Children.Add(videoPanel);
|
||||
}
|
||||
HomePlaylistAddingPanelFilterHeaderCountTextBlock.Text = HiddenVideos.Count + DeletedVideos.Count > 0 ? $"{ResourceLoader.GetForCurrentView().GetString("HomePlaylistAddingPanelFilterHeaderCountTextBlockPrefix")}: {HiddenVideos.Count + DeletedVideos.Count}" : "";
|
||||
}
|
||||
|
||||
// ATL LOCATION BROWSE BUTTON CLICKED
|
||||
private async void HomePlaylistAddingApplyToAllLocationBrowseButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FolderPicker picker = new FolderPicker
|
||||
{
|
||||
SuggestedStartLocation = PickerLocationId.Downloads
|
||||
};
|
||||
picker.FileTypeFilter.Add("*");
|
||||
|
||||
StorageFolder selectedFolder = await picker.PickSingleFolderAsync();
|
||||
|
||||
if (selectedFolder != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
await(await selectedFolder.CreateFileAsync("VDownloadLocationAccessTest")).DeleteAsync();
|
||||
StorageApplicationPermissions.FutureAccessList.AddOrReplace("last_media_location", selectedFolder);
|
||||
ATLLocation = selectedFolder;
|
||||
HomePlaylistAddingApplyToAllLocationSettingControl.Description = ATLLocation.Path;
|
||||
}
|
||||
catch (UnauthorizedAccessException) { }
|
||||
}
|
||||
}
|
||||
|
||||
// APPLY ATL LOCATION BUTTON CLICKED
|
||||
private void HomePlaylistAddingApplyToAllApplyLocationButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
foreach (HomePlaylistAddingPanelVideoPanel videoPanel in HomePlaylistAddingPanelVideosList.Children)
|
||||
{
|
||||
videoPanel.Location = ATLLocation;
|
||||
videoPanel.HomePlaylistAddingVideoPanelLocationSettingControl.Description = ATLLocation != null ? ATLLocation.Path : $@"{UserDataPaths.GetDefault().Downloads}\VDownload";
|
||||
}
|
||||
foreach (HomePlaylistAddingPanelVideoPanel videoPanel in DeletedVideos)
|
||||
{
|
||||
videoPanel.Location = ATLLocation;
|
||||
videoPanel.HomePlaylistAddingVideoPanelLocationSettingControl.Description = ATLLocation != null ? ATLLocation.Path : $@"{UserDataPaths.GetDefault().Downloads}\VDownload";
|
||||
}
|
||||
foreach (HomePlaylistAddingPanelVideoPanel videoPanel in HiddenVideos)
|
||||
{
|
||||
videoPanel.Location = ATLLocation;
|
||||
videoPanel.HomePlaylistAddingVideoPanelLocationSettingControl.Description = ATLLocation != null ? ATLLocation.Path : $@"{UserDataPaths.GetDefault().Downloads}\VDownload";
|
||||
}
|
||||
}
|
||||
|
||||
// ATL SCHEDULE NUMBERBOX VALUE CHANGED
|
||||
private void HomePlaylistAddingApplyToAllScheduleNumberBox_ValueChanged(Microsoft.UI.Xaml.Controls.NumberBox sender, Microsoft.UI.Xaml.Controls.NumberBoxValueChangedEventArgs args)
|
||||
{
|
||||
ATLSchedule = HomePlaylistAddingApplyToAllScheduleNumberBox.Value;
|
||||
}
|
||||
|
||||
// APPLY ATL SCHEDULE BUTTON CLICKED
|
||||
private void HomePlaylistAddingApplyToAllApplyScheduleButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
foreach (HomePlaylistAddingPanelVideoPanel videoPanel in HomePlaylistAddingPanelVideosList.Children)
|
||||
{
|
||||
videoPanel.Schedule = ATLSchedule;
|
||||
videoPanel.HomePlaylistAddingVideoPanelScheduleNumberBox.Value = ATLSchedule;
|
||||
}
|
||||
foreach (HomePlaylistAddingPanelVideoPanel videoPanel in DeletedVideos)
|
||||
{
|
||||
videoPanel.Schedule = ATLSchedule;
|
||||
videoPanel.HomePlaylistAddingVideoPanelScheduleNumberBox.Value = ATLSchedule;
|
||||
}
|
||||
foreach (HomePlaylistAddingPanelVideoPanel videoPanel in HiddenVideos)
|
||||
{
|
||||
videoPanel.Schedule = ATLSchedule;
|
||||
videoPanel.HomePlaylistAddingVideoPanelScheduleNumberBox.Value = ATLSchedule;
|
||||
}
|
||||
}
|
||||
|
||||
// TITLE AND AUTHOR FILTERS TEXTBOXS TEXT CHANGED
|
||||
private void HomePlaylistAddingPanelFilterTitleAndAuthorTextBox_LostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FilterChanged();
|
||||
}
|
||||
|
||||
// MIN VIEWS FILTERS NUMBERBOX VALUE CHANGED
|
||||
private void HomePlaylistAddingPanelFilterMinViewsNumberBox_LostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (double.IsNaN(HomePlaylistAddingPanelFilterMinViewsNumberBox.Value)) HomePlaylistAddingPanelFilterMinViewsNumberBox.Value = MinViews;
|
||||
FilterChanged();
|
||||
}
|
||||
|
||||
// MAX VIEWS FILTERS NUMBERBOX VALUE CHANGED
|
||||
private void HomePlaylistAddingPanelFilterMaxViewsNumberBox_LostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (double.IsNaN(HomePlaylistAddingPanelFilterMaxViewsNumberBox.Value)) HomePlaylistAddingPanelFilterMaxViewsNumberBox.Value = MaxViews;
|
||||
FilterChanged();
|
||||
}
|
||||
|
||||
// MIN AND MAX DATE FILTERS DATEPICKER VALUE CHANGED
|
||||
private void HomePlaylistAddingPanelFilterMinAndMaxDateDatePicker_LostFocus(object sender, RoutedEventArgs args)
|
||||
{
|
||||
FilterChanged();
|
||||
}
|
||||
|
||||
// MIN DURATION FILTERS TEXTBOX VALUE CHANGED
|
||||
private void HomePlaylistAddingPanelFilterMinDurationTextBox_LostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!HomePlaylistAddingPanelFilterMinDurationTextBox.Text.Contains('_'))
|
||||
{
|
||||
string[] segments = HomePlaylistAddingPanelFilterMinDurationTextBox.Text.Split(':').Reverse().ToArray();
|
||||
int.TryParse(segments.ElementAtOrDefault(0), out int seconds);
|
||||
int.TryParse(segments.ElementAtOrDefault(1), out int minutes);
|
||||
int.TryParse(segments.ElementAtOrDefault(2), out int hours);
|
||||
|
||||
TimeSpan parsedTimeSpan = new TimeSpan(hours, minutes, seconds);
|
||||
|
||||
if (parsedTimeSpan < MinDuration && parsedTimeSpan > MaxDuration)
|
||||
{
|
||||
if (Math.Floor(MaxDuration.TotalHours) > 0) HomePlaylistAddingPanelFilterMinDurationTextBox.Text += $"{Math.Floor(MinDuration.TotalHours)}:";
|
||||
if (Math.Floor(MaxDuration.TotalMinutes) > 0) HomePlaylistAddingPanelFilterMinDurationTextBox.Text += Math.Floor(MaxDuration.TotalHours) > 0 ? $"{MinDuration.Minutes:00}:" : $"{MinDuration.Minutes}:";
|
||||
HomePlaylistAddingPanelFilterMinDurationTextBox.Text += Math.Floor(MaxDuration.TotalMinutes) > 0 ? $"{MinDuration.Seconds:00}" : $"{MinDuration.Seconds}";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Math.Floor(MaxDuration.TotalHours) > 0) HomePlaylistAddingPanelFilterMinDurationTextBox.Text += $"{Math.Floor(MinDuration.TotalHours)}:";
|
||||
if (Math.Floor(MaxDuration.TotalMinutes) > 0) HomePlaylistAddingPanelFilterMinDurationTextBox.Text += Math.Floor(MaxDuration.TotalHours) > 0 ? $"{MinDuration.Minutes:00}:" : $"{MinDuration.Minutes}:";
|
||||
HomePlaylistAddingPanelFilterMinDurationTextBox.Text += Math.Floor(MaxDuration.TotalMinutes) > 0 ? $"{MinDuration.Seconds:00}" : $"{MinDuration.Seconds}";
|
||||
}
|
||||
FilterChanged();
|
||||
}
|
||||
|
||||
// MAX DURATION FILTERS TEXTBOX VALUE CHANGED
|
||||
private void HomePlaylistAddingPanelFilterMaxDurationTextBox_LostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!HomePlaylistAddingPanelFilterMaxDurationTextBox.Text.Contains('_'))
|
||||
{
|
||||
string[] segments = HomePlaylistAddingPanelFilterMaxDurationTextBox.Text.Split(':').Reverse().ToArray();
|
||||
int.TryParse(segments.ElementAtOrDefault(0), out int seconds);
|
||||
int.TryParse(segments.ElementAtOrDefault(1), out int minutes);
|
||||
int.TryParse(segments.ElementAtOrDefault(2), out int hours);
|
||||
|
||||
TimeSpan parsedTimeSpan = new TimeSpan(hours, minutes, seconds);
|
||||
|
||||
if (parsedTimeSpan < MinDuration && parsedTimeSpan > MaxDuration)
|
||||
{
|
||||
if (Math.Floor(MaxDuration.TotalHours) > 0) HomePlaylistAddingPanelFilterMaxDurationTextBox.Text += $"{Math.Floor(MaxDuration.TotalHours)}:";
|
||||
if (Math.Floor(MaxDuration.TotalMinutes) > 0) HomePlaylistAddingPanelFilterMaxDurationTextBox.Text += Math.Floor(MaxDuration.TotalHours) > 0 ? $"{MaxDuration.Minutes:00}:" : $"{MaxDuration.Minutes}:";
|
||||
HomePlaylistAddingPanelFilterMaxDurationTextBox.Text += Math.Floor(MaxDuration.TotalMinutes) > 0 ? $"{MaxDuration.Seconds:00}" : $"{MaxDuration.Seconds}";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Math.Floor(MaxDuration.TotalHours) > 0) HomePlaylistAddingPanelFilterMaxDurationTextBox.Text += $"{Math.Floor(MaxDuration.TotalHours)}:";
|
||||
if (Math.Floor(MaxDuration.TotalMinutes) > 0) HomePlaylistAddingPanelFilterMaxDurationTextBox.Text += Math.Floor(MaxDuration.TotalHours) > 0 ? $"{MaxDuration.Minutes:00}:" : $"{MaxDuration.Minutes}:";
|
||||
HomePlaylistAddingPanelFilterMaxDurationTextBox.Text += Math.Floor(MaxDuration.TotalMinutes) > 0 ? $"{MaxDuration.Seconds:00}" : $"{MaxDuration.Seconds}";
|
||||
}
|
||||
FilterChanged();
|
||||
}
|
||||
|
||||
// RESTORE REMOVED VIDEOS BUTTON CLICKED
|
||||
private void HomePlaylistAddingPanelFilterRemovedRestoreButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
foreach (HomePlaylistAddingPanelVideoPanel videoPanel in DeletedVideos)
|
||||
{
|
||||
HomePlaylistAddingPanelVideosList.Children.Add(videoPanel);
|
||||
}
|
||||
HomePlaylistAddingPanelFilterRemovedTextBlock.Visibility = Visibility.Collapsed;
|
||||
HomePlaylistAddingPanelFilterRemovedCountTextBlock.Visibility = Visibility.Collapsed;
|
||||
HomePlaylistAddingPanelFilterRemovedRestoreButton.Visibility = Visibility.Collapsed;
|
||||
HomePlaylistAddingPanelFilterHeaderCountTextBlock.Text = HiddenVideos.Count + DeletedVideos.Count > 0 ? $"{ResourceLoader.GetForCurrentView().GetString("HomePlaylistAddingPanelFilterHeaderCountTextBlockPrefix")}: {HiddenVideos.Count + DeletedVideos.Count}" : "";
|
||||
DeletedVideos.Clear();
|
||||
}
|
||||
|
||||
// SOURCE BUTTON CLICKED
|
||||
private async void HomePlaylistAddingPanelSourceButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Launch the website
|
||||
await Windows.System.Launcher.LaunchUriAsync(PlaylistService.PlaylistUrl);
|
||||
}
|
||||
|
||||
// ADD BUTTON CLICKED
|
||||
private void HomePlaylistAddingPanelAddButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var videos = new List<(IVideoService VideoService, MediaType MediaType, IBaseStream Stream, TimeSpan TrimStart, TimeSpan TrimEnd, string Filename, MediaFileExtension Extension, StorageFolder Location, double Schedule)>();
|
||||
foreach (HomePlaylistAddingPanelVideoPanel videoPanel in HomePlaylistAddingPanelVideosList.Children)
|
||||
{
|
||||
videos.Add((videoPanel.VideoService, videoPanel.MediaType, videoPanel.Stream, videoPanel.TrimStart, videoPanel.TrimEnd, videoPanel.Filename, videoPanel.Extension, videoPanel.Location, videoPanel.Schedule));
|
||||
}
|
||||
PlaylistAddEventArgs eventArgs = new PlaylistAddEventArgs { Videos = videos.ToArray() };
|
||||
PlaylistAddRequest?.Invoke(this, eventArgs);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region EVENT HANDLERS
|
||||
|
||||
public event EventHandler<PlaylistAddEventArgs> PlaylistAddRequest;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
128
VDownload/Views/Home/HomePlaylistAddingPanelVideoPanel.xaml
Normal file
128
VDownload/Views/Home/HomePlaylistAddingPanelVideoPanel.xaml
Normal file
@@ -0,0 +1,128 @@
|
||||
<UserControl
|
||||
x:Class="VDownload.Views.Home.HomePlaylistAddingPanelVideoPanel"
|
||||
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"
|
||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||
xmlns:cc="using:VDownload.Controls"
|
||||
xmlns:ex="using:Microsoft.Toolkit.Uwp.UI"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300"
|
||||
d:DesignWidth="400">
|
||||
|
||||
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="ms-appx:///Resources/Colors.xaml"/>
|
||||
<ResourceDictionary Source="ms-appx:///Resources/Icons.xaml"/>
|
||||
<ResourceDictionary Source="ms-appx:///Resources/Converters.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<x:String x:Key="MetadataIconSize">14</x:String>
|
||||
<x:String x:Key="MetadataTextSize">11</x:String>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
|
||||
|
||||
<muxc:Expander HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" Background="{ThemeResource HomePlaylistAddingVideoPanelContentBackgroundColor}">
|
||||
<muxc:Expander.Header>
|
||||
<Grid Margin="-5,10,-15,10" ColumnSpacing="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image Grid.Row="0" Grid.RowSpan="2" Grid.Column="0" Height="80" Source="{x:Bind ThumbnailImage}"/>
|
||||
<Grid Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left" ColumnSpacing="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Row="0" Grid.Column="0" Spacing="5" Orientation="Horizontal">
|
||||
<Image Width="{StaticResource MetadataIconSize}" Source="{ThemeResource AuthorIcon}"/>
|
||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="{StaticResource MetadataTextSize}" Text="{x:Bind Author}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="1" Grid.Column="0" Spacing="5" Orientation="Horizontal">
|
||||
<Image Width="{StaticResource MetadataIconSize}" Source="{ThemeResource ViewsIcon}"/>
|
||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="{StaticResource MetadataTextSize}" Text="{x:Bind Views}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" Spacing="5" Orientation="Horizontal">
|
||||
<Image Width="{StaticResource MetadataIconSize}" Source="{ThemeResource DateIcon}"/>
|
||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="{StaticResource MetadataTextSize}" Text="{x:Bind Date}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="1" Grid.Column="1" Spacing="5" Orientation="Horizontal">
|
||||
<Image Width="{StaticResource MetadataIconSize}" Source="{ThemeResource DurationIcon}"/>
|
||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="{StaticResource MetadataTextSize}" Text="{x:Bind Duration}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<TextBlock Grid.Row="0" Grid.Column="1" FontSize="15" VerticalAlignment="Center" FontWeight="SemiBold" Text="{x:Bind Title}"/>
|
||||
<AppBarButton Grid.Row="0" Grid.Column="2" Margin="0,-4,0,-4" Width="40" Height="48" Icon="{x:Bind SourceImage}" Click="HomePlaylistAddingVideoPanelSourceButton_Click"/>
|
||||
<AppBarButton Grid.Row="1" Grid.Column="2" Margin="0,-4,0,-4" Width="40" Height="48" Icon="Delete" Click="HomePlaylistAddingVideoPanelDeleteButton_Click"/>
|
||||
</Grid>
|
||||
</muxc:Expander.Header>
|
||||
<muxc:Expander.Content>
|
||||
<StackPanel Spacing="30">
|
||||
<StackPanel>
|
||||
<TextBlock x:Uid="HomePlaylistAddingVideoPanelDownloadingOptionsHeaderTextBlock" Margin="0,0,0,10" FontWeight="SemiBold"/>
|
||||
<cc:SettingControl x:Uid="HomePlaylistAddingVideoPanelMediaTypeSettingControl" Margin="0,0,0,10" Icon="{ThemeResource MediaTypeIcon}">
|
||||
<cc:SettingControl.SettingContent>
|
||||
<ComboBox x:Name="HomePlaylistAddingVideoPanelMediaTypeSettingControlComboBox" SelectionChanged="HomePlaylistAddingVideoPanelMediaTypeSettingControlComboBox_SelectionChanged"/>
|
||||
</cc:SettingControl.SettingContent>
|
||||
</cc:SettingControl>
|
||||
<cc:SettingControl x:Name="HomePlaylistAddingVideoPanelQualitySettingControl" Margin="0,0,0,10" x:Uid="HomePlaylistAddingVideoPanelQualitySettingControl" Icon="{ThemeResource QualityIcon}">
|
||||
<cc:SettingControl.SettingContent>
|
||||
<ComboBox x:Name="HomePlaylistAddingVideoPanelQualitySettingControlComboBox" SelectionChanged="HomePlaylistAddingVideoPanelQualitySettingControlComboBox_SelectionChanged"/>
|
||||
</cc:SettingControl.SettingContent>
|
||||
</cc:SettingControl>
|
||||
<cc:SettingControl x:Uid="HomePlaylistAddingVideoPanelTrimSettingControl" Icon="{ThemeResource TrimIcon}">
|
||||
<cc:SettingControl.SettingContent>
|
||||
<StackPanel Orientation="Horizontal" Spacing="5">
|
||||
<TextBox x:Name="HomePlaylistAddingVideoPanelTrimStartTextBox" ex:TextBoxExtensions.CustomMask="{x:Bind VideoService.Duration, Converter={StaticResource TimeSpanToTextBoxMaskElementsConverter}}" ex:TextBoxExtensions.Mask="{x:Bind VideoService.Duration, Converter={StaticResource TimeSpanToTextBoxMaskConverter}}" TextChanged="HomePlaylistAddingVideoPanelTrimStartTextBox_TextChanged"/>
|
||||
<TextBlock VerticalAlignment="Center" Text="-"/>
|
||||
<TextBox x:Name="HomePlaylistAddingVideoPanelTrimEndTextBox" ex:TextBoxExtensions.CustomMask="{x:Bind VideoService.Duration, Converter={StaticResource TimeSpanToTextBoxMaskElementsConverter}}" ex:TextBoxExtensions.Mask="{x:Bind VideoService.Duration, Converter={StaticResource TimeSpanToTextBoxMaskConverter}}" TextChanged="HomePlaylistAddingVideoPanelTrimEndTextBox_TextChanged"/>
|
||||
</StackPanel>
|
||||
</cc:SettingControl.SettingContent>
|
||||
</cc:SettingControl>
|
||||
</StackPanel>
|
||||
<StackPanel Spacing="10">
|
||||
<TextBlock x:Uid="HomePlaylistAddingVideoPanelFileOptionsHeaderTextBlock" FontWeight="SemiBold"/>
|
||||
<cc:SettingControl x:Uid="HomePlaylistAddingVideoPanelFileSettingControl" Icon="{ThemeResource FileIcon}">
|
||||
<cc:SettingControl.SettingContent>
|
||||
<Grid ColumnSpacing="10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox x:Name="HomePlaylistAddingVideoPanelFilenameTextBox" Grid.Column="0" MaxWidth="170" HorizontalAlignment="Right" IsSpellCheckEnabled="False" TextChanged="HomePlaylistAddingVideoPanelFilenameTextBox_TextChanged"/>
|
||||
<ComboBox x:Name="HomePlaylistAddingVideoPanelExtensionComboBox" Grid.Column="1" HorizontalAlignment="Stretch" SelectionChanged="HomePlaylistAddingVideoPanelExtensionComboBox_SelectionChanged"/>
|
||||
</Grid>
|
||||
</cc:SettingControl.SettingContent>
|
||||
</cc:SettingControl>
|
||||
<cc:SettingControl x:FieldModifier="public" x:Name="HomePlaylistAddingVideoPanelLocationSettingControl" x:Uid="HomePlaylistAddingVideoPanelLocationSettingControl" Icon="{ThemeResource LocationIcon}">
|
||||
<cc:SettingControl.SettingContent>
|
||||
<Button x:Uid="HomePlaylistAddingVideoPanelLocationBrowseButton" Click="HomePlaylistAddingVideoPanelLocationBrowseButton_Click"/>
|
||||
</cc:SettingControl.SettingContent>
|
||||
</cc:SettingControl>
|
||||
</StackPanel>
|
||||
<StackPanel Spacing="10">
|
||||
<TextBlock x:Uid="HomePlaylistAddingVideoPanelTaskOptionsHeaderTextBlock" FontWeight="SemiBold"/>
|
||||
<cc:SettingControl x:Uid="HomePlaylistAddingVideoPanelScheduleSettingControl" Icon="{ThemeResource ScheduleIcon}">
|
||||
<cc:SettingControl.SettingContent>
|
||||
<muxc:NumberBox x:FieldModifier="public" x:Name="HomePlaylistAddingVideoPanelScheduleNumberBox" MaxWidth="100" Value="0" Minimum="0" SpinButtonPlacementMode="Compact" ValueChanged="HomePlaylistAddingVideoPanelScheduleNumberBox_ValueChanged"/>
|
||||
</cc:SettingControl.SettingContent>
|
||||
</cc:SettingControl>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</muxc:Expander.Content>
|
||||
</muxc:Expander>
|
||||
</UserControl>
|
||||
321
VDownload/Views/Home/HomePlaylistAddingPanelVideoPanel.xaml.cs
Normal file
321
VDownload/Views/Home/HomePlaylistAddingPanelVideoPanel.xaml.cs
Normal file
@@ -0,0 +1,321 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using VDownload.Core.Enums;
|
||||
using VDownload.Core.Interfaces;
|
||||
using VDownload.Core.Services;
|
||||
using Windows.ApplicationModel.Resources;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
using Windows.Storage;
|
||||
using Windows.Storage.AccessCache;
|
||||
using Windows.Storage.Pickers;
|
||||
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.Media.Imaging;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
namespace VDownload.Views.Home
|
||||
{
|
||||
public sealed partial class HomePlaylistAddingPanelVideoPanel : UserControl
|
||||
{
|
||||
#region CONSTANTS
|
||||
|
||||
private readonly ResourceDictionary ImagesRes = new ResourceDictionary { Source = new Uri("ms-appx:///Resources/Images.xaml") };
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public HomePlaylistAddingPanelVideoPanel(IVideoService videoService)
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
// Set video service object
|
||||
VideoService = videoService;
|
||||
|
||||
// Set metadata
|
||||
ThumbnailImage = VideoService.Thumbnail != null ? new BitmapImage { UriSource = VideoService.Thumbnail } : (BitmapImage)ImagesRes["UnknownThumbnailImage"];
|
||||
SourceImage = new BitmapIcon { UriSource = new Uri($"ms-appx:///Assets/Sources/{VideoService.GetType().Namespace.Split(".").Last()}.png"), ShowAsMonochrome = false };
|
||||
Title = VideoService.Title;
|
||||
Author = VideoService.Author;
|
||||
Views = VideoService.Views.ToString();
|
||||
Date = VideoService.Date.ToString(CultureInfo.InstalledUICulture.DateTimeFormat.ShortDatePattern);
|
||||
Duration = $"{(Math.Floor(VideoService.Duration.TotalHours) > 0 ? $"{Math.Floor(VideoService.Duration.TotalHours):0}:" : "")}{VideoService.Duration.Minutes:00}:{VideoService.Duration.Seconds:00}";
|
||||
|
||||
// Set media type
|
||||
foreach (string mediaType in Enum.GetNames(typeof(MediaType)))
|
||||
{
|
||||
HomePlaylistAddingVideoPanelMediaTypeSettingControlComboBox.Items.Add(ResourceLoader.GetForCurrentView().GetString($"MediaType{mediaType}Text"));
|
||||
}
|
||||
HomePlaylistAddingVideoPanelMediaTypeSettingControlComboBox.SelectedIndex = (int)Config.GetValue("default_media_type");
|
||||
|
||||
// Set quality
|
||||
foreach (IBaseStream stream in VideoService.BaseStreams)
|
||||
{
|
||||
HomePlaylistAddingVideoPanelQualitySettingControlComboBox.Items.Add($"{stream.Height}p{(stream.FrameRate > 0 ? stream.FrameRate.ToString() : "N/A")}");
|
||||
}
|
||||
HomePlaylistAddingVideoPanelQualitySettingControlComboBox.SelectedIndex = 0;
|
||||
|
||||
// Set trim start
|
||||
if (Math.Floor(VideoService.Duration.TotalHours) > 0) HomePlaylistAddingVideoPanelTrimStartTextBox.Text += $"{new string('0', Math.Floor(VideoService.Duration.TotalHours).ToString().Length)}:";
|
||||
if (Math.Floor(VideoService.Duration.TotalMinutes) > 0) HomePlaylistAddingVideoPanelTrimStartTextBox.Text += Math.Floor(VideoService.Duration.TotalHours) > 0 ? "00:" : $"{new string('0', VideoService.Duration.Minutes.ToString().Length)}:";
|
||||
HomePlaylistAddingVideoPanelTrimStartTextBox.Text += Math.Floor(VideoService.Duration.TotalMinutes) > 0 ? "00" : $"{new string('0', VideoService.Duration.Seconds.ToString().Length)}";
|
||||
|
||||
// Set trim end
|
||||
if (Math.Floor(VideoService.Duration.TotalHours) > 0) HomePlaylistAddingVideoPanelTrimEndTextBox.Text += $"{Math.Floor(VideoService.Duration.TotalHours)}:";
|
||||
if (Math.Floor(VideoService.Duration.TotalMinutes) > 0) HomePlaylistAddingVideoPanelTrimEndTextBox.Text += Math.Floor(VideoService.Duration.TotalHours) > 0 ? $"{VideoService.Duration.Minutes:00}:" : $"{VideoService.Duration.Minutes}:";
|
||||
HomePlaylistAddingVideoPanelTrimEndTextBox.Text += Math.Floor(VideoService.Duration.TotalMinutes) > 0 ? $"{VideoService.Duration.Seconds:00}" : $"{VideoService.Duration.Seconds}";
|
||||
|
||||
// Set filename
|
||||
string temporaryFilename = (string)Config.GetValue("default_filename");
|
||||
Dictionary<string, string> filenameStandardTemplates = new Dictionary<string, string>()
|
||||
{
|
||||
{ "<title>", VideoService.Title },
|
||||
{ "<author>", VideoService.Author },
|
||||
{ "<views>", VideoService.Views.ToString() },
|
||||
{ "<id>", VideoService.ID },
|
||||
};
|
||||
foreach (KeyValuePair<string, string> template in filenameStandardTemplates) temporaryFilename = temporaryFilename.Replace(template.Key, template.Value);
|
||||
Dictionary<Regex, IFormattable> filenameFormatTemplates = new Dictionary<Regex, IFormattable>()
|
||||
{
|
||||
{ new Regex(@"<date_pub:(?<format>.*)>"), VideoService.Date },
|
||||
{ new Regex(@"<date_now:(?<format>.*)>"), DateTime.Now },
|
||||
{ new Regex(@"<duration:(?<format>.*)>"), VideoService.Duration },
|
||||
};
|
||||
foreach (KeyValuePair<Regex, IFormattable> template in filenameFormatTemplates) foreach (Match templateMatch in template.Key.Matches(temporaryFilename)) temporaryFilename = temporaryFilename.Replace(templateMatch.Value, template.Value.ToString(templateMatch.Groups["format"].Value, null));
|
||||
foreach (char c in System.IO.Path.GetInvalidFileNameChars()) temporaryFilename = temporaryFilename.Replace(c, ' ');
|
||||
HomePlaylistAddingVideoPanelFilenameTextBox.Text = temporaryFilename;
|
||||
Filename = temporaryFilename;
|
||||
|
||||
// Set location
|
||||
if (!(bool)Config.GetValue("custom_media_location") && StorageApplicationPermissions.FutureAccessList.ContainsItem("last_media_location"))
|
||||
{
|
||||
Task<StorageFolder> task = StorageApplicationPermissions.FutureAccessList.GetFolderAsync("last_media_location").AsTask();
|
||||
Location = task.Result;
|
||||
HomePlaylistAddingVideoPanelLocationSettingControl.Description = Location.Path;
|
||||
}
|
||||
else if ((bool)Config.GetValue("custom_media_location") && StorageApplicationPermissions.FutureAccessList.ContainsItem("custom_media_location"))
|
||||
{
|
||||
Task<StorageFolder> task = StorageApplicationPermissions.FutureAccessList.GetFolderAsync("selected_media_location").AsTask();
|
||||
Location = task.Result;
|
||||
HomePlaylistAddingVideoPanelLocationSettingControl.Description = Location.Path;
|
||||
}
|
||||
else
|
||||
{
|
||||
Location = null;
|
||||
HomePlaylistAddingVideoPanelLocationSettingControl.Description = $@"{UserDataPaths.GetDefault().Downloads}\VDownload";
|
||||
}
|
||||
|
||||
// Set minutes to start
|
||||
Schedule = 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
// BASE VIDEO DATA
|
||||
public IVideoService VideoService { get; set; }
|
||||
|
||||
// VIDEO DATA
|
||||
private ImageSource ThumbnailImage { get; set; }
|
||||
private IconElement SourceImage { get; set; }
|
||||
private string Title { get; set; }
|
||||
private string Author { get; set; }
|
||||
private string Views { get; set; }
|
||||
private string Date { get; set; }
|
||||
private string Duration { get; set; }
|
||||
|
||||
// VIDEO OPTIONS
|
||||
public MediaType MediaType { get; set; }
|
||||
public IBaseStream Stream { get; set; }
|
||||
public TimeSpan TrimStart { get; set; }
|
||||
public TimeSpan TrimEnd { get; set; }
|
||||
public string Filename { get; set; }
|
||||
public MediaFileExtension Extension { get; set; }
|
||||
public StorageFolder Location { get; set; }
|
||||
public double Schedule { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region EVENT HANDLERS VOIDS
|
||||
|
||||
// MEDIA TYPE COMBOBOX SELECTION CHANGED
|
||||
private void HomePlaylistAddingVideoPanelMediaTypeSettingControlComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
MediaType = (MediaType)HomePlaylistAddingVideoPanelMediaTypeSettingControlComboBox.SelectedIndex;
|
||||
if (HomePlaylistAddingVideoPanelMediaTypeSettingControlComboBox.SelectedIndex == (int)MediaType.OnlyAudio)
|
||||
{
|
||||
HomePlaylistAddingVideoPanelQualitySettingControl.Visibility = Visibility.Collapsed;
|
||||
HomePlaylistAddingVideoPanelQualitySettingControlComboBox.SelectedIndex = VideoService.BaseStreams.Count() - 1;
|
||||
|
||||
HomePlaylistAddingVideoPanelExtensionComboBox.Items.Clear();
|
||||
foreach (AudioFileExtension extension in Enum.GetValues(typeof(AudioFileExtension)))
|
||||
{
|
||||
HomePlaylistAddingVideoPanelExtensionComboBox.Items.Add(extension);
|
||||
}
|
||||
HomePlaylistAddingVideoPanelExtensionComboBox.SelectedIndex = (int)Config.GetValue("default_audio_extension") - 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
HomePlaylistAddingVideoPanelQualitySettingControl.Visibility = Visibility.Visible;
|
||||
HomePlaylistAddingVideoPanelQualitySettingControlComboBox.SelectedIndex = 0;
|
||||
|
||||
HomePlaylistAddingVideoPanelExtensionComboBox.Items.Clear();
|
||||
foreach (VideoFileExtension extension in Enum.GetValues(typeof(VideoFileExtension)))
|
||||
{
|
||||
HomePlaylistAddingVideoPanelExtensionComboBox.Items.Add(extension);
|
||||
}
|
||||
HomePlaylistAddingVideoPanelExtensionComboBox.SelectedIndex = (int)Config.GetValue("default_video_extension");
|
||||
}
|
||||
}
|
||||
|
||||
// QUALITY COMBOBOX SELECTION CHANGED
|
||||
private void HomePlaylistAddingVideoPanelQualitySettingControlComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
Stream = VideoService.BaseStreams[HomePlaylistAddingVideoPanelQualitySettingControlComboBox.SelectedIndex];
|
||||
}
|
||||
|
||||
// TRIM START TEXTBOX TEXT CHANGED
|
||||
private void HomePlaylistAddingVideoPanelTrimStartTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (!HomePlaylistAddingVideoPanelTrimStartTextBox.Text.Contains('_'))
|
||||
{
|
||||
string[] segments = HomePlaylistAddingVideoPanelTrimStartTextBox.Text.Split(':').Reverse().ToArray();
|
||||
int.TryParse(segments.ElementAtOrDefault(0), out int seconds);
|
||||
int.TryParse(segments.ElementAtOrDefault(1), out int minutes);
|
||||
int.TryParse(segments.ElementAtOrDefault(2), out int hours);
|
||||
|
||||
TimeSpan parsedTimeSpan = new TimeSpan(hours, minutes, seconds);
|
||||
|
||||
if (parsedTimeSpan < VideoService.Duration && parsedTimeSpan > new TimeSpan(0)) TrimStart = parsedTimeSpan;
|
||||
else
|
||||
{
|
||||
TrimStart = new TimeSpan(0);
|
||||
|
||||
string newText = string.Empty;
|
||||
if (Math.Floor(VideoService.Duration.TotalHours) > 0) newText += $"{new string('0', Math.Floor(VideoService.Duration.TotalHours).ToString().Length)}:";
|
||||
if (Math.Floor(VideoService.Duration.TotalMinutes) > 0) newText += Math.Floor(VideoService.Duration.TotalHours) > 0 ? "00:" : $"{new string('0', VideoService.Duration.Minutes.ToString().Length)}:";
|
||||
newText += Math.Floor(VideoService.Duration.TotalMinutes) > 0 ? "00" : $"{new string('0', VideoService.Duration.Seconds.ToString().Length)}";
|
||||
|
||||
if (newText != HomePlaylistAddingVideoPanelTrimStartTextBox.Text) HomePlaylistAddingVideoPanelTrimStartTextBox.Text = newText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TRIM END TEXTBOX TEXT CHANGED
|
||||
private void HomePlaylistAddingVideoPanelTrimEndTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (!HomePlaylistAddingVideoPanelTrimEndTextBox.Text.Contains('_'))
|
||||
{
|
||||
string[] segments = HomePlaylistAddingVideoPanelTrimEndTextBox.Text.Split(':').Reverse().ToArray();
|
||||
int.TryParse(segments.ElementAtOrDefault(0), out int seconds);
|
||||
int.TryParse(segments.ElementAtOrDefault(1), out int minutes);
|
||||
int.TryParse(segments.ElementAtOrDefault(2), out int hours);
|
||||
|
||||
TimeSpan parsedTimeSpan = new TimeSpan(hours, minutes, seconds);
|
||||
|
||||
if (parsedTimeSpan < VideoService.Duration && parsedTimeSpan > new TimeSpan(0)) TrimEnd = parsedTimeSpan;
|
||||
else
|
||||
{
|
||||
TrimEnd = VideoService.Duration;
|
||||
|
||||
string newText = string.Empty;
|
||||
if (Math.Floor(VideoService.Duration.TotalHours) > 0) newText += $"{Math.Floor(VideoService.Duration.TotalHours)}:";
|
||||
if (Math.Floor(VideoService.Duration.TotalMinutes) > 0) newText += Math.Floor(VideoService.Duration.TotalHours) > 0 ? $"{TrimEnd.Minutes:00}:" : $"{TrimEnd.Minutes}:";
|
||||
newText += Math.Floor(VideoService.Duration.TotalMinutes) > 0 ? $"{TrimEnd.Seconds:00}" : $"{TrimEnd.Seconds}";
|
||||
|
||||
if (newText != HomePlaylistAddingVideoPanelTrimEndTextBox.Text) HomePlaylistAddingVideoPanelTrimEndTextBox.Text = newText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FILENAME TEXTBOX TEXT CHANGED
|
||||
private void HomePlaylistAddingVideoPanelFilenameTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
string oldFilename = HomePlaylistAddingVideoPanelFilenameTextBox.Text;
|
||||
string newFilename = oldFilename;
|
||||
foreach (char c in System.IO.Path.GetInvalidFileNameChars()) newFilename = newFilename.Replace(c, ' ');
|
||||
if (oldFilename != newFilename)
|
||||
{
|
||||
HomePlaylistAddingVideoPanelFilenameTextBox.Text = newFilename;
|
||||
Filename = newFilename;
|
||||
}
|
||||
}
|
||||
|
||||
// EXTENSION COMBOBOX SELECTION CHANGED
|
||||
private void HomePlaylistAddingVideoPanelExtensionComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
Extension = (MediaFileExtension)HomePlaylistAddingVideoPanelExtensionComboBox.SelectedIndex + (MediaType == MediaType.OnlyAudio ? 3 : 0);
|
||||
}
|
||||
|
||||
// SCHEDULE NUMBERBOX VALUE CHANGED
|
||||
private void HomePlaylistAddingVideoPanelScheduleNumberBox_ValueChanged(Microsoft.UI.Xaml.Controls.NumberBox sender, Microsoft.UI.Xaml.Controls.NumberBoxValueChangedEventArgs args)
|
||||
{
|
||||
Schedule = HomePlaylistAddingVideoPanelScheduleNumberBox.Value;
|
||||
}
|
||||
|
||||
// LOCATION BROWSE BUTTON CLICKED
|
||||
private async void HomePlaylistAddingVideoPanelLocationBrowseButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FolderPicker picker = new FolderPicker
|
||||
{
|
||||
SuggestedStartLocation = PickerLocationId.Downloads
|
||||
};
|
||||
picker.FileTypeFilter.Add("*");
|
||||
|
||||
StorageFolder selectedFolder = await picker.PickSingleFolderAsync();
|
||||
|
||||
if (selectedFolder != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
await(await selectedFolder.CreateFileAsync("VDownloadLocationAccessTest")).DeleteAsync();
|
||||
StorageApplicationPermissions.FutureAccessList.AddOrReplace("last_media_location", selectedFolder);
|
||||
Location = selectedFolder;
|
||||
HomePlaylistAddingVideoPanelLocationSettingControl.Description = Location.Path;
|
||||
}
|
||||
catch (UnauthorizedAccessException) { }
|
||||
}
|
||||
}
|
||||
|
||||
// SOURCE BUTTON CLICKED
|
||||
private async void HomePlaylistAddingVideoPanelSourceButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Launch the website
|
||||
await Windows.System.Launcher.LaunchUriAsync(VideoService.VideoUrl);
|
||||
}
|
||||
|
||||
// DELETE BUTTON CLICKED
|
||||
private void HomePlaylistAddingVideoPanelDeleteButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DeleteRequested?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region EVENT HANDLERS
|
||||
|
||||
public event EventHandler DeleteRequested;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,14 @@
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image Grid.Row="0" Grid.RowSpan="3" Grid.Column="0" Height="120" Source="{x:Bind ThumbnailImage}"/>
|
||||
<TextBlock Grid.Row="0" Grid.Column="1" FontSize="18" VerticalAlignment="Center" FontWeight="SemiBold" Text="{x:Bind Title}"/>
|
||||
<Grid Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" ColumnSpacing="10" HorizontalAlignment="Left">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" FontSize="18" VerticalAlignment="Center" FontWeight="SemiBold" Text="{x:Bind Title}"/>
|
||||
<TextBlock Grid.Column="1" FontSize="12" VerticalAlignment="Bottom" FontWeight="Light" Text="{x:Bind Author}" Margin="0,0,0,2"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="1" Grid.RowSpan="2" Grid.Column="1" ColumnSpacing="5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
|
||||
@@ -24,8 +24,8 @@ namespace VDownload.Views.Home
|
||||
{
|
||||
#region CONSTANTS
|
||||
|
||||
ResourceDictionary IconsRes = new ResourceDictionary { Source = new Uri("ms-appx:///Resources/Icons.xaml") };
|
||||
ResourceDictionary ImagesRes = new ResourceDictionary { Source = new Uri("ms-appx:///Resources/Images.xaml") };
|
||||
private readonly ResourceDictionary IconsRes = new ResourceDictionary { Source = new Uri("ms-appx:///Resources/Icons.xaml") };
|
||||
private readonly ResourceDictionary ImagesRes = new ResourceDictionary { Source = new Uri("ms-appx:///Resources/Images.xaml") };
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -1,19 +1,4 @@
|
||||
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
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
namespace VDownload.Views.Home
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace VDownload.Views.Home
|
||||
{
|
||||
#region CONSTANTS
|
||||
|
||||
ResourceDictionary ImagesRes = new ResourceDictionary { Source = new Uri("ms-appx:///Resources/Images.xaml") };
|
||||
private readonly ResourceDictionary ImagesRes = new ResourceDictionary { Source = new Uri("ms-appx:///Resources/Images.xaml") };
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -47,7 +47,6 @@ namespace VDownload.Views.Home
|
||||
Date = VideoService.Date.ToString(CultureInfo.InstalledUICulture.DateTimeFormat.ShortDatePattern);
|
||||
Duration = $"{(Math.Floor(VideoService.Duration.TotalHours) > 0 ? $"{Math.Floor(VideoService.Duration.TotalHours):0}:" : "")}{VideoService.Duration.Minutes:00}:{VideoService.Duration.Seconds:00}";
|
||||
|
||||
|
||||
// Set media type
|
||||
foreach (string mediaType in Enum.GetNames(typeof(MediaType)))
|
||||
{
|
||||
|
||||
@@ -90,8 +90,6 @@ namespace VDownload.Views.Sources
|
||||
TwitchAuthWebView.Source = Core.Services.Sources.Twitch.Auth.AuthorizationUrl;
|
||||
ElementCompositionPreview.SetAppWindowContent(TwitchAuthWindow, TwitchAuthWebView);
|
||||
|
||||
TwitchAuthWindow.TryShowAsync();
|
||||
|
||||
// NavigationStarting event (only when redirected)
|
||||
TwitchAuthWebView.NavigationStarting += async (s, a) =>
|
||||
{
|
||||
@@ -147,6 +145,8 @@ namespace VDownload.Views.Sources
|
||||
}
|
||||
}
|
||||
|
||||
await TwitchAuthWindow.TryShowAsync();
|
||||
|
||||
// Clear cache
|
||||
TwitchAuthWebView.CoreWebView2.CookieManager.DeleteAllCookies();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user