|
@@ -1,6 +1,4 @@
|
|
-using Avalonia.Controls;
|
|
|
|
-using Avalonia.Threading;
|
|
|
|
-using PicView.Avalonia.Animations;
|
|
|
|
|
|
+using Avalonia.Threading;
|
|
using PicView.Avalonia.Gallery;
|
|
using PicView.Avalonia.Gallery;
|
|
using PicView.Avalonia.Navigation;
|
|
using PicView.Avalonia.Navigation;
|
|
using PicView.Avalonia.ViewModels;
|
|
using PicView.Avalonia.ViewModels;
|
|
@@ -120,147 +118,6 @@ public static class HideInterfaceLogic
|
|
|
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
- #region HoverButtons
|
|
|
|
-
|
|
|
|
- public static void AddHoverButtonEvents(Control parent, MainViewModel vm)
|
|
|
|
- {
|
|
|
|
- parent.PointerEntered += async delegate
|
|
|
|
- {
|
|
|
|
- await DoHoverButtonAnimation(isShown:true, parent);
|
|
|
|
- };
|
|
|
|
- parent.PointerExited += async delegate
|
|
|
|
- {
|
|
|
|
- await DoHoverButtonAnimation(isShown: false, parent);
|
|
|
|
- };
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public static void AddHoverButtonEvents(Control parent, Control childControl, MainViewModel vm)
|
|
|
|
- {
|
|
|
|
- childControl.PointerEntered += delegate
|
|
|
|
- {
|
|
|
|
- if (!Settings.UIProperties.ShowAltInterfaceButtons)
|
|
|
|
- {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!NavigationManager.CanNavigate(vm))
|
|
|
|
- {
|
|
|
|
- Dispatcher.UIThread.Invoke(() =>
|
|
|
|
- {
|
|
|
|
- parent.Opacity = 0;
|
|
|
|
- childControl.Opacity = 0;
|
|
|
|
- });
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (NavigationManager.GetCount <= 1)
|
|
|
|
- {
|
|
|
|
- Dispatcher.UIThread.Invoke(() =>
|
|
|
|
- {
|
|
|
|
- parent.Opacity = 0;
|
|
|
|
- childControl.Opacity = 0;
|
|
|
|
- });
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (childControl.IsPointerOver)
|
|
|
|
- {
|
|
|
|
- Dispatcher.UIThread.Invoke(() =>
|
|
|
|
- {
|
|
|
|
- parent.Opacity = 10;
|
|
|
|
- childControl.Opacity = 1;
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- parent.PointerEntered += async delegate
|
|
|
|
- {
|
|
|
|
- if (!Settings.UIProperties.ShowAltInterfaceButtons)
|
|
|
|
- {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- await DoHoverButtonAnimation(isShown:true, parent, childControl, vm);
|
|
|
|
- };
|
|
|
|
- parent.PointerExited += async delegate
|
|
|
|
- {
|
|
|
|
- await DoHoverButtonAnimation(isShown: false, parent, childControl, vm);
|
|
|
|
- };
|
|
|
|
- UIHelper.GetMainView.PointerExited += async delegate
|
|
|
|
- {
|
|
|
|
- var x = 0;
|
|
|
|
- while (_isHoverButtonAnimationRunning)
|
|
|
|
- {
|
|
|
|
- await Task.Delay(10);
|
|
|
|
- x++;
|
|
|
|
- if (x > 20)
|
|
|
|
- {
|
|
|
|
- await Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
|
- {
|
|
|
|
- if (!childControl.IsPointerOver)
|
|
|
|
- {
|
|
|
|
- parent.Opacity = 0;
|
|
|
|
- childControl.Opacity = 0;
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (parent.Opacity > 0)
|
|
|
|
- {
|
|
|
|
- await DoHoverButtonAnimation(isShown: false, parent, childControl, vm);
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private static bool _isHoverButtonAnimationRunning;
|
|
|
|
-
|
|
|
|
- private static async Task DoHoverButtonAnimation(bool isShown, Control parent)
|
|
|
|
- {
|
|
|
|
- if (_isHoverButtonAnimationRunning || !Settings.UIProperties.ShowAltInterfaceButtons)
|
|
|
|
- {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- _isHoverButtonAnimationRunning = true;
|
|
|
|
- var from = isShown ? 0d : 1d;
|
|
|
|
- var to = isShown ? 1d : 0d;
|
|
|
|
- var speed = isShown ? 0.3 : 0.45;
|
|
|
|
- var anim = AnimationsHelper.OpacityAnimation(from, to, speed);
|
|
|
|
- await anim.RunAsync(parent);
|
|
|
|
- _isHoverButtonAnimationRunning = false;
|
|
|
|
- }
|
|
|
|
- private static async Task DoHoverButtonAnimation(bool isShown, Control parent, Control childControl, MainViewModel vm)
|
|
|
|
- {
|
|
|
|
- if (_isHoverButtonAnimationRunning || !Settings.UIProperties.ShowAltInterfaceButtons)
|
|
|
|
- {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!NavigationManager.CanNavigate(vm))
|
|
|
|
- {
|
|
|
|
- parent.Opacity = 0;
|
|
|
|
- childControl.Opacity = 0;
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (NavigationManager.GetCount <= 1)
|
|
|
|
- {
|
|
|
|
- parent.Opacity = 0;
|
|
|
|
- childControl.Opacity = 0;
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- _isHoverButtonAnimationRunning = true;
|
|
|
|
- var from = isShown ? 0d : 1d;
|
|
|
|
- var to = isShown ? 1d : 0d;
|
|
|
|
- var speed = isShown ? 0.3 : 0.45;
|
|
|
|
- var anim = AnimationsHelper.OpacityAnimation(from, to, speed);
|
|
|
|
- await anim.RunAsync(childControl);
|
|
|
|
- _isHoverButtonAnimationRunning = false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- #endregion
|
|
|
|
-
|
|
|
|
public static async Task ToggleBottomGalleryShownInHiddenUI(MainViewModel vm)
|
|
public static async Task ToggleBottomGalleryShownInHiddenUI(MainViewModel vm)
|
|
{
|
|
{
|
|
Settings.Gallery.ShowBottomGalleryInHiddenUI = !Settings.Gallery
|
|
Settings.Gallery.ShowBottomGalleryInHiddenUI = !Settings.Gallery
|