Files
Wino-Mail/Wino.Core.UWP/Controls/WinoNavigationViewItem.cs

47 lines
1.4 KiB
C#
Raw Normal View History

2024-04-18 01:44:37 +02:00
using System.Numerics;
using Microsoft.UI.Xaml.Controls;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Hosting;
2025-02-16 11:54:23 +01:00
namespace Wino.Core.UWP.Controls;
public partial class WinoNavigationViewItem : NavigationViewItem
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
public bool IsDraggingItemOver
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
get { return (bool)GetValue(IsDraggingItemOverProperty); }
set { SetValue(IsDraggingItemOverProperty, value); }
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
public static readonly DependencyProperty IsDraggingItemOverProperty = DependencyProperty.Register(nameof(IsDraggingItemOver), typeof(bool), typeof(WinoNavigationViewItem), new PropertyMetadata(false, OnIsDraggingItemOverChanged));
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
private static void OnIsDraggingItemOverChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
{
if (obj is WinoNavigationViewItem control)
control.UpdateDragEnterState();
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
private void UpdateDragEnterState()
{
// TODO: Add animation. Maybe after overriding DragUI in shell?
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
//if (IsDraggingItemOver)
//{
// ScaleAnimation(new System.Numerics.Vector3(1.2f, 1.2f, 1.2f));
//}
//else
//{
// ScaleAnimation(new System.Numerics.Vector3(1f, 1f, 1f));
//}
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
private void ScaleAnimation(Vector3 vector)
{
if (Content is UIElement content)
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
var visual = ElementCompositionPreview.GetElementVisual(content);
visual.Scale = vector;
2024-04-18 01:44:37 +02:00
}
}
}