Skip to content

Commit 42c1234

Browse files
committed
Add documentation comments
1 parent 00e56a9 commit 42c1234

14 files changed

+201
-24
lines changed

Nodify/EditorGestures.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ public class SelectionGestures
1313
/// <summary>Disable selection gestures.</summary>
1414
public static readonly SelectionGestures None = new SelectionGestures(MouseAction.None);
1515

16+
/// <summary>
17+
/// Initializes a new instance of the <see cref="SelectionGestures"/> class with specified mouse action
18+
/// and a flag indicating whether modifier keys should be ignored when releasing the mouse button.
19+
/// </summary>
20+
/// <param name="mouseAction">The mouse action to trigger the gestures.</param>
21+
/// <param name="ignoreModifierKeysOnRelease">
22+
/// A value indicating whether modifier keys (Alt, Shift, Control) should be ignored when the mouse button is released.
23+
/// </param>
1624
public SelectionGestures(MouseAction mouseAction, bool ignoreModifierKeysOnRelease)
1725
{
1826
Replace = new MouseGesture(mouseAction);
@@ -23,16 +31,33 @@ public SelectionGestures(MouseAction mouseAction, bool ignoreModifierKeysOnRelea
2331
Cancel = new KeyGesture(Key.Escape);
2432
}
2533

34+
/// <summary>
35+
/// Initializes a new instance of the <see cref="SelectionGestures"/> class with a specified mouse action.
36+
/// Modifier keys will be ignored when releasing the mouse button.
37+
/// </summary>
38+
/// <param name="mouseAction">The mouse action to trigger the gestures.</param>
2639
public SelectionGestures(MouseAction mouseAction)
2740
: this(mouseAction, true)
2841
{
2942
}
3043

44+
/// <summary>
45+
/// Initializes a new instance of the <see cref="SelectionGestures"/> class with a flag indicating
46+
/// whether modifier keys should be ignored when releasing the mouse button.
47+
/// The default mouse action is <see cref="MouseAction.LeftClick"/>.
48+
/// </summary>
49+
/// <param name="ignoreModifierKeysOnRelease">
50+
/// A value indicating whether modifier keys (Alt, Shift, Control) should be ignored when the mouse button is released.
51+
/// </param>
3152
public SelectionGestures(bool ignoreModifierKeysOnRelease)
3253
: this(MouseAction.LeftClick, ignoreModifierKeysOnRelease)
3354
{
3455
}
3556

57+
/// <summary>
58+
/// Initializes a new instance of the <see cref="SelectionGestures"/> class with default values:
59+
/// the mouse action is <see cref="MouseAction.LeftClick"/>, and modifier keys are ignored when releasing the mouse button.
60+
/// </summary>
3661
public SelectionGestures() : this(true)
3762
{
3863
}

Nodify/EditorStates/ConnectorConnectingState.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,18 @@
33

44
namespace Nodify
55
{
6+
/// <summary>
7+
/// Represents the state for handling a connector's connecting operation in the editor,
8+
/// enabling drag-based creation of connections between connectors.
9+
/// </summary>
610
public class ConnectorConnectingState : DragState<Connector>
711
{
812
protected override bool CanCancel => Connector.AllowPendingConnectionCancellation;
913

14+
/// <summary>
15+
/// Initializes a new instance of the <see cref="ConnectorConnectingState"/> class.
16+
/// </summary>
17+
/// <param name="connector">The connector associated with this state.</param>
1018
public ConnectorConnectingState(Connector connector)
1119
: base(connector, EditorGestures.Mappings.Connector.Connect, EditorGestures.Mappings.Connector.CancelAction)
1220
{

Nodify/EditorStates/ConnectorDisconnectState.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22

33
namespace Nodify
44
{
5+
/// <summary>
6+
/// Represents a state in which a connector can be disconnected from its connections based on specific gestures.
7+
/// </summary>
58
public class ConnectorDisconnectState : InputElementState<Connector>
69
{
10+
/// <summary>
11+
/// Initializes a new instance of the <see cref="ConnectorDisconnectState"/> class.
12+
/// </summary>
13+
/// <param name="connector">The <see cref="Connector"/> element associated with this state.</param>
714
public ConnectorDisconnectState(Connector connector) : base(connector)
815
{
916
}

Nodify/EditorStates/ContainerDefaultState.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace Nodify
55
{
66
/// <summary>The default state of the <see cref="ItemContainer"/>.</summary>
7-
public class ContainerDefaultState : InputElementStateStack<ItemContainer>
7+
public sealed class ContainerDefaultState : InputElementStateStack<ItemContainer>
88
{
99
public ContainerDefaultState(ItemContainer container) : base(container)
1010
{

Nodify/EditorStates/DragState.cs

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,70 @@
33

44
namespace Nodify
55
{
6+
/// <summary>
7+
/// Represents an abstract base class for managing drag operations within a UI element.
8+
/// Provides a framework for handling input gestures such as starting, canceling, and completing drag operations.
9+
/// </summary>
10+
/// <typeparam name="TElement">The type of <see cref="FrameworkElement"/> that owns the state.</typeparam>
611
public abstract class DragState<TElement> : InputElementState<TElement>, IInputHandler
712
where TElement : FrameworkElement
813
{
14+
/// <summary>
15+
/// Gets the gesture used to cancel the drag operation, if defined.
16+
/// </summary>
917
protected InputGesture? CancelGesture { get; }
18+
19+
/// <summary>
20+
/// Gets the gesture used to begin the drag operation.
21+
/// </summary>
1022
protected InputGesture BeginGesture { get; }
1123

24+
/// <summary>
25+
/// Indicates whether the element has a context menu associated with it.
26+
/// </summary>
27+
/// <remarks>This property is used to suppress the context menu when a drag operation is performed using the right mouse button.</remarks>
1228
protected virtual bool HasContextMenu => Element.ContextMenu != null;
29+
30+
/// <summary>
31+
/// Determines if the drag operation can begin (see <see cref="OnBegin(InputEventArgs)"/>).
32+
/// </summary>
1333
protected virtual bool CanBegin { get; } = true;
34+
35+
/// <summary>
36+
/// Determines if the drag operation can be canceled (see <see cref="OnCancel(InputEventArgs)"/>).
37+
/// </summary>
1438
protected virtual bool CanCancel { get; } = true;
39+
40+
/// <summary>
41+
/// Indicates if the drag gesture is a toggle, meaning the same gesture can be used to both start and stop the operation.
42+
/// </summary>
1543
protected virtual bool IsToggle { get; }
44+
45+
/// <summary>
46+
/// Gets or sets the UI element used to calculate the mouse position during the drag operation.
47+
/// </summary>
1648
protected IInputElement PositionElement { get; set; }
1749

1850
private bool _canReceiveInput;
1951
private Point _initialPosition;
2052

21-
/// <summary>Constructs a new <see cref="EditorState"/>.</summary>
22-
/// <param name="element">The owner of the state.</param>
53+
/// <summary>
54+
/// Initializes a new instance of the <see cref="DragState{TElement}"/> class with a begin gesture.
55+
/// </summary>
56+
/// <param name="element">The element associated with this state.</param>
57+
/// <param name="beginGesture">The gesture used to start the drag operation.</param>
2358
public DragState(TElement element, InputGesture beginGesture) : base(element)
2459
{
2560
BeginGesture = beginGesture;
2661
PositionElement = element;
2762
}
2863

64+
/// <summary>
65+
/// Initializes a new instance of the <see cref="DragState{TElement}"/> class with begin and cancel gestures.
66+
/// </summary>
67+
/// <param name="element">The element associated with this state.</param>
68+
/// <param name="beginGesture">The gesture used to start the drag operation.</param>
69+
/// <param name="cancelGesture">The gesture used to cancel the drag operation.</param>
2970
public DragState(TElement element, InputGesture beginGesture, InputGesture cancelGesture)
3071
: this(element, beginGesture)
3172
{
@@ -116,6 +157,11 @@ private void EndDrag(InputEventArgs e)
116157
}
117158
}
118159

160+
/// <summary>
161+
/// Determines if the given input event represents the release of an input gesture.
162+
/// </summary>
163+
/// <param name="e">The input event to evaluate.</param>
164+
/// <returns>True if the event represents the release of a gesture; otherwise, false.</returns>
119165
protected virtual bool IsInputEventReleased(InputEventArgs e)
120166
{
121167
if (e is MouseButtonEventArgs mbe && mbe.ButtonState == MouseButtonState.Released)
@@ -130,6 +176,11 @@ protected virtual bool IsInputEventReleased(InputEventArgs e)
130176
return false;
131177
}
132178

179+
/// <summary>
180+
/// Determines if the given input event represents the press of an input gesture.
181+
/// </summary>
182+
/// <param name="e">The input event to evaluate.</param>
183+
/// <returns>True if the event represents the press of a gesture; otherwise, false.</returns>
133184
protected virtual bool IsInputEventPressed(InputEventArgs e)
134185
{
135186
if (e is MouseButtonEventArgs mbe && mbe.ButtonState == MouseButtonState.Pressed)
@@ -144,14 +195,26 @@ protected virtual bool IsInputEventPressed(InputEventArgs e)
144195
return false;
145196
}
146197

198+
/// <summary>
199+
/// Called when the drag operation begins. Override to provide custom behavior.
200+
/// </summary>
201+
/// <param name="e">The input event that started the operation.</param>
147202
protected virtual void OnBegin(InputEventArgs e)
148203
{
149204
}
150205

206+
/// <summary>
207+
/// Called when the drag operation ends. Override to provide custom behavior.
208+
/// </summary>
209+
/// <param name="e">The input event that ended the operation.</param>
151210
protected virtual void OnEnd(InputEventArgs e)
152211
{
153212
}
154213

214+
/// <summary>
215+
/// Called when the drag operation is canceled. Override to provide custom behavior.
216+
/// </summary>
217+
/// <param name="e">The input event that canceled the operation.</param>
155218
protected virtual void OnCancel(InputEventArgs e)
156219
{
157220
}

Nodify/EditorStates/EditorCuttingState.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@
22

33
namespace Nodify
44
{
5+
/// <summary>
6+
/// Represents the cutting state in the <see cref="NodifyEditor"/>, allowing users to cut connections between elements using a drag gesture.
7+
/// </summary>
58
public class EditorCuttingState : DragState<NodifyEditor>
69
{
710
protected override bool HasContextMenu => Element.HasContextMenu;
811
protected override bool CanCancel => NodifyEditor.AllowCuttingCancellation;
912

13+
/// <summary>
14+
/// Initializes a new instance of the <see cref="EditorCuttingState"/> class.
15+
/// </summary>
16+
/// <param name="editor">The <see cref="NodifyEditor"/> associated with this state.</param>
1017
public EditorCuttingState(NodifyEditor editor)
1118
: base(editor, EditorGestures.Mappings.Editor.Cutting, EditorGestures.Mappings.Editor.CancelAction)
1219
{
@@ -15,7 +22,6 @@ public EditorCuttingState(NodifyEditor editor)
1522
protected override void OnBegin(InputEventArgs e)
1623
=> Element.BeginCutting();
1724

18-
/// <inheritdoc />
1925
protected override void OnMouseMove(MouseEventArgs e)
2026
=> Element.UpdateCuttingLine(Element.MouseLocation);
2127

Nodify/EditorStates/EditorPanningState.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
namespace Nodify
66
{
7-
/// <summary>The panning state of the editor.</summary>
7+
/// <summary>
8+
/// Represents the panning state of the <see cref="NodifyEditor"/>, allowing the user to pan the viewport by clicking and dragging.
9+
/// </summary>
810
public class EditorPanningState : DragState<NodifyEditor>
911
{
1012
protected override bool HasContextMenu => Element.HasContextMenu;
@@ -13,8 +15,10 @@ public class EditorPanningState : DragState<NodifyEditor>
1315

1416
private Point _prevPosition;
1517

16-
/// <summary>Constructs an instance of the <see cref="EditorPanningState"/> state.</summary>
17-
/// <param name="editor">The owner of the state.</param>
18+
/// <summary>
19+
/// Initializes a new instance of the <see cref="EditorPanningState"/> class.
20+
/// </summary>
21+
/// <param name="editor">The <see cref="NodifyEditor"/> associated with this state.</param>
1822
public EditorPanningState(NodifyEditor editor)
1923
: base(editor, EditorGestures.Mappings.Editor.Pan, EditorGestures.Mappings.Editor.CancelAction)
2024
{
@@ -26,7 +30,6 @@ protected override void OnBegin(InputEventArgs e)
2630
Element.BeginPanning();
2731
}
2832

29-
/// <inheritdoc />
3033
protected override void OnMouseMove(MouseEventArgs e)
3134
{
3235
var currentMousePosition = e.GetPosition(Element);
@@ -41,10 +44,16 @@ protected override void OnCancel(InputEventArgs e)
4144
=> Element.CancelPanning();
4245
}
4346

47+
/// <summary>
48+
/// Represents the panning state of the <see cref="NodifyEditor"/> using the mouse wheel.
49+
/// Allows the user to pan horizontally or vertically by holding modifier keys while scrolling the mouse wheel.
50+
/// </summary>
4451
public class EditorPanningWithMouseWheelState : InputElementState<NodifyEditor>
4552
{
46-
/// <summary>Constructs an instance of the <see cref="EditorPanningWithMouseWheelState"/> state.</summary>
47-
/// <param name="editor">The owner of the state.</param>
53+
/// <summary>
54+
/// Initializes a new instance of the <see cref="EditorPanningWithMouseWheelState"/> class.
55+
/// </summary>
56+
/// <param name="editor">The <see cref="NodifyEditor"/> associated with this state.</param>
4857
public EditorPanningWithMouseWheelState(NodifyEditor editor) : base(editor)
4958
{
5059
}

Nodify/EditorStates/EditorPushingItemsState.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,20 @@
55

66
namespace Nodify
77
{
8+
/// <summary>
9+
/// Represents the state of the <see cref="NodifyEditor"/> during a "push items" operation, allowing users to move items within the editor by dragging.
10+
/// </summary>
811
public class EditorPushingItemsState : DragState<NodifyEditor>
912
{
1013
protected override bool HasContextMenu => Element.HasContextMenu;
1114
protected override bool CanCancel => NodifyEditor.AllowPushItemsCancellation;
1215

1316
private Point _prevPosition;
1417

18+
/// <summary>
19+
/// Initializes a new instance of the <see cref="EditorPushingItemsState"/> class.
20+
/// </summary>
21+
/// <param name="editor">The <see cref="NodifyEditor"/> associated with this state.</param>
1522
public EditorPushingItemsState(NodifyEditor editor)
1623
: base(editor, EditorGestures.Mappings.Editor.PushItems, EditorGestures.Mappings.Editor.CancelAction)
1724
{
@@ -20,7 +27,6 @@ public EditorPushingItemsState(NodifyEditor editor)
2027
protected override void OnBegin(InputEventArgs e)
2128
=> _prevPosition = Element.MouseLocation;
2229

23-
/// <inheritdoc />
2430
protected override void OnMouseMove(MouseEventArgs e)
2531
{
2632
if (Element.IsPushingItems)

Nodify/EditorStates/EditorSelectingState.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@
22

33
namespace Nodify
44
{
5-
/// <summary>The selecting state of the editor.</summary>
5+
/// <summary>
6+
/// Represents the selecting state of the <see cref="NodifyEditor"/>.
7+
/// This state is responsible for handling item selection within the editor.
8+
/// </summary>
69
public class EditorSelectingState : DragState<NodifyEditor>
710
{
811
protected override bool HasContextMenu => Element.HasContextMenu;
912
protected override bool CanBegin => Element.CanSelectMultipleItems && !Element.IsPanning;
1013
protected override bool CanCancel => NodifyEditor.AllowSelectionCancellation;
1114

12-
/// <summary>Constructs an instance of the <see cref="EditorSelectingState"/> state.</summary>
13-
/// <param name="editor">The owner of the state.</param>
14-
/// <param name="type">The selection strategy.</param>
15+
/// <summary>
16+
/// Initializes a new instance of the <see cref="EditorSelectingState"/> class.
17+
/// </summary>
18+
/// <param name="editor">The <see cref="NodifyEditor"/> associated with this state.</param>
1519
public EditorSelectingState(NodifyEditor editor)
1620
: base(editor, EditorGestures.Mappings.Editor.Selection.Select, EditorGestures.Mappings.Editor.Selection.Cancel)
1721
{
@@ -23,7 +27,6 @@ protected override void OnBegin(InputEventArgs e)
2327
Element.BeginSelecting(selectionType);
2428
}
2529

26-
/// <inheritdoc />
2730
protected override void OnMouseMove(MouseEventArgs e)
2831
=> Element.UpdateSelection(Element.MouseLocation);
2932

Nodify/EditorStates/EditorZoomingState.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
33

44
namespace Nodify
55
{
6+
/// <summary>
7+
/// Represents the zooming state of the <see cref="NodifyEditor"/>.
8+
/// This state handles zooming operations using the mouse wheel with an optional modifier key.
9+
/// </summary>
610
public class EditorZoomingState : InputElementState<NodifyEditor>
711
{
8-
/// <summary>Constructs an instance of the <see cref="EditorZoomingState"/> state.</summary>
9-
/// <param name="editor">The owner of the state.</param>
12+
/// <summary>
13+
/// Initializes a new instance of the <see cref="EditorZoomingState"/> class.
14+
/// </summary>
15+
/// <param name="editor">The <see cref="NodifyEditor"/> associated with this state.</param>
1016
public EditorZoomingState(NodifyEditor editor) : base(editor)
1117
{
1218
}

0 commit comments

Comments
 (0)