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,44 @@
using System.Windows;
using System.Windows.Input;
namespace Nodify.Interactivity
{
public static partial class ConnectorState
{
/// <summary>
/// Represents the state for handling a connector's connecting operation in the editor,
/// enabling drag-based creation of connections between connectors.
/// </summary>
public class Connecting : DragState<Connector>
{
protected override bool HasContextMenu => Element.HasContextMenu;
protected override bool CanCancel => Connector.AllowPendingConnectionCancellation;
protected override bool IsToggle => EnableToggledConnectingMode;
/// <summary>
/// Initializes a new instance of the <see cref="Connecting"/> class.
/// </summary>
/// <param name="connector">The connector associated with this state.</param>
public Connecting(Connector connector)
: base(connector, EditorGestures.Mappings.Connector.Connect, EditorGestures.Mappings.Connector.CancelAction)
{
PositionElement = Element.Editor ?? (IInputElement)Element;
}
protected override void OnBegin(InputEventArgs e)
=> Element.BeginConnecting();
protected override void OnEnd(InputEventArgs e)
=> Element.EndConnecting();
protected override void OnCancel(InputEventArgs e)
=> Element.CancelConnecting();
protected override void OnMouseMove(MouseEventArgs e)
{
Point editorPosition = Element.GetLocationInsideEditor(e); // could also use Element.Editor.MouseLocation
Element.UpdatePendingConnection(editorPosition);
}
}
}
}

View File

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

View File

@@ -0,0 +1,31 @@
using System.Windows.Input;
namespace Nodify.Interactivity
{
public static partial class ConnectorState
{
/// <summary>
/// Represents the default input state for a <see cref="Connector"/>.
/// </summary>
public class Default : InputElementState<Connector>
{
/// <summary>
/// Initializes a new instance of the <see cref="Default"/> class.
/// </summary>
/// <param name="connector">The <see cref="Connector"/> element associated with this state.</param>
public Default(Connector connector) : base(connector)
{
}
protected override void OnMouseDown(MouseButtonEventArgs e)
{
// Allow context menu to appear
if (e.ChangedButton == MouseButton.Right && Element.HasContextMenu)
{
Element.Focus();
e.Handled = true; // prevents the editor capturing the mouse
}
}
}
}
}

View File

@@ -0,0 +1,51 @@
using System.Windows.Input;
namespace Nodify.Interactivity
{
public static partial class ConnectorState
{
/// <summary>
/// Represents a state in which a connector can be disconnected from its connections based on specific gestures.
/// </summary>
public class Disconnect : InputElementState<Connector>
{
/// <summary>
/// Initializes a new instance of the <see cref="Disconnect"/> class.
/// </summary>
/// <param name="connector">The <see cref="Connector"/> element associated with this state.</param>
public Disconnect(Connector connector) : base(connector)
{
}
protected override void OnMouseDown(MouseButtonEventArgs e)
{
EditorGestures.ConnectorGestures gestures = EditorGestures.Mappings.Connector;
if (gestures.Disconnect.Matches(e.Source, e))
{
Element.Focus();
e.Handled = true; // prevent interacting with the container
}
}
protected override void OnMouseUp(MouseButtonEventArgs e)
{
EditorGestures.ConnectorGestures gestures = EditorGestures.Mappings.Connector;
if (gestures.Disconnect.Matches(e.Source, e))
{
Element.RemoveConnections();
e.Handled = true; // prevent opening context menu
}
}
protected override void OnKeyDown(KeyEventArgs e)
{
EditorGestures.ConnectorGestures gestures = EditorGestures.Mappings.Connector;
if (gestures.Disconnect.Matches(e.Source, e))
{
Element.RemoveConnections();
e.Handled = true;
}
}
}
}
}