From 340021b833685963b5cd7e5faa2e490c6ca77137 Mon Sep 17 00:00:00 2001
From: Seng Jik <853974536@qq.com>
Date: Sun, 7 Feb 2021 14:25:46 +0800
Subject: [PATCH] Bug fixed
---
KoKoViewer/BrowsePage.xaml | 32 +++++++++++++++-------
KoKoViewer/BrowsePage.xaml.cs | 50 ++++++++++++++++++++++-------------
KoKoViewer/DownloadHelper.cs | 1 +
KoKoViewer/Viewer.xaml.cs | 4 ++-
4 files changed, 58 insertions(+), 29 deletions(-)
diff --git a/KoKoViewer/BrowsePage.xaml b/KoKoViewer/BrowsePage.xaml
index b525d1e..a688c34 100644
--- a/KoKoViewer/BrowsePage.xaml
+++ b/KoKoViewer/BrowsePage.xaml
@@ -44,17 +44,29 @@
x:Phase="1"/>
+ Symbol="Favorite"
+ x:Name="Info_Fav"
+ x:Load="False"
+ Visibility="Collapsed"/>
+ Symbol="Download"
+ x:Name="Info_Downloaded"
+ x:Load="False"
+ Visibility="Collapsed"/>
+ Symbol="Play"
+ x:Name="Info_GIF"
+ x:Load="False"
+ Visibility="Collapsed"/>
+ Symbol="Video"
+ x:Name="Info_Video"
+ x:Load="False"
+ Visibility="Collapsed"/>
@@ -62,11 +74,11 @@
-
-
-
-
-
+
+
+
+
+
diff --git a/KoKoViewer/BrowsePage.xaml.cs b/KoKoViewer/BrowsePage.xaml.cs
index a5531c8..84f0255 100644
--- a/KoKoViewer/BrowsePage.xaml.cs
+++ b/KoKoViewer/BrowsePage.xaml.cs
@@ -80,18 +80,26 @@ bool selectionMode
{
get => selectionModeInner;
set {
- selectionModeInner = value;
- MutiSelectionCommandBar.IsOpen = value;
- if (value)
+ if (value != selectionModeInner)
{
- Browser.SelectionMode = ListViewSelectionMode.Multiple;
- MutiSelectionCommandBar.IsEnabled = false;
- }
- else
- {
- Browser.SelectedItems.Clear();
- Browser.SelectionMode = ListViewSelectionMode.None;
- MutiSelectionCommandBar.IsEnabled = false;
+ MutiSelectionCommandBar_OpenThese.IsEnabled = false;
+ MutiSelectionCommandBar_FavoriteThese.IsEnabled = false;
+ MutiSelectionCommandBar_UnFavoriteThese.IsEnabled = false;
+ MutiSelectionCommandBar_Download.IsEnabled = false;
+ MutiSelectionCommandBar_FavDownload.IsEnabled = false;
+
+
+ selectionModeInner = value;
+ MutiSelectionCommandBar.IsOpen = value;
+ if (value)
+ {
+ Browser.SelectionMode = ListViewSelectionMode.Multiple;
+ }
+ else
+ {
+ Browser.SelectedItems.Clear();
+ Browser.SelectionMode = ListViewSelectionMode.None;
+ }
}
}
}
@@ -102,7 +110,13 @@ private void Browser_RightTapped(object sender, RightTappedRoutedEventArgs e)
private void Browser_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
- MutiSelectionCommandBar.IsEnabled = Browser.SelectedItems.Count > 0;
+ bool enabled = Browser.SelectedItems.Count > 0;
+
+ MutiSelectionCommandBar_OpenThese.IsEnabled = enabled;
+ MutiSelectionCommandBar_FavoriteThese.IsEnabled = enabled;
+ MutiSelectionCommandBar_UnFavoriteThese.IsEnabled = enabled;
+ MutiSelectionCommandBar_Download.IsEnabled = enabled;
+ MutiSelectionCommandBar_FavDownload.IsEnabled = enabled;
}
private void MutiSelectionCommandBar_OpenThese_Click(object sender, RoutedEventArgs e)
@@ -183,21 +197,21 @@ private void Image_ImageOpened(object sender, RoutedEventArgs e)
var image = sender as Image;
var post = image.Tag as KoKo.Post;
- var parent = image.Parent as Grid;
+ var parent = image;
if (FavoritesData.Get().Has(post.fromSpider.Name, post.id))
- parent.FindName("Info_Fav");
+ (parent.FindName("Info_Fav") as SymbolIcon).Visibility = Visibility.Visible;
if (DownloadHelper.GetDownloaded(post) != null)
- parent.FindName("Info_Downloaded");
+ (parent.FindName("Info_Downloaded") as SymbolIcon).Visibility = Visibility.Visible;
var imageName = post.images.First().First().fileName.ToLower().Trim();
if (imageName.EndsWith(".gif"))
- image.FindName("Info_GIF");
+ (parent.FindName("Info_GIF") as SymbolIcon).Visibility = Visibility.Visible;
- if (imageName.EndsWith(".mp4") || imageName.EndsWith(".webm"))
- image.FindName("Info_Video");
+ else if (imageName.EndsWith(".mp4") || imageName.EndsWith(".webm"))
+ (parent.FindName("Info_Video") as SymbolIcon).Visibility = Visibility.Visible; ;
}
}
}
diff --git a/KoKoViewer/DownloadHelper.cs b/KoKoViewer/DownloadHelper.cs
index 1ceb5f1..e4924dd 100644
--- a/KoKoViewer/DownloadHelper.cs
+++ b/KoKoViewer/DownloadHelper.cs
@@ -108,6 +108,7 @@ public static async void Download(KoKo.Post post)
try
{
var client = new System.Net.WebClient();
+ client.Headers.Set(System.Net.HttpRequestHeader.UserAgent, KoKo.Utils.UserAgent);
var toast = ToastProgress(post);
client.DownloadProgressChanged += (ooo, eee) =>
diff --git a/KoKoViewer/Viewer.xaml.cs b/KoKoViewer/Viewer.xaml.cs
index b1f9296..dd65fdc 100644
--- a/KoKoViewer/Viewer.xaml.cs
+++ b/KoKoViewer/Viewer.xaml.cs
@@ -43,7 +43,9 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
var cache = DownloadHelper.GetDownloaded(post);
- if (post.images.First().First().fileName.ToLower().EndsWith(".mp4") || post.images.First().First().fileName.ToLower().EndsWith(".webm"))
+ var fileName = post.images.First().First().fileName.ToLower();
+
+ if (fileName.EndsWith(".mp4") || fileName.EndsWith(".webm"))
{
// 如果是视频
Flyout_ViewLarger.IsEnabled = false;