Skip to content

Commit

Permalink
Refactor, fix, misc.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben2776 committed Sep 18, 2024
1 parent 7065158 commit 2b716b2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
9 changes: 6 additions & 3 deletions src/PicView.Avalonia/Navigation/Slideshow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public static void StopSlideshow(MainViewModel vm)
_timer = null;
vm.PlatformService.EnableScreensaver();
}
static bool InitiateAndStart(MainViewModel vm)

private static bool InitiateAndStart(MainViewModel vm)
{
if (!NavigationHelper.CanNavigate(vm))
{
Expand All @@ -69,7 +69,10 @@ static bool InitiateAndStart(MainViewModel vm)
Enabled = true,
};
_timer.Elapsed += async (_, _) =>
{
// TODO: add animation
await vm.ImageIterator.NextIteration(NavigateTo.Next);
};
}
else if (_timer.Enabled)
{
Expand All @@ -96,7 +99,7 @@ private static async Task Start(MainViewModel vm, double seconds)
{
await WindowHelper.ToggleFullscreen(vm, false);
}
// TODO: add animation

await vm.ImageIterator.NextIteration(NavigateTo.Next);
}
}
10 changes: 10 additions & 0 deletions src/PicView.Avalonia/Views/UC/Menus/ImageMenu.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,16 @@
</StackPanel>
<SplitButton.Flyout>
<MenuFlyout Placement="Top" ShowMode="Transient">
<Button
Background="Transparent"
Command="{CompiledBinding StartSlideShowTask}"
CommandParameter="2000"
Width="86">
<TextBlock Classes="txt">
<Run Text="2 " />
<Run Text="{CompiledBinding SecAbbreviation, Mode=OneWay}" />
</TextBlock>
</Button>
<Button
Background="Transparent"
Command="{CompiledBinding StartSlideShowTask}"
Expand Down
11 changes: 6 additions & 5 deletions src/PicView.Avalonia/Views/UC/Menus/ImageMenu.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Reactive.Linq;
using Avalonia.Input;
using PicView.Avalonia.CustomControls;
using PicView.Avalonia.Navigation;
using PicView.Avalonia.ViewModels;
using ReactiveUI;

Expand All @@ -26,6 +27,11 @@ private async Task GoToPicBox_OnKeyDown(KeyEventArgs e)
return;
}

if (!NavigationHelper.CanNavigate(vm))
{
return;
}

if (!int.TryParse(GoToPicBox.Text, out var number))
{
return;
Expand All @@ -44,11 +50,6 @@ private async Task GoToPicBox_OnKeyDown(KeyEventArgs e)
number--;
}

if (vm.ImageIterator is null)
{
return;
}

await vm.ImageIterator.IterateToIndex(number).ConfigureAwait(false);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/PicView.WindowsNT/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static partial class NativeMethods

public static void DisableScreensaver()
{
_ = SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
_ = SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED);
}

public static void EnableScreensaver()
Expand Down

0 comments on commit 2b716b2

Please sign in to comment.