Archived
1
0

Development 666(?)

This commit is contained in:
Michael Gordeev
2018-08-29 23:07:02 +03:00
parent 94d59f1dba
commit 866b4ef373
19 changed files with 296 additions and 224 deletions
+2
View File
@@ -11,7 +11,9 @@ using Windows.Foundation;
using Windows.Foundation.Collections; using Windows.Foundation.Collections;
using Windows.Globalization; using Windows.Globalization;
using Windows.Storage; using Windows.Storage;
using Windows.UI;
using Windows.UI.Core; using Windows.UI.Core;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives; using Windows.UI.Xaml.Controls.Primitives;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 KiB

After

Width:  |  Height:  |  Size: 31 KiB

+3 -3
View File
@@ -17,7 +17,7 @@
<RowDefinition/> <RowDefinition/>
<RowDefinition Height="auto"/> <RowDefinition Height="auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Image Name="cover" Source="/Assets/videoThumbSample.png" Stretch="UniformToFill" VerticalAlignment="Center"/> <Image Name="cover" Source="/Assets/ChannelCoverTemplate.png" Stretch="UniformToFill" VerticalAlignment="Center"/>
<StackPanel Name="liveTag" Margin="5" Background="Red" BorderBrush="White" BorderThickness="1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Padding="5,2,5,3" Orientation="Horizontal" Visibility="Collapsed"> <StackPanel Name="liveTag" Margin="5" 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 Text="&#xEC44; " VerticalAlignment="Center" Foreground="White" FontSize="12" FontFamily="Segoe MDL2 Assets" FontWeight="Black"/>
<TextBlock Text="LIVE" VerticalAlignment="Center" Foreground="White" FontSize="12" FontWeight="Bold"/> <TextBlock Text="LIVE" VerticalAlignment="Center" Foreground="White" FontSize="12" FontWeight="Bold"/>
@@ -45,8 +45,8 @@
<TextBlock Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Height="50" Margin="10" TextAlignment="Center" Padding="0,16,0,0" Foreground="Gray"> <TextBlock Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Height="50" Margin="10" TextAlignment="Center" Padding="0,16,0,0" Foreground="Gray">
<Hyperlink Click="Hyperlink_Click">Log in</Hyperlink> to manage your subscriptions <Hyperlink Click="Hyperlink_Click">Log in</Hyperlink> to manage your subscriptions
</TextBlock> </TextBlock>
<Grid Visibility="Collapsed" Grid.Row="1" VerticalAlignment="Bottom" Margin="10" Name="subscriptionPane" Background="Red"> <Grid Visibility="Collapsed" Grid.Row="1" VerticalAlignment="Bottom" Margin="10" Name="subscriptionPane" Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}">
<ToggleButton Click="subscribe_Click" Name="subscribe" HorizontalAlignment="Stretch" Height="50" Background="Red" Foreground="White" FontSize="18" FontWeight="SemiBold" Content="Subscirbe" Margin="0,0,0,0"/> <Button Click="subscribe_Click" Name="subscribe" HorizontalAlignment="Stretch" Height="50" Background="Red" Foreground="White" FontSize="18" FontWeight="SemiBold" Content="Subscirbe" Margin="0,0,0,0"/>
<ToggleButton Name="notify" Height="50" Width="50" Visibility="Collapsed" FontFamily="Segoe MDL2 Assets" FontSize="18" FontWeight="SemiBold" Content="&#xE7ED;" Foreground="White" Background="Red" HorizontalAlignment="Right"/> <ToggleButton Name="notify" Height="50" Width="50" Visibility="Collapsed" FontFamily="Segoe MDL2 Assets" FontSize="18" FontWeight="SemiBold" Content="&#xE7ED;" Foreground="White" Background="Red" HorizontalAlignment="Right"/>
</Grid> </Grid>
</Grid> </Grid>
+18 -9
View File
@@ -7,6 +7,7 @@ using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime; using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation; using Windows.Foundation;
using Windows.Foundation.Collections; using Windows.Foundation.Collections;
using Windows.UI;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives; using Windows.UI.Xaml.Controls.Primitives;
@@ -59,16 +60,20 @@ namespace FoxTube.Controls
{ {
if(s.Snippet.ResourceId.ChannelId == id) if(s.Snippet.ResourceId.ChannelId == id)
{ {
subscribe.IsChecked = true; subscribe.Background = new SolidColorBrush(Colors.Transparent);
subscribe.Foreground = new SolidColorBrush(Colors.Gray);
subscribe.Content = "Subscribed"; subscribe.Content = "Subscribed";
} }
} }
subscriptionPane.Visibility = Visibility.Visible; subscriptionPane.Visibility = Visibility.Visible;
} }
try { avatar.ProfilePicture = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url)); }
catch { }
try try
{ {
avatar.ProfilePicture = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url)); if (item.BrandingSettings.Image.BannerImageUrl.Contains("default"))
throw new Exception("Default channel cover detected");
cover.Source = new BitmapImage(new Uri(item.BrandingSettings.Image.BannerTvLowImageUrl)); cover.Source = new BitmapImage(new Uri(item.BrandingSettings.Image.BannerTvLowImageUrl));
} }
catch { } catch { }
@@ -86,20 +91,24 @@ namespace FoxTube.Controls
private async void subscribe_Click(object sender, RoutedEventArgs e) private async void subscribe_Click(object sender, RoutedEventArgs e)
{ {
if (subscribe.IsChecked.Value) if (subscribe.Background == new SolidColorBrush(Colors.Red))
{ {
if (!await SecretsVault.Subscribe(channelId)) if (await SecretsVault.Subscribe(channelId))
subscribe.IsChecked = false; {
else subscribe.Background = new SolidColorBrush(Colors.Transparent);
subscribe.Foreground = new SolidColorBrush(Colors.Gray);
subscribe.Content = "Subscribed"; subscribe.Content = "Subscribed";
} }
}
else else
{ {
if (!await SecretsVault.Unsubscibe(channelId)) if (await SecretsVault.Unsubscibe(channelId))
subscribe.IsChecked = true; {
else subscribe.Background = new SolidColorBrush(Colors.Red);
subscribe.Foreground = new SolidColorBrush(Colors.White);
subscribe.Content = "Subscribe"; subscribe.Content = "Subscribe";
} }
} }
} }
}
} }
+3 -3
View File
@@ -82,7 +82,7 @@ namespace FoxTube.Controls
else else
more.Visibility = Visibility.Collapsed; more.Visibility = Visibility.Collapsed;
foreach (Comment c in response.Items) foreach (Comment c in response.Items.Reverse())
replies.Children.Add(new CommentCard(c)); replies.Children.Add(new CommentCard(c));
} }
} }
@@ -111,7 +111,7 @@ namespace FoxTube.Controls
rating.Text = comment.Snippet.LikeCount.HasValue ? comment.Snippet.LikeCount.ToString() : ""; rating.Text = comment.Snippet.LikeCount.HasValue ? comment.Snippet.LikeCount.ToString() : "";
meta.Text = string.Format("{0} | {1} {2}", comment.Snippet.AuthorDisplayName, Methods.GetAgo(comment.Snippet.PublishedAt.Value), comment.Snippet.UpdatedAt.Value != comment.Snippet.PublishedAt.Value ? "(edited)" : ""); meta.Text = string.Format("{0} | {1} {2}", comment.Snippet.AuthorDisplayName, Methods.GetAgo(comment.Snippet.PublishedAt.Value), comment.Snippet.UpdatedAt.Value != comment.Snippet.PublishedAt.Value ? "(edited)" : "");
text.Text = comment.Snippet.TextDisplay; Methods.FormatText(ref text, comment.Snippet.TextDisplay);
try { avatar.ProfilePicture = new BitmapImage(new Uri(comment.Snippet.AuthorProfileImageUrl)); } try { avatar.ProfilePicture = new BitmapImage(new Uri(comment.Snippet.AuthorProfileImageUrl)); }
catch { } catch { }
@@ -147,7 +147,7 @@ namespace FoxTube.Controls
request.TextFormat = CommentsResource.ListRequest.TextFormatEnum.PlainText; request.TextFormat = CommentsResource.ListRequest.TextFormatEnum.PlainText;
var response = await request.ExecuteAsync(); var response = await request.ExecuteAsync();
foreach (Comment c in response.Items) foreach (Comment c in response.Items.Reverse())
replies.Children.Add(new CommentCard(c)); replies.Children.Add(new CommentCard(c));
if (response.NextPageToken != null) if (response.NextPageToken != null)
+2 -2
View File
@@ -9,7 +9,7 @@
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="1080" d:DesignHeight="1080"
d:DesignWidth="1920" d:DesignWidth="1920"
DoubleTapped="UserControl_DoubleTapped" RequestedTheme="Dark"
PointerMoved="UserControl_PointerMoved" PointerMoved="UserControl_PointerMoved"
PointerExited="UserControl_PointerExited" PointerExited="UserControl_PointerExited"
PointerEntered="UserControl_PointerEntered"> PointerEntered="UserControl_PointerEntered">
@@ -41,7 +41,7 @@
</StackPanel> </StackPanel>
</Grid> </Grid>
<Grid Grid.Row="1" Name="playPauseArea" Tapped="playPauseArea_Tapped"/> <Grid Grid.Row="1" Name="playPauseArea" Tapped="playPauseArea_Tapped" DoubleTapped="playPauseArea_DoubleTapped" Background="Black" Opacity=".0001"/>
<Grid Name="touchCentral" Background="#7F000000" Visibility="Collapsed" Grid.Row="1"> <Grid Name="touchCentral" Background="#7F000000" Visibility="Collapsed" Grid.Row="1">
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center"> <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
+4 -3
View File
@@ -40,7 +40,7 @@ namespace FoxTube
{ {
public string videoId; public string videoId;
private bool miniView = false; public bool miniView = false;
private bool fullScreen = false; private bool fullScreen = false;
public bool pointerCaptured = false; public bool pointerCaptured = false;
@@ -783,7 +783,7 @@ namespace FoxTube
await connection.RequestStartCastingAsync(videoSource.GetAsCastingSource()); await connection.RequestStartCastingAsync(videoSource.GetAsCastingSource());
} }
private void UserControl_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e) private void playPauseArea_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
{ {
if (miniView && ApplicationView.GetForCurrentView().ViewMode == ApplicationViewMode.CompactOverlay) if (miniView && ApplicationView.GetForCurrentView().ViewMode == ApplicationViewMode.CompactOverlay)
miniView_Click(this, null); miniView_Click(this, null);
@@ -797,7 +797,8 @@ namespace FoxTube
private void playPauseArea_Tapped(object sender, TappedRoutedEventArgs e) private void playPauseArea_Tapped(object sender, TappedRoutedEventArgs e)
{ {
if (e.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse) ; if (e.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse && !miniView)
play_Click(this, null);
} }
} }
} }
+6 -4
View File
@@ -1,4 +1,5 @@
<Page <Page
NavigationCacheMode="Disabled"
x:Class="FoxTube.Pages.ChannelPage" x:Class="FoxTube.Pages.ChannelPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@@ -26,8 +27,9 @@
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<PersonPicture Name="avatar" Grid.Column="0" HorizontalAlignment="Left" Margin="10,-40,0,0" ProfilePicture="/Assets/LogoAvatar.png"/> <Ellipse HorizontalAlignment="Left" Margin="10,-40,0,0" Fill="Black" Width="100" Height="100"/>
<StackPanel Grid.Column="1" Orientation="Vertical" Margin="10,0,0,0"> <PersonPicture Name="avatar" HorizontalAlignment="Left" Margin="10,-40,0,0"/>
<StackPanel Grid.Column="1" Orientation="Vertical" Margin="10,0,0,5">
<TextBlock Name="title" FontWeight="SemiBold" FontSize="22" Text="Channel name"/> <TextBlock Name="title" FontWeight="SemiBold" FontSize="22" Text="Channel name"/>
<TextBlock Name="subscribers" Foreground="Gray" Text="1,000,000 subscribers"/> <TextBlock Name="subscribers" Foreground="Gray" Text="1,000,000 subscribers"/>
<TextBlock Name="videosCount" Foreground="Gray" Text="563,000 videos"/> <TextBlock Name="videosCount" Foreground="Gray" Text="563,000 videos"/>
@@ -36,8 +38,8 @@
<Hyperlink Click="Hyperlink_Click">Log in</Hyperlink> to manage your subscriptions <Hyperlink Click="Hyperlink_Click">Log in</Hyperlink> to manage your subscriptions
</TextBlock> </TextBlock>
<Grid Visibility="Visible" Grid.Column="2" VerticalAlignment="Bottom" Margin="10" Name="subscriptionPane" Background="Red"> <Grid Visibility="Visible" Grid.Column="2" VerticalAlignment="Bottom" Margin="10" Name="subscriptionPane" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<ToggleButton Click="subscribe_Click" Name="subscribe" Width="250" Height="50" Background="Red" Foreground="White" FontSize="18" FontWeight="SemiBold" Content="Subscirbe"/> <Button Click="subscribe_Click" Name="subscribe" Width="250" Height="50" Background="Red" Foreground="White" FontSize="18" FontWeight="SemiBold" Content="Subscirbe"/>
</Grid> </Grid>
</Grid> </Grid>
<pages:VideoGrid/> <pages:VideoGrid/>
+29 -12
View File
@@ -25,6 +25,8 @@ using Windows.ApplicationModel.DataTransfer;
using Windows.ApplicationModel; using Windows.ApplicationModel;
using Windows.Storage.Streams; using Windows.Storage.Streams;
using Windows.System; using Windows.System;
using Windows.UI;
using System.Diagnostics;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
@@ -97,10 +99,13 @@ namespace FoxTube.Pages
try try
{ {
if (item.BrandingSettings.Image.BannerImageUrl.Contains("default"))
throw new Exception("Default channel cover detected");
channelCover.Source = new BitmapImage(new Uri(item.BrandingSettings.Image.BannerImageUrl)); channelCover.Source = new BitmapImage(new Uri(item.BrandingSettings.Image.BannerImageUrl));
avatar.ProfilePicture = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url));
} }
catch { } catch { }
try { avatar.ProfilePicture = new BitmapImage(new Uri(item.Snippet.Thumbnails.Medium.Url)); }
catch { }
Methods.FormatText(ref description, item.Snippet.Description); Methods.FormatText(ref description, item.Snippet.Description);
views.Text = $"{item.Statistics.ViewCount:0,0}"; views.Text = $"{item.Statistics.ViewCount:0,0}";
@@ -128,14 +133,22 @@ namespace FoxTube.Pages
if (SecretsVault.IsAuthorized) if (SecretsVault.IsAuthorized)
{ {
SecretsVault.Subscriptions.ForEach(x => Debug.WriteLine($"{x.Snippet.Title}: {x.Snippet.ResourceId.ChannelId}"));
Debug.WriteLine($"Current channel ID: {item.Id}");
bool b = false;
foreach (Subscription s in SecretsVault.Subscriptions) foreach (Subscription s in SecretsVault.Subscriptions)
{ {
if (s.Snippet.ResourceId.ChannelId == id) if (s.Snippet.ResourceId.ChannelId == item.Id)
{ {
subscribe.IsChecked = true; Debug.WriteLine($"{s.Snippet.ResourceId.ChannelId} ({item.Snippet.Title}: {item.Id})");
subscribe.Background = new SolidColorBrush(Colors.Transparent);
subscribe.Foreground = new SolidColorBrush(Colors.Gray);
subscribe.Content = "Subscribed"; subscribe.Content = "Subscribed";
b = true;
break;
} }
} }
Debug.WriteLine($"Channel was found: {b}");
subscriptionPane.Visibility = Visibility.Visible; subscriptionPane.Visibility = Visibility.Visible;
} }
@@ -145,9 +158,9 @@ namespace FoxTube.Pages
{ {
loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true); loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true);
} }
catch catch (Exception e)
{ {
loading.Error(); loading.Error(e.GetType().ToString(), e.Message);
} }
} }
@@ -236,21 +249,25 @@ namespace FoxTube.Pages
private async void subscribe_Click(object sender, RoutedEventArgs e) private async void subscribe_Click(object sender, RoutedEventArgs e)
{ {
if (subscribe.IsChecked.Value) if (subscribe.Background == new SolidColorBrush(Colors.Red))
{ {
if (!await SecretsVault.Subscribe(channelId)) if (await SecretsVault.Subscribe(channelId))
subscribe.IsChecked = false; {
else subscribe.Background = new SolidColorBrush(Colors.Transparent);
subscribe.Foreground = new SolidColorBrush(Colors.Gray);
subscribe.Content = "Subscribed"; subscribe.Content = "Subscribed";
} }
}
else else
{ {
if (!await SecretsVault.Unsubscibe(channelId)) if (await SecretsVault.Unsubscibe(channelId))
subscribe.IsChecked = true; {
else subscribe.Background = new SolidColorBrush(Colors.Red);
subscribe.Foreground = new SolidColorBrush(Colors.White);
subscribe.Content = "Subscribe"; subscribe.Content = "Subscribe";
} }
} }
}
private void Hyperlink_Click(Windows.UI.Xaml.Documents.Hyperlink sender, Windows.UI.Xaml.Documents.HyperlinkClickEventArgs args) private void Hyperlink_Click(Windows.UI.Xaml.Documents.Hyperlink sender, Windows.UI.Xaml.Documents.HyperlinkClickEventArgs args)
{ {
+1
View File
@@ -1,4 +1,5 @@
<Page <Page
NavigationCacheMode="Enabled"
x:Class="FoxTube.Pages.History" x:Class="FoxTube.Pages.History"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+29 -2
View File
@@ -1,4 +1,5 @@
<Page <Page
NavigationCacheMode="Enabled"
x:Class="FoxTube.Home" x:Class="FoxTube.Home"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@@ -15,10 +16,36 @@
<RowDefinition Height="auto"/> <RowDefinition Height="auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Pivot Name="pivot" SelectionChanged="pivot_SelectionChanged"/> <Pivot Name="pivot" SelectionChanged="pivot_SelectionChanged" SelectedIndex="1">
<PivotItem Header="Recommended" Name="recommended">
<ScrollViewer>
<StackPanel>
<pages:VideoGrid/>
<controls:ShowMore Clicked="RecMore_Clicked"/>
</StackPanel>
</ScrollViewer>
</PivotItem>
<PivotItem Header="Trending" Name="trending">
<ScrollViewer>
<StackPanel>
<pages:VideoGrid/>
<controls:ShowMore Clicked="TrendMore_Clicked"/>
</StackPanel>
</ScrollViewer>
</PivotItem>
<PivotItem Header="Subscriptions" Name="subscriptions">
<ScrollViewer>
<StackPanel>
<pages:VideoGrid/>
<controls:ShowMore Clicked="SubsMore_Clicked"/>
</StackPanel>
</ScrollViewer>
</PivotItem>
</Pivot>
<CommandBar Grid.Row="1"> <CommandBar Grid.Row="1">
<AppBarButton Icon="Refresh" Label="Refresh page" Name="refresh" Click="refresh_Click"/> <AppBarButton Icon="Refresh" Label="Refresh page" Name="refresh" Click="refreshPage"/>
</CommandBar> </CommandBar>
<local:LoadingPage Grid.RowSpan="2" Margin="0,50,0,0" Visibility="Visible" RefreshPage="refreshPage"/>
</Grid> </Grid>
</Page> </Page>
+96 -112
View File
@@ -20,6 +20,8 @@ using Windows.Storage;
using Windows.UI.Text; using Windows.UI.Text;
using FoxTube.Controls; using FoxTube.Controls;
using FoxTube.Pages; using FoxTube.Pages;
using System.Collections.ObjectModel;
using System.Diagnostics;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
@@ -34,11 +36,12 @@ namespace FoxTube
private bool trendLoaded = false; private bool trendLoaded = false;
private bool subsLoaded = false; private bool subsLoaded = false;
VideoGrid recGrid = new VideoGrid(), trendGrid = new VideoGrid(), subsGrid = new VideoGrid(); VideoGrid recGrid, trendGrid, subsGrid;
ShowMore recMore = new ShowMore(), trendMore = new ShowMore(), subsMore = new ShowMore(); ShowMore recMore, trendMore, subsMore;
LoadingPage recLoading = new LoadingPage(), trendLoading = new LoadingPage(), subsLoading = new LoadingPage(); LoadingPage loading;
string trendToken, recToken, subsToken; string trendToken, recToken;
Dictionary<string, string> subsTokens = new Dictionary<string, string>();
string reg; string reg;
public Home() public Home()
@@ -46,27 +49,29 @@ namespace FoxTube
this.InitializeComponent(); this.InitializeComponent();
try try
{ {
reg = (ApplicationData.Current.LocalSettings.Values["region"] as string).ToUpper().Remove(0, 3); reg = (ApplicationData.Current.LocalSettings.Values["region"] as string).ToLower().Remove(0, 3);
} }
catch (ArgumentOutOfRangeException) catch (ArgumentOutOfRangeException)
{ {
reg = (ApplicationData.Current.LocalSettings.Values["region"] as string).ToUpper(); reg = (ApplicationData.Current.LocalSettings.Values["region"] as string).ToUpper();
} }
recMore.Clicked += RecMore_Clicked; recGrid = ((recommended.Content as ScrollViewer).Content as StackPanel).Children[0] as VideoGrid;
trendMore.Clicked += TrendMore_Clicked; trendGrid = ((trending.Content as ScrollViewer).Content as StackPanel).Children[0] as VideoGrid;
subsMore.Clicked += SubsMore_Clicked; subsGrid = ((subscriptions.Content as ScrollViewer).Content as StackPanel).Children[0] as VideoGrid;
recLoading.RefreshPage += refreshPage; recMore = ((recommended.Content as ScrollViewer).Content as StackPanel).Children[1] as ShowMore;
subsLoading.RefreshPage += refreshPage; trendMore = ((trending.Content as ScrollViewer).Content as StackPanel).Children[1] as ShowMore; ;
trendLoading.RefreshPage += refreshPage; subsMore = ((subscriptions.Content as ScrollViewer).Content as StackPanel).Children[1] as ShowMore;
loading = grid.Children[2] as LoadingPage;
Initialize(); Initialize();
} }
private void refreshPage(object sender, RoutedEventArgs e) private void refreshPage(object sender, RoutedEventArgs e)
{ {
Initialize(); (Parent as Frame).Navigate(typeof(Home));
} }
private void RecMore_Clicked() private void RecMore_Clicked()
@@ -75,6 +80,8 @@ namespace FoxTube
} }
private async void TrendMore_Clicked() private async void TrendMore_Clicked()
{
try
{ {
VideosResource.ListRequest request = SecretsVault.Service.Videos.List("id"); VideosResource.ListRequest request = SecretsVault.Service.Videos.List("id");
request.MaxResults = 48; request.MaxResults = 48;
@@ -96,117 +103,80 @@ namespace FoxTube
} }
trendMore.Complete(); trendMore.Complete();
} }
catch
private void SubsMore_Clicked()
{ {
trendMore.Complete(true);
}
}
private async void SubsMore_Clicked()
{
try
{
List<SearchResult> items = new List<SearchResult>();
Dictionary<string, string> pairs = new Dictionary<string, string>();
SearchResource.ListRequest request = SecretsVault.Service.Search.List("snippet");
request.Type = "video";
request.MaxResults = 10;
request.Order = SearchResource.ListRequest.OrderEnum.Date;
foreach (KeyValuePair<string, string> i in subsTokens)
{
request.ChannelId = i.Key;
request.PageToken = i.Value;
SearchListResponse response = await request.ExecuteAsync();
foreach (SearchResult result in response.Items)
items.Add(result);
if (response.NextPageToken != null)
pairs.Add(i.Value, response.NextPageToken);
}
if (pairs.Count == 0)
subsMore.Complete(true);
else
subsTokens = pairs;
items = items.OrderByDescending(x => x.Snippet.PublishedAt).ToList();
foreach (SearchResult i in items)
subsGrid.Add(new VideoCard(i.Id.VideoId));
subsMore.Complete();
}
catch
{
subsMore.Complete(true);
}
} }
public void Initialize() public void Initialize()
{ {
GC.Collect();
pivot.Items.Clear();
if(SecretsVault.IsAuthorized) if(SecretsVault.IsAuthorized)
{
//Initializing recommended tab
StackPanel rs = new StackPanel();
rs.Children.Add(recGrid);
rs.Children.Add(recMore);
Grid rg = new Grid();
rg.Children.Add(new ScrollViewer() { Content = rs });
rg.Children.Add(recLoading);
pivot.Items.Add(new PivotItem()
{
Content = rg,
Header = "Recommended"
});
//Initializing trending tab
StackPanel ts = new StackPanel();
ts.Children.Add(trendGrid);
ts.Children.Add(trendMore);
Grid tg = new Grid();
tg.Children.Add(new ScrollViewer() { Content = ts });
tg.Children.Add(trendLoading);
pivot.Items.Add(new PivotItem()
{
Content = tg,
Header = "Trending"
});
//Initializing subscriptions tab
StackPanel s = new StackPanel();
s.Children.Add(subsGrid);
s.Children.Add(subsMore);
Grid g = new Grid();
g.Children.Add(new ScrollViewer() { Content = s });
g.Children.Add(subsLoading);
pivot.Items.Add(new PivotItem()
{
Content = g,
Header = "Subscriptions"
});
LoadRecommendations(); LoadRecommendations();
}
else else
{ {
StackPanel ts = new StackPanel(); pivot.Items.Remove(recommended);
ts.Children.Add(trendGrid); pivot.Items.Remove(subscriptions);
ts.Children.Add(trendMore);
Grid tg = new Grid();
tg.Children.Add(new ScrollViewer() { Content = ts });
tg.Children.Add(trendLoading);
pivot.Items.Add(new PivotItem()
{
Content = tg
});
LoadTrending(); LoadTrending();
} }
} }
private void refresh_Click(object sender, RoutedEventArgs e)
{
Initialize();
}
private void pivot_SelectionChanged(object sender, SelectionChangedEventArgs e) private void pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
switch(pivot.SelectedIndex) loading.Close();
{ if (pivot.SelectedItem == recommended && !recLoaded)
case 2:
if (!subsLoaded)
LoadSubscriptions();
break;
case 1:
if (!trendLoaded)
LoadTrending();
break;
case 0:
if (pivot.Items.Count > 1)
{
if (!recLoaded)
LoadRecommendations(); LoadRecommendations();
} else if (pivot.SelectedItem == trending && !trendLoaded)
else
{
if (!trendLoaded)
LoadTrending(); LoadTrending();
} else if (pivot.SelectedItem == subscriptions && !subsLoaded)
break; LoadSubscriptions();
}
} }
async void LoadTrending() async void LoadTrending()
{ {
try try
{ {
loading.Refresh();
VideosResource.ListRequest request = SecretsVault.Service.Videos.List("id"); VideosResource.ListRequest request = SecretsVault.Service.Videos.List("id");
request.MaxResults = 48; request.MaxResults = 48;
@@ -225,16 +195,18 @@ namespace FoxTube
trendGrid.Add(vCard); trendGrid.Add(vCard);
} }
trendLoading.Close(); loading.Close();
trendLoaded = true; trendLoaded = true;
} }
catch (System.Net.Http.HttpRequestException) catch (System.Net.Http.HttpRequestException)
{ {
trendLoading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true); trendLoaded = false;
loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true);
} }
catch catch(Exception e)
{ {
trendLoading.Error(); trendLoaded = false;
loading.Error(e.GetType().ToString(), e.Message);
} }
} }
@@ -242,17 +214,22 @@ namespace FoxTube
{ {
try try
{ {
recLoading.Close(); loading.Refresh();
throw new NotImplementedException();
loading.Close();
recLoaded = true; recLoaded = true;
recLoading.Block();
} }
catch (System.Net.Http.HttpRequestException) catch (System.Net.Http.HttpRequestException)
{ {
recLoading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true); recLoaded = false;
loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true);
} }
catch catch (Exception e)
{ {
recLoading.Error(); recLoaded = false;
loading.Error(e.GetType().ToString(), e.Message);
} }
} }
@@ -260,10 +237,11 @@ namespace FoxTube
{ {
try try
{ {
loading.Refresh();
List<SearchResult> items = new List<SearchResult>(); List<SearchResult> items = new List<SearchResult>();
SearchResource.ListRequest request = SecretsVault.Service.Search.List("snippet"); SearchResource.ListRequest request = SecretsVault.Service.Search.List("snippet");
request.Type = "video"; request.Type = "video";
request.MaxResults = 20; request.MaxResults = 10;
request.Order = SearchResource.ListRequest.OrderEnum.Date; request.Order = SearchResource.ListRequest.OrderEnum.Date;
foreach (Subscription i in SecretsVault.Subscriptions) foreach (Subscription i in SecretsVault.Subscriptions)
@@ -272,23 +250,29 @@ namespace FoxTube
SearchListResponse response = await request.ExecuteAsync(); SearchListResponse response = await request.ExecuteAsync();
foreach (SearchResult result in response.Items) foreach (SearchResult result in response.Items)
items.Add(result); items.Add(result);
if (response.NextPageToken != null)
subsTokens.Add(i.Snippet.ResourceId.ChannelId, response.NextPageToken);
} }
if (subsTokens.Count == 0)
subsMore.Complete(true); subsMore.Complete(true);
items.OrderBy(x => x.Snippet.PublishedAt.Value); items = items.OrderByDescending(x => x.Snippet.PublishedAt).ToList();
foreach (SearchResult i in items) foreach (SearchResult i in items)
subsGrid.Add(new VideoCard(i.Id.VideoId)); subsGrid.Add(new VideoCard(i.Id.VideoId));
subsLoading.Close(); loading.Close();
subsLoaded = true;
} }
catch (System.Net.Http.HttpRequestException) catch (System.Net.Http.HttpRequestException)
{ {
subsLoading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true); subsLoaded = false;
loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true);
} }
catch (Exception e) catch (Exception e)
{ {
subsLoading.Error(e.ToString(), e.Message); subsLoaded = false;
loading.Error(e.GetType().ToString(), e.Message);
} }
} }
} }
-2
View File
@@ -107,9 +107,7 @@
<Grid> <Grid>
<Frame Name="content" Navigated="content_Navigated"/> <Frame Name="content" Navigated="content_Navigated"/>
<controls:DropShadowPanel Color="Black" BlurRadius="0" ShadowOpacity=".7" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Frame Name="videoPlaceholder"/> <Frame Name="videoPlaceholder"/>
</controls:DropShadowPanel>
</Grid> </Grid>
</NavigationView> </NavigationView>
+27 -24
View File
@@ -133,6 +133,7 @@ namespace FoxTube
SecretsVault.AuthorizationStateChanged += Vault_AuthorizationStateChanged; SecretsVault.AuthorizationStateChanged += Vault_AuthorizationStateChanged;
SecretsVault.SubscriptionsChanged += SecretsVault_SubscriptionsChanged; SecretsVault.SubscriptionsChanged += SecretsVault_SubscriptionsChanged;
SetTitleBar();
} }
protected override void OnNavigatedTo(NavigationEventArgs e) protected override void OnNavigatedTo(NavigationEventArgs e)
@@ -150,10 +151,21 @@ namespace FoxTube
titleBar.ButtonPressedBackgroundColor = Colors.DarkRed; titleBar.ButtonPressedBackgroundColor = Colors.DarkRed;
titleBar.ButtonInactiveBackgroundColor = Colors.Transparent; titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
if((int)settings.Values["themeMode"] == 2)
{
Color uiTheme = new UISettings().GetColorValue(UIColorType.Background);
if (uiTheme == Colors.Black)
titleBar.ButtonForegroundColor = Colors.White;
else
titleBar.ButtonForegroundColor = Colors.Black;
}
else
{
if (RequestedTheme == ElementTheme.Dark) if (RequestedTheme == ElementTheme.Dark)
titleBar.ButtonForegroundColor = Colors.White; titleBar.ButtonForegroundColor = Colors.White;
else if(RequestedTheme == ElementTheme.Light) else if (RequestedTheme == ElementTheme.Light)
titleBar.ButtonForegroundColor = Colors.Black; titleBar.ButtonForegroundColor = Colors.Black;
}
CoreApplicationViewTitleBar coreTitleBar = CoreApplication.GetCurrentView().TitleBar; CoreApplicationViewTitleBar coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
coreTitleBar.ExtendViewIntoTitleBar = true; coreTitleBar.ExtendViewIntoTitleBar = true;
@@ -348,14 +360,11 @@ namespace FoxTube
public void MinimizeVideo() public void MinimizeVideo()
{ {
DropShadowPanel ph = videoPlaceholder.Parent as DropShadowPanel; videoPlaceholder.Width = 432;
videoPlaceholder.Height = 243;
ph.BlurRadius = 20; videoPlaceholder.VerticalAlignment = VerticalAlignment.Bottom;
ph.Width = 432; videoPlaceholder.HorizontalAlignment = HorizontalAlignment.Right;
ph.Height = 243; videoPlaceholder.Margin = new Thickness(0, 0, 25, 50);
ph.VerticalAlignment = VerticalAlignment.Bottom;
ph.HorizontalAlignment = HorizontalAlignment.Right;
ph.Margin = new Thickness(0, 0, 25, 50);
if (content.CanGoBack) if (content.CanGoBack)
nav.IsBackEnabled = true; nav.IsBackEnabled = true;
@@ -365,14 +374,11 @@ namespace FoxTube
public void MaximizeVideo() public void MaximizeVideo()
{ {
DropShadowPanel ph = videoPlaceholder.Parent as DropShadowPanel; videoPlaceholder.Width = double.NaN;
videoPlaceholder.Height = double.NaN;
ph.BlurRadius = 0; videoPlaceholder.VerticalAlignment = VerticalAlignment.Stretch;
ph.Width = double.NaN; videoPlaceholder.HorizontalAlignment = HorizontalAlignment.Stretch;
ph.Height = double.NaN; videoPlaceholder.Margin = new Thickness(0);
ph.VerticalAlignment = VerticalAlignment.Stretch;
ph.HorizontalAlignment = HorizontalAlignment.Stretch;
ph.Margin = new Thickness(0);
nav.IsBackEnabled = true; nav.IsBackEnabled = true;
} }
@@ -383,7 +389,7 @@ namespace FoxTube
{ {
nav.OpenPaneLength = 0; nav.OpenPaneLength = 0;
nav.CompactPaneLength = 0; nav.CompactPaneLength = 0;
if (nav.DisplayMode == NavigationViewDisplayMode.Minimal) if ((videoPlaceholder.Content as VideoPage).player.miniView)
nav.Margin = new Thickness(0, -80, 0, 0); nav.Margin = new Thickness(0, -80, 0, 0);
else else
nav.Margin = new Thickness(0, -91, 0, 0); nav.Margin = new Thickness(0, -91, 0, 0);
@@ -425,8 +431,7 @@ namespace FoxTube
try try
{ {
XmlDocument doc = new XmlDocument(); XmlDocument doc = new XmlDocument();
string reg = (settings.Values["region"] as string).Length > 2 ? (settings.Values["region"] as string).Remove(2) : (settings.Values["region"] as string); doc.Load($"http://suggestqueries.google.com/complete/search?ds=yt&client=toolbar&q={search.Text}");
doc.Load($"http://suggestqueries.google.com/complete/search?ds=yt&output=toolbar&hl={reg}&q={WebUtility.UrlEncode(search.Text)}");
List<string> suggestions = new List<string>(); List<string> suggestions = new List<string>();
@@ -611,7 +616,7 @@ namespace FoxTube
else else
nav.ExpandedModeThresholdWidth = int.MaxValue; nav.ExpandedModeThresholdWidth = int.MaxValue;
if (videoPlaceholder.Content != null && (videoPlaceholder.Parent as DropShadowPanel).HorizontalAlignment == HorizontalAlignment.Stretch) if (videoPlaceholder.Content != null && videoPlaceholder.HorizontalAlignment == HorizontalAlignment.Stretch)
MinimizeAsInitializer(); MinimizeAsInitializer();
} }
@@ -624,11 +629,9 @@ namespace FoxTube
{ {
if (videoPlaceholder.Content != null) if (videoPlaceholder.Content != null)
{ {
DropShadowPanel panel = videoPlaceholder.Parent as DropShadowPanel;
if ((videoPlaceholder.Content as VideoPage).loading.State != LoadingState.Loaded) if ((videoPlaceholder.Content as VideoPage).loading.State != LoadingState.Loaded)
CloseVideo(); CloseVideo();
else if (panel.HorizontalAlignment == HorizontalAlignment.Stretch) else if (videoPlaceholder.HorizontalAlignment == HorizontalAlignment.Stretch)
MinimizeAsInitializer(); MinimizeAsInitializer();
else else
content.GoBack(); content.GoBack();
+1
View File
@@ -1,4 +1,5 @@
<Page <Page
NavigationCacheMode="Enabled"
x:Class="FoxTube.Pages.PlaylistPage" x:Class="FoxTube.Pages.PlaylistPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+1
View File
@@ -1,4 +1,5 @@
<Page <Page
NavigationCacheMode="Enabled"
x:Class="FoxTube.Search" x:Class="FoxTube.Search"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+6 -8
View File
@@ -67,11 +67,8 @@ namespace FoxTube
break; break;
case "youtube#channel": case "youtube#channel":
if(channelId != null) if(channelId == null)
{ list.Add(new ChannelCard(result.Id.ChannelId, result.Snippet.LiveBroadcastContent));
ChannelCard cCard = new ChannelCard(result.Id.ChannelId/*, result.Snippet.LiveBroadcastContent*/);
list.Add(cCard);
}
break; break;
case "youtube#playlist": case "youtube#playlist":
@@ -112,11 +109,12 @@ namespace FoxTube
try try
{ {
Term = term; Term = term;
request = SecretsVault.Service.Search.List("id"); request = SecretsVault.Service.Search.List("id,snippet");
if (!string.IsNullOrWhiteSpace(channel)) if (!string.IsNullOrWhiteSpace(channel))
{ {
channelId = channel; channelId = channel;
request.ChannelId = channel; request.ChannelId = channel;
(type.Items[2] as ComboBoxItem).Visibility = Visibility.Collapsed;
(grid.Children[1] as CommandBar).Visibility = Visibility.Collapsed; (grid.Children[1] as CommandBar).Visibility = Visibility.Collapsed;
} }
request.Q = term; request.Q = term;
@@ -172,9 +170,9 @@ namespace FoxTube
{ {
loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true); loading.Error("System.Net.Http.HttpRequestException", "Unable to connect to Google servers.", true);
} }
catch catch (Exception e)
{ {
loading.Error(); loading.Error(e.GetType().ToString(), e.Message);
} }
} }
+1 -1
View File
@@ -47,7 +47,7 @@
<StackPanel Orientation="Vertical" Grid.Column="1" Padding="5" VerticalAlignment="Center"> <StackPanel Orientation="Vertical" Grid.Column="1" Padding="5" VerticalAlignment="Center">
<TextBlock Name="channelName" Text="[Channel name]" FontSize="18"/> <TextBlock Name="channelName" Text="[Channel name]" FontSize="18"/>
<TextBlock Name="subscribers" Text="[subscribers]" Foreground="Gray" Margin="0,0,0,5"/> <TextBlock Name="subscribers" Text="[subscribers]" Foreground="Gray" Margin="0,0,0,5"/>
<ToggleButton Grid.Column="2" Height="30" Width="200" Background="Red" Foreground="White" FontSize="14" FontWeight="SemiBold" Content="Subscirbe" Name="subscribe"/> <Button Click="subscribe_Click" Grid.Column="2" Height="30" Width="200" Background="Red" Foreground="White" FontSize="14" FontWeight="SemiBold" Content="Subscirbe" Name="subscribe"/>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</Button> </Button>
+39 -11
View File
@@ -162,7 +162,7 @@ namespace FoxTube.Pages
foreach (PlaylistItem i in listResponse.Items) foreach (PlaylistItem i in listResponse.Items)
{ {
items.Add(new VideoPlaylistItem(i.Snippet.Thumbnails.Medium.Url, i.Snippet.Title, i.ContentDetails.VideoId)); items.Add(new VideoPlaylistItem(i.Snippet.Thumbnails.Medium.Url, i.Snippet.Title, i.Snippet.ResourceId.VideoId));
if (items.Last().Id == videoId) if (items.Last().Id == videoId)
selection = items.Last(); selection = items.Last();
} }
@@ -177,6 +177,7 @@ namespace FoxTube.Pages
playlistList.ItemsSource = items; playlistList.ItemsSource = items;
playlistList.SelectedItem = selection; playlistList.SelectedItem = selection;
pivot.SelectedItem = playlist;
} }
else else
pivot.Items.Remove(playlist); pivot.Items.Remove(playlist);
@@ -220,7 +221,8 @@ namespace FoxTube.Pages
{ {
if (s.Snippet.ResourceId.ChannelId == item.Snippet.ChannelId) if (s.Snippet.ResourceId.ChannelId == item.Snippet.ChannelId)
{ {
subscribe.IsChecked = true; subscribe.Background = new SolidColorBrush(Colors.Transparent);
subscribe.Foreground = new SolidColorBrush(Colors.Gray);
subscribe.Content = "Subscribed"; subscribe.Content = "Subscribed";
} }
} }
@@ -248,7 +250,7 @@ namespace FoxTube.Pages
} }
catch (Exception e) catch (Exception e)
{ {
loading.Error(e.HResult.ToString(), e.Message); loading.Error(e.GetType().ToString(), e.Message);
} }
} }
@@ -444,10 +446,10 @@ namespace FoxTube.Pages
{ {
case Rating.Like: case Rating.Like:
like.Foreground = new SolidColorBrush(Colors.Gray); like.Foreground = new SolidColorBrush(Colors.Gray);
likes.Text = (Convert.ToInt32(likes.Text) - 1).ToString(); likes.Text = (int.Parse(likes.Text, System.Globalization.NumberStyles.AllowThousands) - 1).ToString("0,0");
dislike.Foreground = new SolidColorBrush(Colors.Red); dislike.Foreground = new SolidColorBrush(Colors.Red);
dislikes.Text = (Convert.ToInt32(dislikes.Text) + 1).ToString(); dislikes.Text = (int.Parse(dislikes.Text, System.Globalization.NumberStyles.AllowThousands) + 1).ToString("0,0");
rating.Value = (int)((item.Statistics.LikeCount - 1) / (item.Statistics.DislikeCount + item.Statistics.LikeCount) * 100); rating.Value = (int)((item.Statistics.LikeCount - 1) / (item.Statistics.DislikeCount + item.Statistics.LikeCount) * 100);
await SecretsVault.Service.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.Dislike).ExecuteAsync(); await SecretsVault.Service.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.Dislike).ExecuteAsync();
@@ -456,7 +458,7 @@ namespace FoxTube.Pages
case Rating.None: case Rating.None:
dislike.Foreground = new SolidColorBrush(Colors.Red); dislike.Foreground = new SolidColorBrush(Colors.Red);
dislikes.Text = (Convert.ToInt32(dislikes.Text) + 1).ToString(); dislikes.Text = (int.Parse(dislikes.Text, System.Globalization.NumberStyles.AllowThousands) + 1).ToString("0,0");
rating.Value = (int)((item.Statistics.LikeCount) / (item.Statistics.DislikeCount + item.Statistics.LikeCount + 1) * 100); rating.Value = (int)((item.Statistics.LikeCount) / (item.Statistics.DislikeCount + item.Statistics.LikeCount + 1) * 100);
await SecretsVault.Service.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.Dislike).ExecuteAsync(); await SecretsVault.Service.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.Dislike).ExecuteAsync();
@@ -465,7 +467,7 @@ namespace FoxTube.Pages
case Rating.Dislike: case Rating.Dislike:
dislike.Foreground = new SolidColorBrush(Colors.Gray); dislike.Foreground = new SolidColorBrush(Colors.Gray);
dislikes.Text = (Convert.ToInt32(dislikes.Text) - 1).ToString(); dislikes.Text = (int.Parse(dislikes.Text, System.Globalization.NumberStyles.AllowThousands) - 1).ToString("0,0");
rating.Value = (int)((item.Statistics.LikeCount) / (item.Statistics.DislikeCount + item.Statistics.LikeCount - 1) * 100); rating.Value = (int)((item.Statistics.LikeCount) / (item.Statistics.DislikeCount + item.Statistics.LikeCount - 1) * 100);
await SecretsVault.Service.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.None).ExecuteAsync(); await SecretsVault.Service.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.None).ExecuteAsync();
break; break;
@@ -479,10 +481,10 @@ namespace FoxTube.Pages
{ {
case Rating.Dislike: case Rating.Dislike:
dislike.Foreground = new SolidColorBrush(Colors.Gray); dislike.Foreground = new SolidColorBrush(Colors.Gray);
dislikes.Text = (Convert.ToInt32(dislikes.Text) - 1).ToString(); dislikes.Text = (int.Parse(dislikes.Text, System.Globalization.NumberStyles.AllowThousands) - 1).ToString("0,0");
like.Foreground = new SolidColorBrush(Colors.Green); like.Foreground = new SolidColorBrush(Colors.Green);
likes.Text = (Convert.ToInt32(likes.Text) + 1).ToString(); likes.Text = (int.Parse(likes.Text, System.Globalization.NumberStyles.AllowThousands) + 1).ToString("0,0");
rating.Value = (int)((item.Statistics.LikeCount + 1) / (item.Statistics.DislikeCount + item.Statistics.LikeCount) * 100); rating.Value = (int)((item.Statistics.LikeCount + 1) / (item.Statistics.DislikeCount + item.Statistics.LikeCount) * 100);
await SecretsVault.Service.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.Like).ExecuteAsync(); await SecretsVault.Service.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.Like).ExecuteAsync();
@@ -491,7 +493,7 @@ namespace FoxTube.Pages
case Rating.None: case Rating.None:
like.Foreground = new SolidColorBrush(Colors.Green); like.Foreground = new SolidColorBrush(Colors.Green);
likes.Text = (Convert.ToInt32(likes.Text) + 1).ToString(); likes.Text = (int.Parse(likes.Text, System.Globalization.NumberStyles.AllowThousands) + 1).ToString("0,0");
rating.Value = (int)((item.Statistics.LikeCount + 1) / (item.Statistics.DislikeCount + item.Statistics.LikeCount + 1) * 100); rating.Value = (int)((item.Statistics.LikeCount + 1) / (item.Statistics.DislikeCount + item.Statistics.LikeCount + 1) * 100);
await SecretsVault.Service.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.Like).ExecuteAsync(); await SecretsVault.Service.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.Like).ExecuteAsync();
@@ -500,7 +502,7 @@ namespace FoxTube.Pages
case Rating.Like: case Rating.Like:
like.Foreground = new SolidColorBrush(Colors.Gray); like.Foreground = new SolidColorBrush(Colors.Gray);
likes.Text = (Convert.ToInt32(likes.Text) - 1).ToString(); likes.Text = (int.Parse(likes.Text, System.Globalization.NumberStyles.AllowThousands) - 1).ToString("0,0");
rating.Value = (int)((item.Statistics.LikeCount - 1) / (item.Statistics.DislikeCount + item.Statistics.LikeCount - 1) * 100); rating.Value = (int)((item.Statistics.LikeCount - 1) / (item.Statistics.DislikeCount + item.Statistics.LikeCount - 1) * 100);
await SecretsVault.Service.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.None).ExecuteAsync(); await SecretsVault.Service.Videos.Rate(videoId, VideosResource.RateRequest.RatingEnum.None).ExecuteAsync();
break; break;
@@ -508,9 +510,35 @@ namespace FoxTube.Pages
} }
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
try
{ {
if ((e.AddedItems[0] as VideoPlaylistItem).Id != videoId) if ((e.AddedItems[0] as VideoPlaylistItem).Id != videoId)
Methods.MainPage.GoToVideo((e.AddedItems[0] as VideoPlaylistItem).Id, playlistId); Methods.MainPage.GoToVideo((e.AddedItems[0] as VideoPlaylistItem).Id, playlistId);
} }
catch { }
}
private async void subscribe_Click(object sender, RoutedEventArgs e)
{
if (subscribe.Background == new SolidColorBrush(Colors.Red))
{
if (await SecretsVault.Subscribe(item.Snippet.ChannelId))
{
subscribe.Background = new SolidColorBrush(Colors.Transparent);
subscribe.Foreground = new SolidColorBrush(Colors.Gray);
subscribe.Content = "Subscribed";
}
}
else
{
if (await SecretsVault.Unsubscibe(item.Snippet.ChannelId))
{
subscribe.Background = new SolidColorBrush(Colors.Red);
subscribe.Foreground = new SolidColorBrush(Colors.White);
subscribe.Content = "Subscribe";
}
}
}
} }
} }