Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Commit

Permalink
Bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Seng-Jik committed Feb 7, 2021
1 parent eece759 commit 340021b
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 29 deletions.
32 changes: 22 additions & 10 deletions KoKoViewer/BrowsePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,41 @@
x:Phase="1"/>
<StackPanel
VerticalAlignment="Top"
Background="Black"
Background="White"
Opacity="0.7"
HorizontalAlignment="Left">
<SymbolIcon
Symbol="Favorite" x:Name="Info_Fav" x:Load="False"/>
Symbol="Favorite"
x:Name="Info_Fav"
x:Load="False"
Visibility="Collapsed"/>
<SymbolIcon
Symbol="Download" x:Name="Info_Downloaded" x:Load="False"/>
Symbol="Download"
x:Name="Info_Downloaded"
x:Load="False"
Visibility="Collapsed"/>
<SymbolIcon
Symbol="Play" x:Name="Info_GIF" x:Load="False"/>
Symbol="Play"
x:Name="Info_GIF"
x:Load="False"
Visibility="Collapsed"/>
<SymbolIcon
Symbol="Video" x:Name="Info_Video" x:Load="False"/>
Symbol="Video"
x:Name="Info_Video"
x:Load="False"
Visibility="Collapsed"/>
</StackPanel>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>

<CommandBar OverflowButtonVisibility="Collapsed" IsOpen="False" ClosedDisplayMode="Hidden" IsSticky="True" Grid.Row="1" Name="MutiSelectionCommandBar">
<AppBarButton Icon="Find" Label="Open" Click="MutiSelectionCommandBar_OpenThese_Click" />
<AppBarButton Icon="Favorite" Label="Favorite" Click="MutiSelectionCommandBar_FavoriteThese_Click" />
<AppBarButton Icon="UnFavorite" Label="UnFavorite" Click="MutiSelectionCommandBar_UnFavoriteThese_Click" />
<AppBarButton Icon="Download" Label="Download" Click="MutiSelectionCommandBar_Download_Click"/>
<AppBarButton Icon="Like" Label="Fav&amp;Down" Click="MutiSelectionCommandBar_FavDownload_Click"/>
<AppBarButton x:Name="MutiSelectionCommandBar_OpenThese" Icon="Find" Label="Open" Click="MutiSelectionCommandBar_OpenThese_Click" />
<AppBarButton x:Name="MutiSelectionCommandBar_FavoriteThese" Icon="Favorite" Label="Favorite" Click="MutiSelectionCommandBar_FavoriteThese_Click" />
<AppBarButton x:Name="MutiSelectionCommandBar_UnFavoriteThese" Icon="UnFavorite" Label="UnFavorite" Click="MutiSelectionCommandBar_UnFavoriteThese_Click" />
<AppBarButton x:Name="MutiSelectionCommandBar_Download" Icon="Download" Label="Download" Click="MutiSelectionCommandBar_Download_Click"/>
<AppBarButton x:Name="MutiSelectionCommandBar_FavDownload" Icon="Like" Label="Fav&amp;Down" Click="MutiSelectionCommandBar_FavDownload_Click"/>
<AppBarButton Icon="Cancel" Label="Cancel" Click="MutiSelectionCommandBar_Cancel_Click"/>
</CommandBar>
</Grid>
Expand Down
50 changes: 32 additions & 18 deletions KoKoViewer/BrowsePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
Expand All @@ -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)
Expand Down Expand Up @@ -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; ;
}
}
}
1 change: 1 addition & 0 deletions KoKoViewer/DownloadHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
4 changes: 3 additions & 1 deletion KoKoViewer/Viewer.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 340021b

Please sign in to comment.