Add project files.
This commit is contained in:
11
Nodify/Connections/States/ConnectionState.cs
Normal file
11
Nodify/Connections/States/ConnectionState.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Nodify.Interactivity
|
||||
{
|
||||
public static partial class ConnectionState
|
||||
{
|
||||
internal static void RegisterDefaultHandlers()
|
||||
{
|
||||
InputProcessor.Shared<BaseConnection>.RegisterHandlerFactory(elem => new Disconnect(elem));
|
||||
InputProcessor.Shared<BaseConnection>.RegisterHandlerFactory(elem => new Split(elem));
|
||||
}
|
||||
}
|
||||
}
|
||||
41
Nodify/Connections/States/Disconnect.cs
Normal file
41
Nodify/Connections/States/Disconnect.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Nodify.Interactivity
|
||||
{
|
||||
public static partial class ConnectionState
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a state in which a connection can be disconnected from its connectors based on specific gestures.
|
||||
/// </summary>
|
||||
public class Disconnect : InputElementState<BaseConnection>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Disconnect"/> class.
|
||||
/// </summary>
|
||||
/// <param name="connection">The <see cref="BaseConnection"/> element associated with this state.</param>
|
||||
public Disconnect(BaseConnection connection) : base(connection)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseButtonEventArgs e)
|
||||
{
|
||||
EditorGestures.ConnectionGestures gestures = EditorGestures.Mappings.Connection;
|
||||
if (gestures.Disconnect.Matches(e.Source, e))
|
||||
{
|
||||
Element.Focus();
|
||||
e.Handled = true; // prevent interacting with the editor
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseButtonEventArgs e)
|
||||
{
|
||||
EditorGestures.ConnectionGestures gestures = EditorGestures.Mappings.Connection;
|
||||
if (gestures.Disconnect.Matches(e.Source, e))
|
||||
{
|
||||
Element.Remove();
|
||||
e.Handled = true; // prevent opening context menu
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
Nodify/Connections/States/Split.cs
Normal file
33
Nodify/Connections/States/Split.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Nodify.Interactivity
|
||||
{
|
||||
public static partial class ConnectionState
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a state in which a connection can be split.
|
||||
/// </summary>
|
||||
public class Split : InputElementState<BaseConnection>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Split"/> class.
|
||||
/// </summary>
|
||||
/// <param name="connection">The <see cref="BaseConnection"/> element associated with this state.</param>
|
||||
public Split(BaseConnection connection) : base(connection)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseButtonEventArgs e)
|
||||
{
|
||||
EditorGestures.ConnectionGestures gestures = EditorGestures.Mappings.Connection;
|
||||
if (gestures.Split.Matches(e.Source, e))
|
||||
{
|
||||
Element.Focus();
|
||||
Element.SplitAtLocation(e.GetPosition(Element));
|
||||
|
||||
e.Handled = true; // prevent interacting with the editor
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user