Archived
1
0

Development 7

This commit is contained in:
Michael Gordeev
2018-07-22 15:00:47 +03:00
parent 57c90f4037
commit 0338d8a626
24 changed files with 727 additions and 359 deletions
+2 -2
View File
@@ -22,7 +22,7 @@ namespace FoxTube.Background
{
public static event NotificationHandler NotificationRecieved;
public List<Notification> Notifications = new List<Notification>();
List<Notification> Notifications = new List<Notification>();
private DateTime lastCheck = DateTime.Now;
private ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
@@ -124,7 +124,7 @@ namespace FoxTube.Background
doc["posts"].FirstChild["content"].InnerText,
XmlConvert.ToDateTime((doc["posts"].FirstChild as XmlElement).GetAttribute("time"),
XmlDateTimeSerializationMode.Unspecified),
(doc["posts"].FirstChild as XmlElement).GetAttribute("image")));
(doc["posts"].FirstChild as XmlElement).GetAttribute("image"), null));
return doc.InnerXml;
}
+5 -5
View File
@@ -18,25 +18,25 @@ namespace FoxTube.Background
Video, Comment, Post, Internal
}
public class Notification
public sealed class Notification
{
public string Channel { get; set; }
public string Content { get; set; }
public DateTime TimeStamp { get; set; }
public DateTimeOffset TimeStamp { get; set; }
public NotificationType Type { get; set; }
public string Avatar { get; set; }
public string Thumbnail { get; set; }
public string Id { get; set; }
public Notification(string type, string id,
string channelName, string content, DateTime date,
string thumbnailUrl, string avatarUrl = "ms-appx:///Assets/Icons/Profile.png")
string channelName, string content, DateTimeOffset date,
string thumbnailUrl, string avatarUrl)
{
Channel = channelName;
Content = content;
TimeStamp = date;
Type = TypeConversion(type);
Avatar = avatarUrl;
Avatar = avatarUrl == null? "ms-appx:///Assets/Icons/Profile.png" : avatarUrl;
Thumbnail = thumbnailUrl;
}
+10 -1
View File
@@ -38,11 +38,20 @@ namespace FoxTube
ApplicationName = "FoxTube"
});
public static YouTubeService Service => new YouTubeService(new BaseClientService.Initializer()
public static YouTubeService Service
{
get
{
if (IsAuthorized)
return new YouTubeService(new BaseClientService.Initializer()
{
HttpClientInitializer = Vault.Credential,
ApplicationName = "FoxTube"
});
else
return NoAuthService;
}
}
#endregion
#region Object containers
+31 -22
View File
@@ -1,36 +1,45 @@
<UserControl
x:Class="FoxTube.ChannelCard"
x:Class="FoxTube.Controls.ChannelCard"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FoxTube"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
HorizontalAlignment="Stretch"
Height="150">
VerticalAlignment="Top"
SizeChanged="UserControl_SizeChanged"
d:DesignHeight="290"
d:DesignWidth="384">
<Button Padding="0" Background="WhiteSmoke" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" Margin="2" VerticalAlignment="Stretch" Click="Button_Click">
<Button Padding="0" Background="Transparent" Click="Button_Click" VerticalContentAlignment="Stretch" VerticalAlignment="Stretch">
<Grid Background="WhiteSmoke" BorderBrush="LightGray" BorderThickness="1">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Image Name="thumbnail" Source="/Assets/ChannelCoverTemplate.png" Stretch="Fill"/>
<StackPanel Name="liveTag" Margin="5" Background="Red" BorderBrush="White" BorderThickness="1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Padding="5,2,5,3" Orientation="Horizontal" Visibility="Visible">
<TextBlock Text="&#xEC44; " VerticalAlignment="Center" Foreground="White" FontSize="12" FontFamily="Segoe MDL2 Assets" FontWeight="Black"/>
<TextBlock Name="liveContent" Text="LIVE" VerticalAlignment="Center" Foreground="White" FontSize="12" FontWeight="Bold"/>
</StackPanel>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="125"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<PersonPicture Name="avatar" Width="125"/>
<StackPanel Orientation="Vertical" Grid.Column="1" Padding="10,5,5,5" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal">
<TextBlock Name="channelName" Text="IGP" FontSize="18"/>
<StackPanel Name="liveTag" Margin="5,0,0,0" BorderBrush="Red" BorderThickness="2" VerticalAlignment="Center" HorizontalAlignment="Right" Padding="5,0,5,0" Height="20" Orientation="Horizontal" Visibility="Collapsed">
<TextBlock Text="&#xEC44; " VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Red" FontSize="12" FontFamily="Segoe MDL2 Assets" Margin="0,1,0,0" FontWeight="Black"/>
<TextBlock Text="LIVE" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Red" FontSize="12" FontWeight="Bold"/>
</StackPanel>
</StackPanel>
<TextBlock Name="subscribers" Text="120,452 subscribers" Foreground="Gray"/>
<TextBlock Name="videoCount" Foreground="Gray" Text="563,000 videos"/>
<StackPanel Orientation="Horizontal" Margin="0,5,0,0" Name="subscriptionPane">
<ToggleButton Grid.Column="2" Height="40" Width="200" Background="Red" Foreground="White" FontSize="18" FontWeight="SemiBold" Content="Subscirbe"/>
<ToggleButton Grid.Column="3" Height="40" Width="40" FontFamily="Segoe MDL2 Assets" FontSize="18" FontWeight="SemiBold" Content="" Foreground="White" Background="Red"/>
</StackPanel>
</StackPanel>
<Ellipse Grid.Column="0" Height="80" Width="80" Margin="0,-45,0,0" VerticalAlignment="Bottom" Fill="WhiteSmoke"/>
<PersonPicture Name="avatar" Grid.Column="0" Height="74" Margin="3,-45,3,3" VerticalAlignment="Bottom" BorderBrush="White" BorderThickness="10"/>
<TextBlock Name="channelName" Grid.Column="1" Text="Markiplier"/>
<TextBlock Grid.Column="1" Name="views" Text="[Views]" HorizontalAlignment="Right" Foreground="Gray" Margin="0,2,2,0" FontSize="12"/>
</Grid>
<TextBlock Grid.Row="1" Name="title" Text="[Title]" TextWrapping="WrapWholeWords" Margin="5" MaxLines="2" Foreground="Gray"/>
</Grid>
</Grid>
</Button>
</UserControl>
+2 -40
View File
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
@@ -12,54 +11,17 @@ 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;
using Google.Apis.Services;
using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
namespace FoxTube
namespace FoxTube.Controls
{
public sealed partial class ChannelCard : UserControl
{
string channelId;
public ChannelCard(string id, string live)
public ChannelCard()
{
this.InitializeComponent();
Initialize(id, live);
}
public async void Initialize(string id, string live)
{
YouTubeService ytService = new YouTubeService(new BaseClientService.Initializer()
{
ApiKey = "AIzaSyBgHrCnrlzlVmk0cJKL8RqP9Y8x6XSuk_0",
ApplicationName = this.GetType().ToString()
});
ChannelsResource.ListRequest request = ytService.Channels.List("snippet,contentDetails,statistics");
request.Id = id;
ChannelListResponse response = await request.ExecuteAsync();
var item = response.Items[0];
channelId = id;
channelName.Text = item.Snippet.Title;
subscribers.Text = string.Format("{0} subscribers", item.Statistics.SubscriberCount);
videoCount.Text = string.Format("{0} videos", item.Statistics.VideoCount);
avatar.ProfilePicture = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url));
if (live == "live")
liveTag.Visibility = Visibility.Visible;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Methods.MainPage.GoToChannel(channelId);
}
}
}
+36
View File
@@ -0,0 +1,36 @@
<UserControl
x:Class="FoxTube.Controls.ChannelCardWide"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FoxTube"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
HorizontalAlignment="Stretch"
Height="150">
<Button Padding="0" Background="WhiteSmoke" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" Margin="2" VerticalAlignment="Stretch" Click="Button_Click">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="125"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<PersonPicture Name="avatar" Width="125"/>
<StackPanel Orientation="Vertical" Grid.Column="1" Padding="10,5,5,5" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal">
<TextBlock Name="channelName" Text="IGP" FontSize="18"/>
<StackPanel Name="liveTag" Margin="5,0,0,0" BorderBrush="Red" BorderThickness="2" VerticalAlignment="Center" HorizontalAlignment="Right" Padding="5,0,5,0" Height="20" Orientation="Horizontal" Visibility="Collapsed">
<TextBlock Text="&#xEC44; " VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Red" FontSize="12" FontFamily="Segoe MDL2 Assets" Margin="0,1,0,0" FontWeight="Black"/>
<TextBlock Text="LIVE" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Red" FontSize="12" FontWeight="Bold"/>
</StackPanel>
</StackPanel>
<TextBlock Name="subscribers" Text="120,452 subscribers" Foreground="Gray"/>
<TextBlock Name="videoCount" Foreground="Gray" Text="563,000 videos"/>
<StackPanel Orientation="Horizontal" Margin="0,5,0,0" Name="subscriptionPane">
<ToggleButton Grid.Column="2" Height="40" Width="200" Background="Red" Foreground="White" FontSize="18" FontWeight="SemiBold" Content="Subscirbe"/>
<ToggleButton Grid.Column="3" Height="40" Width="40" FontFamily="Segoe MDL2 Assets" FontSize="18" FontWeight="SemiBold" Content="" Foreground="White" Background="Red"/>
</StackPanel>
</StackPanel>
</Grid>
</Button>
</UserControl>
+50
View File
@@ -0,0 +1,50 @@
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media.Imaging;
using Google.Apis.Services;
using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
namespace FoxTube.Controls
{
public sealed partial class ChannelCardWide : UserControl
{
string channelId;
public ChannelCardWide(string id, string live)
{
this.InitializeComponent();
Initialize(id, live);
}
public async void Initialize(string id, string live)
{
YouTubeService ytService = new YouTubeService(new BaseClientService.Initializer()
{
ApiKey = "AIzaSyBgHrCnrlzlVmk0cJKL8RqP9Y8x6XSuk_0",
ApplicationName = this.GetType().ToString()
});
ChannelsResource.ListRequest request = ytService.Channels.List("snippet,contentDetails,statistics");
request.Id = id;
ChannelListResponse response = await request.ExecuteAsync();
var item = response.Items[0];
channelId = id;
channelName.Text = item.Snippet.Title;
subscribers.Text = string.Format("{0} subscribers", item.Statistics.SubscriberCount);
videoCount.Text = string.Format("{0} videos", item.Statistics.VideoCount);
avatar.ProfilePicture = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url));
if (live == "live")
liveTag.Visibility = Visibility.Visible;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Methods.MainPage.GoToChannel(channelId);
}
}
}
+14
View File
@@ -0,0 +1,14 @@
<UserControl
x:Class="FoxTube.Controls.ShowMore"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FoxTube.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid>
<HyperlinkButton Foreground="Red" HorizontalAlignment="Center" Content="Show more" Name="btn" Click="btn_Click"/>
<ProgressBar Name="bar" IsIndeterminate="True" Foreground="Red" Visibility="Collapsed"/>
</Grid>
</UserControl>
+44
View File
@@ -0,0 +1,44 @@
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 FoxTube.Controls
{
public delegate void Event();
public sealed partial class ShowMore : UserControl
{
public event Event Clicked;
public ShowMore()
{
this.InitializeComponent();
}
private void btn_Click(object sender, RoutedEventArgs e)
{
btn.Visibility = Visibility.Collapsed;
bar.Visibility = Visibility.Visible;
Clicked.Invoke();
}
public void Complete(bool close = false)
{
bar.Visibility = Visibility.Collapsed;
if (!close)
btn.Visibility = Visibility.Visible;
}
}
}
+13 -16
View File
@@ -1,8 +1,7 @@
<UserControl
x:Class="FoxTube.VideoCard"
x:Class="FoxTube.Controls.VideoCard"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FoxTube"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
@@ -12,36 +11,36 @@
d:DesignHeight="290"
d:DesignWidth="384">
<Button Padding="0" Background="Transparent" VerticalAlignment="Top" Click="Button_Click">
<Button Padding="0" Background="Transparent" Click="Button_Click">
<Grid Background="WhiteSmoke" BorderBrush="LightGray" BorderThickness="1">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="75"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Background="Black">
<Image Name="thumbnail" Source="Assets/videoThumbSample.png" Stretch="Fill"/>
<Grid Background="Black">
<Image Name="thumbnail" Source="/Assets/videoThumbSample.png" Stretch="Fill"/>
<Grid Background="#7FFFFFFF" Name="watched" Visibility="Collapsed">
<StackPanel Margin="5" Background="WhiteSmoke" VerticalAlignment="Top" HorizontalAlignment="Left" Padding="5,2,5,2" BorderBrush="Gray" BorderThickness="1">
<TextBlock Text="Watched" Foreground="Gray" FontSize="12"/>
</StackPanel>
</Grid>
<StackPanel Margin="0,0,5,5" Background="WhiteSmoke" VerticalAlignment="Bottom" HorizontalAlignment="Right" Padding="5,2,5,0" Height="20">
<StackPanel Margin="0,0,5,5" Background="WhiteSmoke" VerticalAlignment="Bottom" HorizontalAlignment="Right" Padding="5,2,5,3">
<TextBlock Name="info" Text="[Duration] | [Published at]" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Gray" FontSize="12"/>
</StackPanel>
<StackPanel Name="liveTag" Margin="0,0,5,30" Background="Red" BorderBrush="White" BorderThickness="1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Padding="5,0,5,0" Height="20" Orientation="Horizontal" Visibility="Collapsed">
<TextBlock Text="&#xEC44; " VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White" FontSize="12" FontFamily="Segoe MDL2 Assets" Margin="0,1,0,0" FontWeight="Black"/>
<TextBlock Name="liveContent" Text="LIVE" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White" FontSize="12" FontWeight="Bold"/>
<StackPanel Name="liveTag" Margin="0,0,5,30" Background="Red" BorderBrush="White" BorderThickness="1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Padding="5,2,5,3" Orientation="Horizontal" Visibility="Collapsed">
<TextBlock Text="&#xEC44; " VerticalAlignment="Center" Foreground="White" FontSize="12" FontFamily="Segoe MDL2 Assets" FontWeight="Black"/>
<TextBlock Name="liveContent" Text="LIVE" VerticalAlignment="Center" Foreground="White" FontSize="12" FontWeight="Bold"/>
</StackPanel>
</Grid>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition Height="5*"/>
<RowDefinition Height="20"/>
<RowDefinition Height="55"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Ellipse Grid.Column="0" Height="50" Width="50" Margin="5,-30,5,10" Fill="WhiteSmoke"/>
<PersonPicture Name="avatar" Grid.Column="0" Height="46" Margin="5,-30,5,0" BorderBrush="White" BorderThickness="10"/>
@@ -49,9 +48,7 @@
<TextBlock Name="channelName" Grid.Column="1" Text="[Channel name]" Foreground="Gray" Margin="0,2,0,0" FontSize="12"/>
<TextBlock Grid.Column="1" Name="views" Text="[Views]" HorizontalAlignment="Right" Foreground="Gray" Margin="0,2,2,0" FontSize="12"/>
</Grid>
<StackPanel Grid.Row="1">
<TextBlock Name="title" Text="[Title]" TextWrapping="WrapWholeWords" Margin="5" FontSize="14" MaxLines="2"/>
</StackPanel>
<TextBlock Grid.Row="1" Name="title" Text="[Title]" TextWrapping="WrapWholeWords" Margin="5" MaxLines="2"/>
</Grid>
</Grid>
</Button>
+47 -47
View File
@@ -1,36 +1,21 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
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;
using Google.Apis.Services;
using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
using Windows.UI.Xaml.Media.Imaging;
using System.Xml;
using Windows.System;
using Windows.UI.Popups;
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
namespace FoxTube
namespace FoxTube.Controls
{
public sealed partial class VideoCard : UserControl
{
public string videoId;
Google.Apis.YouTube.v3.Data.Video item;
bool embed = false;
bool embed = true;
public VideoCard(string id)
{
this.InitializeComponent();
@@ -51,58 +36,73 @@ namespace FoxTube
VideoListResponse response = await request.ExecuteAsync();
item = response.Items[0];
videoId = id;
title.Text = item.Snippet.Title;
views.Text = string.Format("{0} views", item.Statistics.ViewCount);
string duration;
if (!string.IsNullOrWhiteSpace(item.ContentDetails.Duration))
{
TimeSpan ts = XmlConvert.ToTimeSpan(item.ContentDetails.Duration);
duration = string.Format("{0}{1:00}:{2:00} | ", ts.Hours == 0 ? "" : ts.Hours + ":", ts.Minutes, ts.Seconds);
}
else duration = string.Empty;
info.Text = string.Format("{0}{1} | {2}", duration, Methods.GetAgo(item.Snippet.PublishedAt.Value), (item.LiveStreamingDetails != null && item.LiveStreamingDetails.ConcurrentViewers.HasValue) ? item.LiveStreamingDetails.ConcurrentViewers + " viewers" : item.Statistics.ViewCount + " views");
thumbnail.Source = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url));
channelName.Text = item.Snippet.ChannelTitle;
if (item.Snippet.LiveBroadcastContent == "live")
{
embed = true;
views.Text = $"{item.LiveStreamingDetails.ConcurrentViewers} viewers";
if (item.LiveStreamingDetails.ScheduledStartTime.HasValue && item.LiveStreamingDetails.ScheduledEndTime.HasValue)
info.Text = $"{item.LiveStreamingDetails.ScheduledEndTime - item.LiveStreamingDetails.ScheduledStartTime} | {Methods.GetAgo(item.LiveStreamingDetails.ActualStartTime.Value)}";
else
info.Text = item.LiveStreamingDetails.ActualStartTime.Value.ToString();
liveTag.Visibility = Visibility.Visible;
}
else if(item.Snippet.LiveBroadcastContent == "upcoming")
{
embed = true;
TimeSpan span;
if (item.LiveStreamingDetails.ScheduledStartTime != null && (item.LiveStreamingDetails.ScheduledStartTime - DateTime.Now).Value.TotalMilliseconds > 0)
{
span = (TimeSpan)(item.LiveStreamingDetails.ScheduledStartTime - DateTime.Now);
liveContent.Text = "Goes live in " + string.Format("{0}{1:00}:{2:00}:{3:00}", span.Days != 0 ? span.Days + ":" : "", span.Hours, span.Minutes, span.Seconds);
views.Text = "";
if (item.LiveStreamingDetails.ScheduledStartTime.HasValue && item.LiveStreamingDetails.ScheduledEndTime.HasValue)
info.Text = $"{item.LiveStreamingDetails.ScheduledEndTime - item.LiveStreamingDetails.ScheduledStartTime} | {item.LiveStreamingDetails.ScheduledStartTime}";
else
info.Text = $"{Methods.GetAgo(item.Snippet.PublishedAt.Value)}";
liveTag.Visibility = Visibility.Visible;
if (item.LiveStreamingDetails.ScheduledStartTime.HasValue && (item.LiveStreamingDetails.ScheduledStartTime - DateTime.Now).Value.TotalMilliseconds > 0)
liveContent.Text = $"Goes live in {item.LiveStreamingDetails.ScheduledStartTime}";
else liveContent.Text = "Upcoming";
}
else
liveContent.Text = "Upcoming";
liveTag.Visibility = Visibility.Visible;
{
views.Text = $"{item.Statistics.ViewCount} views";
info.Text = $"{XmlConvert.ToTimeSpan(item.ContentDetails.Duration)} | {Methods.GetAgo(item.Snippet.PublishedAt.Value)}";
embed = false;
}
var request1 = ytService.Channels.List("snippet,contentDetails,statistics");
var request1 = ytService.Channels.List("snippet");
request1.Id = item.Snippet.ChannelId;
ChannelListResponse response1 = await request1.ExecuteAsync();
var item1 = response1.Items[0];
try
{
avatar.ProfilePicture = new BitmapImage(new Uri(response1.Items[0].Snippet.Thumbnails.Medium.Url));
thumbnail.Source = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url));
}
catch { }
avatar.ProfilePicture = new BitmapImage(new Uri(item1.Snippet.Thumbnails.Medium.Url));
channelName.Text = item1.Snippet.Title;
if (SecretsVault.UserHistory.Contains(item.Id))
foreach(PlaylistItem i in SecretsVault.UserHistory)
if (i.Snippet.ResourceId.VideoId == id)
{
watched.Visibility = Visibility.Visible;
break;
}
}
private async void Button_Click(object sender, RoutedEventArgs e)
{
if (embed)
await Launcher.LaunchUriAsync(new Uri(string.Format("https://www.youtube.com/watch?v={0}", videoId)));
{
MessageDialog dialog = new MessageDialog("Unfortunately, at this stage of application development we don't support live steams. This issue will be fixed in the next update. Sorry. Would you like us to open this stream in browser?", "Open in browser");
dialog.Commands.Add(new UICommand("Yes", async (command) =>
{
await Launcher.LaunchUriAsync(new Uri($"https://www.youtube.com/watch?v={videoId}"));
}));
dialog.Commands.Add(new UICommand("No"));
dialog.DefaultCommandIndex = 0;
dialog.CancelCommandIndex = 1;
await dialog.ShowAsync();
}
else
Methods.MainPage.GoToVideo(videoId);
}
+2 -2
View File
@@ -92,8 +92,8 @@ namespace FoxTube
channelName.Text = item1.Snippet.Title;
channelSubs.Text = string.Format("{0} subscribers", item1.Statistics.SubscriberCount);
if (SecretsVault.UserHistory.Contains(item.Id))
watched.Visibility = Visibility.Visible;
//if (SecretsVault.UserHistory.Contains(item.Id))
//watched.Visibility = Visibility.Visible;
}
private void channelLink_Click(object sender, RoutedEventArgs e)
+17 -3
View File
@@ -98,6 +98,9 @@
</Compile>
<Compile Include="Classes\Methods.cs" />
<Compile Include="Classes\ObjectEventArgs.cs" />
<Compile Include="Controls\ChannelCard.xaml.cs">
<DependentUpon>ChannelCard.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\CommentCard.xaml.cs">
<DependentUpon>CommentCard.xaml</DependentUpon>
</Compile>
@@ -105,14 +108,17 @@
<Compile Include="Controls\DownloadItem.xaml.cs">
<DependentUpon>DownloadItem.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\ShowMore.xaml.cs">
<DependentUpon>ShowMore.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\SuggestionsQueries.xaml.cs">
<DependentUpon>SuggestionsQueries.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\Channel.xaml.cs">
<DependentUpon>Channel.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\ChannelCard.xaml.cs">
<DependentUpon>ChannelCard.xaml</DependentUpon>
<Compile Include="Controls\ChannelCardWide.xaml.cs">
<DependentUpon>ChannelCardWide.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\CommentsPage.xaml.cs">
<DependentUpon>CommentsPage.xaml</DependentUpon>
@@ -258,6 +264,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="Controls\ChannelCard.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\CommentCard.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -266,6 +276,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\ShowMore.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\SuggestionsQueries.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -274,7 +288,7 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\ChannelCard.xaml">
<Page Include="Controls\ChannelCardWide.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+1 -1
View File
@@ -35,7 +35,7 @@
<Pivot SelectedIndex="0" Name="content" IsHeaderItemsCarouselEnabled="False" SelectionChanged="content_SelectionChanged">
<PivotItem Margin="0,-48,0,0">
<StackPanel Name="videos">
<Image Name="channelCover" Stretch="Uniform" Source="Assets/ChannelCoverTemplate.png"/>
<Image Name="channelCover" Stretch="Uniform" Source="/Assets/ChannelCoverTemplate.png"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
+7 -10
View File
@@ -9,11 +9,11 @@
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Name="grid">
<Grid.RowDefinitions>
<RowDefinition Height="0"/>
<RowDefinition Height="*"/>
<RowDefinition Height="auto"/>
<RowDefinition/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Background="Red">
<StackPanel Orientation="Horizontal" Margin="10,0,10,0">
<StackPanel Name="navigation" Visibility="Collapsed" Orientation="Horizontal" Padding="10,0,10,0" Background="Red" Height="47">
<HyperlinkButton Name="toRecommended" Click="toRecommended_Click" Foreground="White" Margin="0,0,10,0">
<TextBlock Text="Recommended"/>
</HyperlinkButton>
@@ -24,10 +24,8 @@
<TextBlock Text="Subscriptions"/>
</HyperlinkButton>
</StackPanel>
</Grid>
<Grid Grid.Row="1">
<ScrollViewer Margin="0,0,0,50">
<Pivot Name="pivot">
<ScrollViewer Grid.Row="1">
<Pivot Name="pivot" SelectionChanged="pivot_SelectionChanged">
<PivotItem Margin="0,-48,0,0">
</PivotItem>
@@ -39,9 +37,8 @@
</PivotItem>
</Pivot>
</ScrollViewer>
<CommandBar VerticalAlignment="Bottom">
<CommandBar Grid.Row="2">
<AppBarButton Icon="Refresh" Label="Refresh page" Name="refresh" Click="refresh_Click"/>
</CommandBar>
</Grid>
</Grid>
</Page>
+75 -24
View File
@@ -17,6 +17,7 @@ using System.Globalization;
using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
using Windows.Storage;
using Windows.UI.Text;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
@@ -27,6 +28,9 @@ namespace FoxTube
/// </summary>
public sealed partial class Home : Page
{
private bool recLoaded = false;
private bool trendLoaded = false;
private bool subsLoaded = false;
public Home()
{
this.InitializeComponent();
@@ -35,7 +39,6 @@ namespace FoxTube
public async void Initialize()
{
#region Vairables declaring
VideoGrid videoGrid = new VideoGrid();
string reg;
@@ -47,58 +50,106 @@ namespace FoxTube
{
reg = (ApplicationData.Current.LocalSettings.Values["region"] as string).ToUpper();
}
#endregion
pivot.Items.Clear();
grid.RowDefinitions[0].Height = new GridLength(0);
#region Request-Response
VideosResource.ListRequest request = SecretsVault.NoAuthService.Videos.List("snippet,contentDetails,statistics");
request.Chart = VideosResource.ListRequest.ChartEnum.MostPopular;
request.RegionCode = reg;
VideosResource.ListRequest request = SecretsVault.Service.Videos.List("id");
request.MaxResults = 48;
if(SecretsVault.IsAuthorized)
{
navigation.Visibility = Visibility.Visible;
for(int k = 0; k < 3; k++)
{
StackPanel stack = new StackPanel();
stack.Children.Add(new VideoGrid());
stack.Children.Add(new LoadingPage());
pivot.Items.Add(new PivotItem()
{
Margin = new Thickness(0, -48, 0, 0),
Content = stack
});
}
//Initializing recommended videos loading
recLoaded = true;
(((pivot.Items[0] as PivotItem).Content as StackPanel).Children[1] as LoadingPage).Block();
}
else
{
Grid g = new Grid();
StackPanel stack = new StackPanel();
stack.Children.Add(new VideoGrid());
stack.Children.Add(new HyperlinkButton()
{
});
g.Children.Add(stack);
g.Children.Add(new LoadingPage());
pivot.Items.Add(new PivotItem()
{
Margin = new Thickness(0, -48, 0, 0),
Content = g
});
//Initializing recommended videos loading
request.Chart = VideosResource.ListRequest.ChartEnum.MostPopular;
request.RegionCode = reg;
VideoListResponse response = await request.ExecuteAsync();
#endregion
foreach (Google.Apis.YouTube.v3.Data.Video vid in response.Items)
{
VideoCard vCard = new VideoCard(vid.Id);
videoGrid.AddCards(vCard);
}
pivot.Items.Add(new PivotItem()
{
Margin = new Thickness(0,-48,0,0),
Name = "trending",
Content = videoGrid
});
/*if((Parent as MainPage).Logged)
{
grid.RowDefinitions[0].Height = new GridLength(47);
//TO-DO: Add initializing recommended and subscriptions tabs
}*/
trendLoaded = true;
}
}
private void toRecommended_Click(object sender, RoutedEventArgs e)
{
pivot.SelectedIndex = 0;
}
private void toTrending_Click(object sender, RoutedEventArgs e)
{
if (pivot.Items.Count > 1)
pivot.SelectedIndex = 1;
else
pivot.SelectedIndex = 0;
}
private void tosubs_Click(object sender, RoutedEventArgs e)
{
pivot.SelectedIndex = 2;
}
private void refresh_Click(object sender, RoutedEventArgs e)
{
Initialize();
}
private void pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
toRecommended.FontWeight = FontWeights.Normal;
toTrending.FontWeight = FontWeights.Normal;
tosubs.FontWeight = FontWeights.Normal;
switch(pivot.SelectedIndex)
{
case 2:
tosubs.FontWeight = FontWeights.Bold;
break;
case 1:
toTrending.FontWeight = FontWeights.Bold;
break;
case 0:
if (pivot.Items.Count > 1)
toRecommended.FontWeight = FontWeights.Bold;
else toTrending.FontWeight = FontWeights.Bold;
break;
}
}
}
}
+8 -1
View File
@@ -22,7 +22,7 @@ namespace FoxTube
/// </summary>
public sealed partial class LoadingPage : Page
{
public event EventHandler RefreshPage;
public event RoutedEventHandler RefreshPage;
public LoadingPage()
{
@@ -54,6 +54,7 @@ namespace FoxTube
public void Block()
{
Visibility = Visibility.Visible;
ring.IsActive = false;
trouble.Visibility = Visibility.Collapsed;
wifiTrouble.Visibility = Visibility.Collapsed;
@@ -86,10 +87,16 @@ namespace FoxTube
public void Refresh()
{
Visibility = Visibility.Visible;
ring.IsActive = true;
trouble.Visibility = Visibility.Collapsed;
wifiTrouble.Visibility = Visibility.Collapsed;
blockIcon.Visibility = Visibility.Collapsed;
}
public void Close()
{
Visibility = Visibility.Collapsed;
}
}
}
+5 -1
View File
@@ -108,6 +108,10 @@
<SplitView Name="menu" Grid.Row="1" OpenPaneLength="250" CompactPaneLength="50" DisplayMode="CompactInline" IsPaneOpen="True" PaneClosing="menu_PaneClosed" PaneOpening="menu_PaneOpened">
<SplitView.Pane>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<ScrollViewer>
<StackPanel>
<ListBox Name="mainList" SelectionChanged="HamburgerSelectionChanged">
@@ -211,7 +215,7 @@
</ListBox>
</StackPanel>
</ScrollViewer>
<ListBox VerticalAlignment="Bottom" Name="serviceList" SelectionChanged="HamburgerSelectionChanged">
<ListBox Grid.Row="1" VerticalAlignment="Bottom" Name="serviceList" SelectionChanged="HamburgerSelectionChanged">
<ListBoxItem Padding="0" IsEnabled="False">
<Line X2="250" Stroke="Gray"/>
</ListBoxItem>
+12 -3
View File
@@ -194,6 +194,8 @@ namespace FoxTube
}
private void HamburgerSelectionChanged(object sender, SelectionChangedEventArgs e)
{
try
{
if (sender == mainList)
{
@@ -230,6 +232,7 @@ namespace FoxTube
categoriesList.SelectedItem = null;
serviceList.SelectedItem = null;
}
} catch { }
}
void MainListSelected()
@@ -371,10 +374,14 @@ namespace FoxTube
}
private void menu_PaneOpened(SplitView sender, object args)
{
try
{
subsTitle.Visibility = Visibility.Visible;
catTitle.Visibility = Visibility.Visible;
}
catch { }
}
private async void createAccount_Click(object sender, RoutedEventArgs e)
{
@@ -418,8 +425,10 @@ namespace FoxTube
private void searchButton_Click(object sender, RoutedEventArgs e)
{
if (searchField.Text != "" || (!(content.Content is Search) && (content.Content as Search).Term != searchField.Text))
if (!string.IsNullOrWhiteSpace(searchField.Text) || !(content.Content is Search))
content.Navigate(typeof(Search), searchField.Text);
else if (content.Content is Search)
(content.Content as Search).Initialize(searchField.Text);
}
public void GoToSearch(string keyword)
@@ -428,7 +437,7 @@ namespace FoxTube
searchButton_Click(this, null);
}
private async void StartSearch(string keyword)
/*private async void StartSearch(string keyword)
{
content.Navigate(typeof(Search));
HamburgerSelectionChanged(null, null);
@@ -458,7 +467,7 @@ namespace FoxTube
s.ring.IsActive = false;
s.content.Visibility = Visibility.Visible;
Debug.WriteLine("done");
}
}*/
private void searchField_KeyUp(object sender, KeyRoutedEventArgs e)
{
+64 -29
View File
@@ -5,41 +5,76 @@
xmlns:local="using:FoxTube"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:FoxTube.Controls"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid Name="grid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<ScrollViewer>
<Grid>
<ProgressRing HorizontalAlignment="Center" VerticalAlignment="Center" IsActive="True" Name="progressRing" Foreground="Red" Width="100" Height="100"/>
<StackPanel Orientation="Vertical" Margin="10" Visibility="Collapsed" Name="displaying">
<StackPanel Orientation="Horizontal">
<TextBlock Text="Search results for: " FontSize="28"/>
<TextBlock Name="searchTerm" Text="[searchTerm]" FontSize="28" Margin="10,0,0,0"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Found:" FontSize="14" Foreground="Gray" Margin="0,-5,0,10"/>
<TextBlock Name="resultsCount" Text="[resultsCount]" FontSize="14" Foreground="Gray" Margin="5,-5,0,10"/>
<TextBlock Text="items" FontSize="14" Foreground="Gray" Margin="5,-5,0,10"/>
</StackPanel>
<HyperlinkButton Content="Show filters &#xE71C;" FontFamily="Default, Segoe MDL2 Assets" FontSize="18" Visibility="Collapsed"/>
<Grid Background="WhiteSmoke" Padding="5" Visibility="Collapsed">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel>
<TextBlock Text="Type" FontSize="20"/>
<Line StrokeThickness="1" Stroke="Gray" X1="0" X2="150"/>
<RadioButton Content="All" IsChecked="True"/>
<RadioButton Content="Videos"/>
<RadioButton Content="Channels"/>
<RadioButton Content="Playlists"/>
</StackPanel>
</Grid>
<StackPanel Name="resultsList" Orientation="Vertical">
<StackPanel Margin="10">
<TextBlock Name="searchTerm" Text="Search results for: [searchTerm]" FontSize="28"/>
<TextBlock Name="resultsCount" Text="Found: [resultCount] item(s)" FontSize="14" Foreground="Gray"/>
<HyperlinkButton Name="toggleFilters" Click="toggleFilters_Click" Content="Show filters &#xE71C;" FontFamily="Default, Segoe MDL2 Assets" Visibility="Visible"/>
<StackPanel Name="filters" Visibility="Collapsed">
<GridView Padding="5" Visibility="Visible">
<ComboBox Name="order" Header="Sort by" Width="150" SelectedIndex="0">
<ComboBoxItem Content="Relevance"/>
<ComboBoxItem Content="Upload date"/>
<ComboBoxItem Content="View count"/>
<ComboBoxItem Content="Rating"/>
<ComboBoxItem Content="Title"/>
</ComboBox>
<ComboBox Name="type" Header="Type" Width="150" SelectedIndex="0">
<ComboBoxItem Content="All"/>
<ComboBoxItem Content="Video"/>
<ComboBoxItem Content="Channel"/>
<ComboBoxItem Content="Playlist"/>
</ComboBox>
<ComboBox Name="date" Header="Upload date" Width="150" SelectedIndex="0">
<ComboBoxItem Content="Anytime"/>
<ComboBoxItem Content="Last hour"/>
<ComboBoxItem Content="Today"/>
<ComboBoxItem Content="This week"/>
<ComboBoxItem Content="This month"/>
<ComboBoxItem Content="This year"/>
</ComboBox>
<ComboBox Name="duration" Header="Duration" Width="150" SelectedIndex="0">
<ComboBoxItem Content="Any"/>
<ComboBoxItem Content="Short (&#x3C; 4 minutes)"/>
<ComboBoxItem Content="Medium"/>
<ComboBoxItem Content="Long (&#x3E; 20 minutes)"/>
</ComboBox>
</GridView>
<StackPanel Orientation="Horizontal">
<Button Content="Features" Margin="10,0,0,10">
<Button.Flyout>
<Flyout>
<ListView Name="features" SelectionMode="Multiple" Header="Features">
<TextBlock Text="HD"/>
<TextBlock Text="3D"/>
<TextBlock Text="Subtitles/CC"/>
<TextBlock Text="Live"/>
<TextBlock Text="Creative Commons"/>
</ListView>
</Flyout>
</Button.Flyout>
</Button>
<Button Content="Apply" Margin="10,0,0,10"/>
</StackPanel>
</StackPanel>
</Grid>
<local:VideoGrid Name="list"/>
<controls:ShowMore Name="more" Clicked="more_Clicked" Visibility="Collapsed"/>
</StackPanel>
</ScrollViewer>
<CommandBar Grid.Row="1" DefaultLabelPosition="Right">
<AppBarButton Label="Refresh" Icon="Refresh" Click="AppBarButton_Click"/>
</CommandBar>
<local:LoadingPage Name="loading" Grid.RowSpan="2" Visibility="Collapsed" RefreshPage="AppBarButton_Click"/>
</Grid>
</Page>
+200 -14
View File
@@ -1,4 +1,5 @@
using Google.Apis.YouTube.v3.Data;
using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -7,6 +8,7 @@ using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Storage;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
@@ -25,22 +27,22 @@ namespace FoxTube
public sealed partial class Search : Page
{
public string Term;
public ProgressRing ring;
public StackPanel content;
SearchResource.ListRequest request;
string nextToken;
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
public Search()
{
this.InitializeComponent();
ring = progressRing;
content = displaying;
}
public void SetResults(string keyword, int count)
public string SetResults(int? count)
{
searchTerm.Text = keyword;
if (count == 1000000)
resultsCount.Text = count + "+";
return count + "+";
else if (count == null)
return "0";
else
resultsCount.Text = count.ToString();
return count.ToString();
}
public void AddItem(SearchResult result)
@@ -49,23 +51,207 @@ namespace FoxTube
{
case "youtube#video":
VideoCardWide vCard = new VideoCardWide(result.Id.VideoId);
resultsList.Children.Add(vCard);
list.Add(vCard);
break;
case "youtube#channel":
ChannelCard cCard = new ChannelCard(result.Id.ChannelId, result.Snippet.LiveBroadcastContent);
resultsList.Children.Add(cCard);
list.Add(cCard);
break;
case "youtube#playlist":
PlaylistCardWide pCard = new PlaylistCardWide(result.Id.PlaylistId);
resultsList.Children.Add(pCard);
list.Add(pCard);
break;
}
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (e.Parameter == null)
loading.Error("NullReferenceException", "Unable to initialize search. Search term is not stated.");
else
Initialize(e.Parameter as string);
}
public async void Initialize(string term, bool forceInitialization = false)
{
if (term == Term && !forceInitialization)
return;
loading.Refresh();
try
{
Term = term;
request = SecretsVault.Service.Search.List("id");
request.Q = term;
request.SafeSearch = (SearchResource.ListRequest.SafeSearchEnum)(int)settings.Values["safeSearch"];
try
{
request.RelevanceLanguage = settings.Values["region"].ToString().Remove(2).ToLower();
}
catch (ArgumentOutOfRangeException)
{
request.RelevanceLanguage = settings.Values["region"].ToString().ToLower();
}
request.MaxResults = 48;
request.Order = Order;
request.Type = Type;
request.PublishedAfter = Date;
if (Duration != SearchResource.ListRequest.VideoDurationEnum.Any)
{
request.Type = "video";
type.SelectedIndex = 1;
request.VideoDuration = Duration;
}
request.VideoDuration = Duration;
if (features.SelectedItems.Count > 0)
{
request.Type = "video";
type.SelectedIndex = 1;
if (features.SelectedItems.Contains(features.Items[0]))
request.VideoDefinition = SearchResource.ListRequest.VideoDefinitionEnum.High;
if (features.SelectedItems.Contains(features.Items[1]))
request.VideoDimension = SearchResource.ListRequest.VideoDimensionEnum.Value3d;
if (features.SelectedItems.Contains(features.Items[2]))
request.VideoCaption = SearchResource.ListRequest.VideoCaptionEnum.ClosedCaption;
if (features.SelectedItems.Contains(features.Items[3]))
request.EventType = SearchResource.ListRequest.EventTypeEnum.Live;
if (features.SelectedItems.Contains(features.Items[4]))
request.VideoLicense = SearchResource.ListRequest.VideoLicenseEnum.CreativeCommon;
}
SearchListResponse response = await request.ExecuteAsync();
searchTerm.Text = $"Search results for: {Term}";
resultsCount.Text = $"Found: {SetResults(response.PageInfo.TotalResults)} item(s)";
if (response.NextPageToken != null)
{
nextToken = response.NextPageToken;
more.Visibility = Visibility.Visible;
}
foreach (SearchResult item in response.Items)
AddItem(item);
loading.Close();
}
catch
{
loading.Error();
}
}
private void toggleFilters_Click(object sender, RoutedEventArgs e)
{
if(filters.Visibility == Visibility.Collapsed)
{
filters.Visibility = Visibility.Visible;
toggleFilters.Content = "Hide filters &#xE71C;";
}
else
{
filters.Visibility = Visibility.Collapsed;
toggleFilters.Content = "Show filters &#xE71C;";
}
}
SearchResource.ListRequest.OrderEnum Order
{
get
{
switch (order.SelectedIndex)
{
case 1:
return SearchResource.ListRequest.OrderEnum.Date;
case 2:
return SearchResource.ListRequest.OrderEnum.ViewCount;
case 3:
return SearchResource.ListRequest.OrderEnum.Rating;
case 4:
return SearchResource.ListRequest.OrderEnum.Title;
default:
Debug.WriteLine("Skipped");
break;
return SearchResource.ListRequest.OrderEnum.Relevance;
}
}
}
string Type
{
get
{
switch(type.SelectedIndex)
{
case 1:
return "video";
case 2:
return "channel";
case 3:
return "playlist";
default:
return "video,channel,playlist";
}
}
}
DateTime? Date
{
get
{
switch(date.SelectedIndex)
{
case 1:
return DateTime.Now.Subtract(TimeSpan.FromHours(1));
case 2:
return DateTime.Now.Subtract(TimeSpan.FromDays(1));
case 3:
return DateTime.Now.Subtract(TimeSpan.FromDays(7));
case 4:
return DateTime.Now.Subtract(TimeSpan.FromDays(31));
case 5:
return DateTime.Now.Subtract(TimeSpan.FromDays(365));
default:
return null;
}
}
}
SearchResource.ListRequest.VideoDurationEnum Duration
{
get
{
switch (type.SelectedIndex)
{
case 1:
return SearchResource.ListRequest.VideoDurationEnum.Short__;
case 2:
return SearchResource.ListRequest.VideoDurationEnum.Medium;
case 3:
return SearchResource.ListRequest.VideoDurationEnum.Long__;
default:
return SearchResource.ListRequest.VideoDurationEnum.Any;
}
}
}
private void AppBarButton_Click(object sender, RoutedEventArgs e)
{
Initialize(Term, true);
}
private async void more_Clicked()
{
request.PageToken = nextToken;
SearchListResponse response = await request.ExecuteAsync();
foreach (SearchResult item in response.Items)
AddItem(item);
if (response.NextPageToken != null)
{
nextToken = response.NextPageToken;
more.Complete();
}
else
more.Complete(true);
}
}
}
+3 -3
View File
@@ -190,7 +190,7 @@ namespace FoxTube
LoadRelatedVideos();
if (SecretsVault.IsAuthorized && SecretsVault.UserHistory[0] != item.Id)
/*if (SecretsVault.IsAuthorized && SecretsVault.UserHistory[0] != item.Id)
{
await SecretsVault.Service.PlaylistItems.Insert(new PlaylistItem()
{
@@ -205,7 +205,7 @@ namespace FoxTube
}
}, "snippet").ExecuteAsync();
SecretsVault.UserHistory.Insert(0, item.Id);
}
}*/
}
catch
{
@@ -595,7 +595,7 @@ namespace FoxTube
PlaylistId = SecretsVault.UserChannel.ContentDetails.RelatedPlaylists.WatchLater
}
}, "snippet").ExecuteAsync();
SecretsVault.WatchLater.Insert(0, new KeyValuePair<string, string>(pi.Id, item.Id));
SecretsVault.WatchLater.Insert(0, pi);
}
else
{
+4 -15
View File
@@ -5,23 +5,12 @@
xmlns:local="using:FoxTube"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
x:Name="root"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Padding="5" Name="grid" SizeChanged="grid_SizeChanged">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" Grid.Column="0" Name="col0">
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="1" Name="col1">
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="2" Name="col2">
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="3" Name="col3">
</StackPanel>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<controls:AdaptiveGridView Name="list" OneRowModeEnabled="False" DesiredWidth="384" SelectionMode="None"/>
<TextBlock Name="empty" Text="&#xD8;" FontSize="200" Foreground="Gray" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Grid>
</Page>
+4 -49
View File
@@ -15,6 +15,7 @@ using Windows.UI.Xaml.Navigation;
using System.Diagnostics;
using System.Timers;
using Windows.UI.Core;
using Microsoft.Toolkit.Uwp.UI.Controls;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
@@ -25,61 +26,15 @@ namespace FoxTube
/// </summary>
public sealed partial class VideoGrid : Page
{
int cols = 0;
List<VideoCard> cards = new List<VideoCard>();
public VideoGrid()
{
this.InitializeComponent();
}
public void AddCards(VideoCard vCard)
public void Add(UIElement card)
{
cards.Add(vCard);
}
void SetColumns(int num)
{
cols = num;
for (int k = 0; k < grid.ColumnDefinitions.Count; k++)
grid.ColumnDefinitions[k].Width = new GridLength(1, GridUnitType.Star);
for (int k = num; k < grid.ColumnDefinitions.Count; k++)
grid.ColumnDefinitions[k].Width = new GridLength(0);
col0.Children.Clear();
col1.Children.Clear();
col2.Children.Clear();
col3.Children.Clear();
for (int k = 0; k < cards.Count; k += num)
col0.Children.Add(cards[k]);
if(num > 1)
{
for (int k = 1; k < cards.Count; k += num)
col1.Children.Add(cards[k]);
if(num > 2)
{
for (int k = 2; k < cards.Count; k += num)
col2.Children.Add(cards[k]);
if(num > 3)
{
for (int k = 3; k < cards.Count; k += num)
col3.Children.Add(cards[k]);
}
}
}
}
private void grid_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (e.NewSize.Width >= 1000 && cols != 4)
SetColumns(4);
else if (e.NewSize.Width >= 800 && e.NewSize.Width < 1000 && cols != 3)
SetColumns(3);
else if (e.NewSize.Width >= 600 && e.NewSize.Width < 800 && cols != 2)
SetColumns(2);
else if (e.NewSize.Width < 600 && cols != 1)
SetColumns(1);
list.Items.Add(card);
empty.Visibility = Visibility.Collapsed;
}
}
}