diff --git a/src/Pixeval.Controls/HeartButton.xaml.cs b/src/Pixeval.Controls/HeartButton.xaml.cs index 7f909f4f..e0b4a743 100644 --- a/src/Pixeval.Controls/HeartButton.xaml.cs +++ b/src/Pixeval.Controls/HeartButton.xaml.cs @@ -6,6 +6,7 @@ using WinUI3Utilities.Attributes; namespace Pixeval.Controls; [DependencyProperty("Command")] +[DependencyProperty("CommandParameter", IsNullable = true)] public sealed partial class HeartButton { public HeartButton() => InitializeComponent(); @@ -14,7 +15,7 @@ public sealed partial class HeartButton { e.Handled = true; if (IsTapEnabled) - Command.Execute(null); + Command.Execute(CommandParameter); } // ReSharper disable UnusedMember.Global diff --git a/src/Pixeval/AppManagement/AppSettings.cs b/src/Pixeval/AppManagement/AppSettings.cs index 21a42ba1..fb8d258a 100644 --- a/src/Pixeval/AppManagement/AppSettings.cs +++ b/src/Pixeval/AppManagement/AppSettings.cs @@ -105,6 +105,9 @@ public partial record AppSettings : IWindowSettings [SettingMetadata(SettingEntryCategory.Download, typeof(SettingsPageResources), nameof(SettingsPageResources.MaxDownloadConcurrencyLevelEntryHeader))] public int MaxDownloadTaskConcurrencyLevel { get; set; } = Environment.ProcessorCount / 2; + [SettingMetadata(SettingEntryCategory.Download, typeof(SettingsPageResources), nameof(SettingsPageResources.DownloadWhenBookmarkedEntryHeader))] + public bool DownloadWhenBookmarked { get; set; } + /// /// The application-wide default sort option, any illustration page that supports /// different orders will use this as its default value @@ -174,12 +177,6 @@ public partial record AppSettings : IWindowSettings [SettingMetadata(SettingEntryCategory.BrowsingExperience, typeof(SettingsPageResources), nameof(SettingsPageResources.FiltrateRestrictedContentEntryHeader))] public bool FiltrateRestrictedContent { get; set; } - /// - /// How many rows to be preloaded in illustration grid - /// - [SettingMetadata(SettingEntryCategory.Misc, typeof(SettingsPageResources), nameof(SettingsPageResources.PreloadRowsEntryHeader))] - public int PreLoadRows { get; set; } = 2; - /// /// Indicates the maximum page count that are allowed to be retrieved during /// spotlight retrieval(10 entries per page) diff --git a/src/Pixeval/Controls/Entry/ThumbnailEntryViewModel.Commands.cs b/src/Pixeval/Controls/Entry/ThumbnailEntryViewModel.Commands.cs index 5b7aaba3..032c9b28 100644 --- a/src/Pixeval/Controls/Entry/ThumbnailEntryViewModel.Commands.cs +++ b/src/Pixeval/Controls/Entry/ThumbnailEntryViewModel.Commands.cs @@ -34,8 +34,6 @@ namespace Pixeval.Controls; public partial class ThumbnailEntryViewModel { - public XamlUICommand BookmarkCommand { get; } = "".GetCommand(FontIconSymbol.HeartEB51, VirtualKeyModifiers.Control, VirtualKey.D); - public XamlUICommand AddToBookmarkCommand { get; } = EntryItemResources.AddToBookmark.GetCommand(FontIconSymbol.BookmarksE8A4); public XamlUICommand GenerateLinkCommand { get; } = EntryItemResources.GenerateLink.GetCommand(FontIconSymbol.LinkE71B); @@ -48,6 +46,12 @@ public partial class ThumbnailEntryViewModel public XamlUICommand ShowPixEzQrCodeCommand { get; } = EntryItemResources.ShowPixEzQrCode.GetCommand(FontIconSymbol.Photo2EB9F); + /// + /// Parameter1: where T1 is ? and T2 is ? where T is ? and TResult is ?
+ /// Parameter2: ? + ///
+ public XamlUICommand BookmarkCommand { get; } = "".GetCommand(FontIconSymbol.HeartEB51, VirtualKeyModifiers.Control, VirtualKey.D); + /// /// Parameter1: where T1 is ? and T2 is ? where T is ? and TResult is ?
/// Parameter2: ? @@ -68,9 +72,6 @@ public partial class ThumbnailEntryViewModel private void InitializeCommands() { - BookmarkCommand.GetBookmarkCommand(IsBookmarked); - BookmarkCommand.ExecuteRequested += BookmarkCommandOnExecuteRequested; - // TODO: AddToBookmarkCommand AddToBookmarkCommand.CanExecuteRequested += (sender, args) => args.CanExecute = false; @@ -84,6 +85,9 @@ public partial class ThumbnailEntryViewModel ShowPixEzQrCodeCommand.ExecuteRequested += ShowPixEzQrCodeCommandOnExecuteRequested; + BookmarkCommand.GetBookmarkCommand(IsBookmarked); + BookmarkCommand.ExecuteRequested += BookmarkCommandOnExecuteRequested; + SaveCommand.ExecuteRequested += SaveCommandOnExecuteRequested; SaveAsCommand.ExecuteRequested += SaveAsCommandOnExecuteRequested; @@ -91,8 +95,6 @@ public partial class ThumbnailEntryViewModel CopyCommand.ExecuteRequested += CopyCommandOnExecuteRequested; } - protected abstract void BookmarkCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs e); - private void GenerateLinkCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) { UiHelper.ClipboardSetText(AppUri.OriginalString); @@ -152,11 +154,13 @@ public partial class ThumbnailEntryViewModel } } - protected abstract void SaveCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs e); + protected abstract void BookmarkCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args); - protected abstract void SaveAsCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs e); + protected abstract void SaveCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args); - protected abstract void CopyCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs e); + protected abstract void SaveAsCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args); + + protected abstract void CopyCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args); protected abstract Uri AppUri { get; } diff --git a/src/Pixeval/Controls/IllustrationItem/IllustrationItem.xaml b/src/Pixeval/Controls/IllustrationItem/IllustrationItem.xaml index 3e51dc4f..341d71b9 100644 --- a/src/Pixeval/Controls/IllustrationItem/IllustrationItem.xaml +++ b/src/Pixeval/Controls/IllustrationItem/IllustrationItem.xaml @@ -41,7 +41,7 @@ - + @@ -75,7 +75,8 @@ x:Name="HeartButton" HorizontalAlignment="Left" VerticalAlignment="Top" - Command="{x:Bind ViewModel.BookmarkCommand, Mode=OneWay}" /> + Command="{x:Bind ViewModel.BookmarkCommand, Mode=OneWay}" + CommandParameter="{x:Bind}" /> + Command="{x:Bind ViewModel.BookmarkCommand, Mode=OneWay}" + CommandParameter="{x:Bind}"> diff --git a/src/Pixeval/Controls/NovelItem/NovelItemViewModel.Commands.cs b/src/Pixeval/Controls/NovelItem/NovelItemViewModel.Commands.cs index e06e69e9..cd2f17ee 100644 --- a/src/Pixeval/Controls/NovelItem/NovelItemViewModel.Commands.cs +++ b/src/Pixeval/Controls/NovelItem/NovelItemViewModel.Commands.cs @@ -27,23 +27,25 @@ namespace Pixeval.Controls; public partial class NovelItemViewModel { - protected override async void BookmarkCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs e) + protected override async void BookmarkCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) { IsBookmarked = await MakoHelper.SetNovelBookmarkAsync(Id, !IsBookmarked); BookmarkCommand.GetBookmarkCommand(IsBookmarked); + if (App.AppViewModel.AppSettings.DownloadWhenBookmarked && IsBookmarked && !User.IsFollowed) + SaveCommandOnExecuteRequested(sender, args); } - protected override void SaveCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs e) + protected override void SaveCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) { } - protected override void SaveAsCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs e) + protected override void SaveAsCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) { } - protected override void CopyCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs e) + protected override void CopyCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) { } diff --git a/src/Pixeval/Pages/IllustrationViewer/IllustrationViewerPage.xaml b/src/Pixeval/Pages/IllustrationViewer/IllustrationViewerPage.xaml index ddba44ff..d5b60c52 100644 --- a/src/Pixeval/Pages/IllustrationViewer/IllustrationViewerPage.xaml +++ b/src/Pixeval/Pages/IllustrationViewer/IllustrationViewerPage.xaml @@ -189,7 +189,10 @@ Grid.Row="1" DefaultLabelPosition="Collapsed" OverflowButtonVisibility="Collapsed"> - + - + diff --git a/src/Pixeval/Pages/IllustrationViewer/ImageViewerPageViewModel.cs b/src/Pixeval/Pages/IllustrationViewer/ImageViewerPageViewModel.cs index fd43dc8e..437d58eb 100644 --- a/src/Pixeval/Pages/IllustrationViewer/ImageViewerPageViewModel.cs +++ b/src/Pixeval/Pages/IllustrationViewer/ImageViewerPageViewModel.cs @@ -330,13 +330,13 @@ public partial class ImageViewerPageViewModel : UiObservableObject, IDisposable private void InitializeCommands() { SaveCommand.CanExecuteRequested += LoadingCompletedCanExecuteRequested; - SaveCommand.ExecuteRequested += (_, _) => IllustrationViewModel.SaveCommand.Execute((FrameworkElement, (Func?, Task>)(p => GetOriginalImageSourceAsync(p)))); + SaveCommand.ExecuteRequested += (_, _) => IllustrationViewModel.SaveCommand.Execute(DownloadParameter); SaveAsCommand.CanExecuteRequested += LoadingCompletedCanExecuteRequested; SaveAsCommand.ExecuteRequested += (_, _) => IllustrationViewModel.SaveAsCommand.Execute((Window, (Func?, Task>)(p => GetOriginalImageSourceAsync(p)))); CopyCommand.CanExecuteRequested += LoadingCompletedCanExecuteRequested; - CopyCommand.ExecuteRequested += (_, _) => IllustrationViewModel.CopyCommand.Execute((FrameworkElement, (Func?, Task>)(p => GetOriginalImageSourceAsync(p)))); + CopyCommand.ExecuteRequested += (_, _) => IllustrationViewModel.CopyCommand.Execute(DownloadParameter); PlayGifCommand.CanExecuteRequested += (_, e) => e.CanExecute = IllustrationViewModel.IsUgoira && LoadSuccessfully; PlayGifCommand.ExecuteRequested += PlayGifCommandOnExecuteRequested; @@ -389,6 +389,8 @@ public partial class ImageViewerPageViewModel : UiObservableObject, IDisposable private void IsNotUgoiraAndLoadingCompletedCanExecuteRequested(XamlUICommand sender, CanExecuteRequestedEventArgs args) => args.CanExecute = !IllustrationViewModel.IsUgoira && LoadSuccessfully; + public (FrameworkElement FrameworkElement, Func?, Task>) DownloadParameter => (FrameworkElement, p => GetOriginalImageSourceAsync(p)); + public XamlUICommand SaveCommand { get; } = EntryItemResources.Save.GetCommand( FontIconSymbol.SaveE74E, VirtualKeyModifiers.Control, VirtualKey.S); diff --git a/src/Pixeval/Pages/Misc/SettingsPage.xaml b/src/Pixeval/Pages/Misc/SettingsPage.xaml index a0bed0e6..8cddbc67 100644 --- a/src/Pixeval/Pages/Misc/SettingsPage.xaml +++ b/src/Pixeval/Pages/Misc/SettingsPage.xaml @@ -659,6 +659,13 @@ + + + + - - - -