Skip to content

Commit

Permalink
Move NavSpeed user setting to Commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben2776 committed Feb 14, 2025
1 parent 6e0645f commit 9efb8e1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
28 changes: 28 additions & 0 deletions src/PicView.Avalonia/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1599,13 +1599,27 @@ public MainViewModel(IPlatformSpecificService? platformSpecificService)

NextButtonCommand = ReactiveCommand.Create(() =>
{
var button = UIHelper.GetBottomBar?.NextButton;
if (button != null)
{
button.Interval =
(int)TimeSpan.FromSeconds(SettingsHelper.Settings.UIProperties.NavSpeed).TotalMilliseconds;
}

Task.Run(() =>
NavigationManager.NavigateAndPositionCursor(next: true, arrow: false, vm: this)
);
});

NextArrowButtonCommand = ReactiveCommand.Create( () =>
{
var button = UIHelper.GetMainView?.ClickArrowRight?.PolyButton;
if (button != null)
{
button.Interval =
(int)TimeSpan.FromSeconds(SettingsHelper.Settings.UIProperties.NavSpeed).TotalMilliseconds;
}

Task.Run(() =>
NavigationManager.NavigateAndPositionCursor(next:true, arrow: true, vm: this)
);
Expand All @@ -1623,13 +1637,27 @@ public MainViewModel(IPlatformSpecificService? platformSpecificService)

PreviousButtonCommand = ReactiveCommand.Create( () =>
{
var button = UIHelper.GetBottomBar?.PreviousButton;
if (button != null)
{
button.Interval =
(int)TimeSpan.FromSeconds(SettingsHelper.Settings.UIProperties.NavSpeed).TotalMilliseconds;
}

Task.Run(() =>
NavigationManager.NavigateAndPositionCursor(next:false, arrow: false, vm: this)
);
});

PreviousArrowButtonCommand = ReactiveCommand.Create( () =>
{
var button = UIHelper.GetMainView?.ClickArrowLeft?.PolyButton;
if (button != null)
{
button.Interval =
(int)TimeSpan.FromSeconds(SettingsHelper.Settings.UIProperties.NavSpeed).TotalMilliseconds;
}

Task.Run(() =>
NavigationManager.NavigateAndPositionCursor(next:false, arrow: true, vm: this)
);
Expand Down
9 changes: 0 additions & 9 deletions src/PicView.Avalonia/Views/BottomBar.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Runtime.InteropServices;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
Expand Down Expand Up @@ -66,14 +65,6 @@ public BottomBar()
NextButton.Foreground = new SolidColorBrush(color);
PreviousButton.Foreground = new SolidColorBrush(color);
}

// TODO add interval to mainviewmodel
NextButton.Interval =
(int)TimeSpan.FromSeconds(Settings.UIProperties.NavSpeed).TotalMilliseconds;

PreviousButton.Interval =
(int)TimeSpan.FromSeconds(Settings.UIProperties.NavSpeed).TotalMilliseconds;

};
}

Expand Down
4 changes: 0 additions & 4 deletions src/PicView.Avalonia/Views/UC/Buttons/ClickArrowLeft.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ public ClickArrowLeft()
}
HideInterfaceLogic.AddHoverButtonEvents(this, PolyButton, vm);
PointerWheelChanged += async (_, e) => await vm.ImageViewer.PreviewOnPointerWheelChanged(this, e);

// TODO add interval to mainviewmodel
PolyButton.Interval =
(int)TimeSpan.FromSeconds(Settings.UIProperties.NavSpeed).TotalMilliseconds;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ public ClickArrowRight()
}
HideInterfaceLogic.AddHoverButtonEvents(this, PolyButton, vm);
PointerWheelChanged += async (_, e) => await vm.ImageViewer.PreviewOnPointerWheelChanged(this, e);

// TODO add interval to mainviewmodel
PolyButton.Interval =
(int)TimeSpan.FromSeconds(Settings.UIProperties.NavSpeed).TotalMilliseconds;
};
}
}

0 comments on commit 9efb8e1

Please sign in to comment.