diff --git a/src/PicView.Avalonia/Navigation/ImageIterator.cs b/src/PicView.Avalonia/Navigation/ImageIterator.cs index d6474b13e..8d461bd43 100644 --- a/src/PicView.Avalonia/Navigation/ImageIterator.cs +++ b/src/PicView.Avalonia/Navigation/ImageIterator.cs @@ -389,10 +389,17 @@ public async Task QuickReload() await IterateToIndex(CurrentIndex).ConfigureAwait(false); } - public int GetIteration(int index, NavigateTo navigateTo, bool skip1 = false) + public int GetIteration(int index, NavigateTo navigateTo, bool skip1 = false, bool skip10 = false, bool skip100 = false) { int next; - var skipAmount = skip1 ? 2 : 1; + + if (skip100) + { + PreLoader.Clear(); + } + + // Determine skipAmount based on input flags + var skipAmount = skip100 ? 100 : skip10 ? 10 : skip1 ? 2 : 1; switch (navigateTo) { @@ -403,26 +410,18 @@ public int GetIteration(int index, NavigateTo navigateTo, bool skip1 = false) if (SettingsHelper.Settings.UIProperties.Looping) { + // Calculate new index with looping next = (index + indexChange + ImagePaths.Count) % ImagePaths.Count; } else { + // Calculate new index without looping and ensure bounds var newIndex = index + indexChange; - - // Ensure the new index doesn't go out of bounds - if (newIndex < 0) - { - return 0; - } - - if (newIndex >= ImagePaths.Count) - { - return ImagePaths.Count - 1; - } + if (newIndex < 0) return 0; + if (newIndex >= ImagePaths.Count) return ImagePaths.Count - 1; next = newIndex; } - break; case NavigateTo.First: @@ -431,7 +430,6 @@ public int GetIteration(int index, NavigateTo navigateTo, bool skip1 = false) { PreLoader.Clear(); } - next = navigateTo == NavigateTo.First ? 0 : ImagePaths.Count - 1; break; @@ -459,6 +457,18 @@ public async Task NextIteration(NavigateTo navigateTo) await TimerIteration(index); } } + + public async Task Next10Iteration(bool forwards) + { + var index = GetIteration(CurrentIndex, forwards ? NavigateTo.Next : NavigateTo.Previous, false, true); + await IterateToIndex(index).ConfigureAwait(false); + } + + public async Task Next100Iteration(bool forwards) + { + var index = GetIteration(CurrentIndex, forwards ? NavigateTo.Next : NavigateTo.Previous, false, false, true); + await IterateToIndex(index).ConfigureAwait(false); + } public async Task IterateToIndex(int index) { diff --git a/src/PicView.Avalonia/UI/FunctionsHelper.cs b/src/PicView.Avalonia/UI/FunctionsHelper.cs index 5ffcf8dc6..555700785 100644 --- a/src/PicView.Avalonia/UI/FunctionsHelper.cs +++ b/src/PicView.Avalonia/UI/FunctionsHelper.cs @@ -37,6 +37,10 @@ public static Task> GetFunctionByName(string functionName) "Down" => Down, "Last" => Last, "First" => First, + "Next10" => Next10, + "Prev10" => Prev10, + "Next100" => Next100, + "Prev100" => Prev100, // Rotate "RotateLeft" => RotateLeft, @@ -227,6 +231,27 @@ public static async Task First() { await NavigationHelper.NavigateFirstOrLast(last: false, Vm); } + + public static async Task Next10() + { + await Vm?.ImageIterator.Next10Iteration(true); + } + + public static async Task Next100() + { + await Vm?.ImageIterator.Next100Iteration(true); + } + + public static async Task Prev10() + { + await Vm?.ImageIterator.Next10Iteration(false); + } + + public static async Task Prev100() + { + await Vm?.ImageIterator.Next100Iteration(false); + } + public static async Task Up() { diff --git a/src/PicView.Avalonia/ViewModels/MainViewModel.cs b/src/PicView.Avalonia/ViewModels/MainViewModel.cs index 02c027d02..20cbe5a55 100644 --- a/src/PicView.Avalonia/ViewModels/MainViewModel.cs +++ b/src/PicView.Avalonia/ViewModels/MainViewModel.cs @@ -423,6 +423,10 @@ public bool IsFillSquareMenuChecked public ReactiveCommand? PreviousFolderCommand { get; } public ReactiveCommand? FirstCommand { get; } public ReactiveCommand? LastCommand { get; } + public ReactiveCommand? Skip10Command { get; } + public ReactiveCommand? Prev10Command { get; } + public ReactiveCommand? Skip100Command { get; } + public ReactiveCommand? Prev100Command { get; } public ReactiveCommand? OpenFileCommand { get; } public ReactiveCommand? SaveFileCommand { get; } public ReactiveCommand? SaveFileAsCommand { get; } diff --git a/src/PicView.Avalonia/ViewModels/ViewModelBase.cs b/src/PicView.Avalonia/ViewModels/ViewModelBase.cs index 9a7d40d4e..5a050bb15 100644 --- a/src/PicView.Avalonia/ViewModels/ViewModelBase.cs +++ b/src/PicView.Avalonia/ViewModels/ViewModelBase.cs @@ -236,10 +236,46 @@ public void UpdateLanguage() Quality = TranslationHelper.Translation.Quality; SaveAs = TranslationHelper.Translation.SaveAs; Reset = TranslationHelper.Translation.Reset; + AdvanceBy10Images = TranslationHelper.Translation.AdvanceBy10Images; + AdvanceBy100Images = TranslationHelper.Translation.AdvanceBy100Images; + GoBackBy10Images = TranslationHelper.Translation.GoBackBy10Images; + GoBackBy100Images = TranslationHelper.Translation.GoBackBy100Images; } #region Strings + private string? _advanceBy10Images; + + public string? AdvanceBy10Images + { + get => _advanceBy10Images; + set => this.RaiseAndSetIfChanged(ref _advanceBy10Images, value); + } + + private string? _advanceBy100Images; + + public string? AdvanceBy100Images + { + get => _advanceBy100Images; + set => this.RaiseAndSetIfChanged(ref _advanceBy100Images, value); + } + + private string? _goBackBy10Images; + + public string? GoBackBy10Images + { + get => _goBackBy10Images; + set => this.RaiseAndSetIfChanged(ref _goBackBy10Images, value); + } + + private string? _goBackBy100Images; + + public string? GoBackBy100Images + { + get => _goBackBy100Images; + set => this.RaiseAndSetIfChanged(ref _goBackBy100Images, value); + } + private string? _reset; public string? Reset diff --git a/src/PicView.Avalonia/Views/ShortcutsView.axaml b/src/PicView.Avalonia/Views/ShortcutsView.axaml index 4b5ea3080..6a42b7b93 100644 --- a/src/PicView.Avalonia/Views/ShortcutsView.axaml +++ b/src/PicView.Avalonia/Views/ShortcutsView.axaml @@ -47,6 +47,7 @@ TextAlignment="Center" x:Name="NavigationTextBlock" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +