Add project files.

This commit is contained in:
Ankitkumar Satapara
2026-04-17 22:31:58 +05:30
commit 21aaef6776
473 changed files with 50152 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
using System.Windows;
using System.Windows.Input;
namespace Nodify.Interactivity
{
public static partial class MinimapState
{
public class KeyboardNavigation : InputElementState<Minimap>
{
public KeyboardNavigation(Minimap element) : base(element)
{
}
protected override void OnKeyDown(KeyEventArgs e)
{
if (Element.IsKeyboardFocused)
{
var gestures = EditorGestures.Mappings.Minimap;
if (gestures.Pan.TryGetNavigationDirection(e, out var panDirection))
{
var panning = new Vector(-panDirection.X * Minimap.NavigationStepSize, panDirection.Y * Minimap.NavigationStepSize);
Element.UpdatePanning(panning);
e.Handled = true;
}
else if (gestures.ResetViewport.Matches(e.Source, e))
{
Element.ResetViewport();
e.Handled = true;
}
}
}
}
}
}

View File

@@ -0,0 +1,17 @@
namespace Nodify.Interactivity
{
public static partial class MinimapState
{
/// <summary>
/// Determines whether toggled panning mode is enabled, allowing the user to start and end the interaction in two steps with the same input gesture.
/// </summary>
public static bool EnableToggledPanningMode { get; set; }
internal static void RegisterDefaultHandlers()
{
InputProcessor.Shared<Minimap>.RegisterHandlerFactory(elem => new Panning(elem));
InputProcessor.Shared<Minimap>.RegisterHandlerFactory(elem => new Zooming(elem));
InputProcessor.Shared<Minimap>.RegisterHandlerFactory(elem => new KeyboardNavigation(elem));
}
}
}

View File

@@ -0,0 +1,38 @@
using System.Windows.Input;
namespace Nodify.Interactivity
{
public static partial class MinimapState
{
/// <summary>
/// Represents the panning state of the <see cref="Minimap"/>, allowing the user to pan the viewport by clicking and dragging.
/// </summary>
public class Panning : DragState<Minimap>
{
protected override bool CanBegin => !Element.IsReadOnly;
protected override bool CanCancel => Minimap.AllowPanningCancellation;
protected override bool IsToggle => EnableToggledPanningMode;
/// <summary>
/// Initializes a new instance of the <see cref="Panning"/> class.
/// </summary>
/// <param name="minimap">The <see cref="Minimap"/> associated with this state.</param>
public Panning(Minimap minimap)
: base(minimap, EditorGestures.Mappings.Minimap.DragViewport, EditorGestures.Mappings.Minimap.CancelAction)
{
}
protected override void OnBegin(InputEventArgs e)
=> Element.BeginPanning();
protected override void OnMouseMove(MouseEventArgs e)
=> Element.UpdatePanning(Element.MouseLocation);
protected override void OnEnd(InputEventArgs e)
=> Element.EndPanning();
protected override void OnCancel(InputEventArgs e)
=> Element.CancelPanning();
}
}
}

View File

@@ -0,0 +1,52 @@
using System;
using System.Windows.Input;
namespace Nodify.Interactivity
{
public static partial class MinimapState
{
/// <summary>
/// Represents the zooming state of the <see cref="Minimap"/>.
/// This state handles zooming operations using the mouse wheel with an optional modifier key.
/// </summary>
public class Zooming : InputElementState<Minimap>
{
/// <summary>
/// Initializes a new instance of the <see cref="Zooming"/> class.
/// </summary>
/// <param name="minimap">The <see cref="Minimap"/> associated with this state.</param>
public Zooming(Minimap minimap) : base(minimap)
{
}
protected override void OnMouseWheel(MouseWheelEventArgs e)
{
if (!Element.IsReadOnly && EditorGestures.Mappings.Minimap.ZoomModifierKey == Keyboard.Modifiers)
{
double zoom = Math.Pow(2.0, e.Delta / 3.0 / Mouse.MouseWheelDeltaForOneLine);
Element.ZoomAtPosition(zoom, Element.MouseLocation);
e.Handled = true;
}
}
protected override void OnKeyDown(KeyEventArgs e)
{
var gestures = EditorGestures.Mappings.Minimap;
if (!Element.IsReadOnly)
{
if (gestures.ZoomIn.Matches(e.Source, e))
{
Element.ZoomIn();
e.Handled = true;
}
else if (gestures.ZoomOut.Matches(e.Source, e))
{
Element.ZoomOut();
e.Handled = true;
}
}
}
}
}
}