Skip to content

Commit 1f90d2f

Browse files
authored
Merge pull request #223 from miroiu/master
Merge master into release-v7.0.0
2 parents 994a1ca + 9b3d36e commit 1f90d2f

File tree

23 files changed

+251
-161
lines changed

23 files changed

+251
-161
lines changed

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,35 @@
66
> - Features:
77
> - Bugfixes:
88
9+
#### **Version 7.0.4**
10+
11+
> - Features:
12+
> - Added AsRef extension method to InputGesture to convert it to an InputGestureRef
13+
> - Bugfixes:
14+
> - Fixed an issue where the gesture used for EditorGestures.Editor.SelectAll extracted from the ApplicationCommands was assumed to be a KeyGesture
15+
> - Fixed overrides of DrawDirectionalArrowheadGeometry virtual method not working in subclasses of the built in connections
16+
> - Fixed a memory leak caused by the auto panning timer
17+
18+
#### **Version 7.0.3**
19+
20+
> - Bugfixes:
21+
> - Fixed an issue where the SelectedEvent and UnselectedEvent events on the ItemContainer were not raised when the selection was completed
22+
23+
#### **Version 7.0.2**
24+
25+
> - Features:
26+
> - Added EditorGestures.Editor.SelectAll
27+
> - Bugfixes:
28+
> - Fixed an issue where the EditorCommands.SelectAll gesture could not be customized
29+
30+
#### **Version 7.0.1**
31+
32+
> - Bugfixes:
33+
> - Fixed an issue where connections would not gain focus when selected, which could prevent editor keybindings from functioning in certain scenarios
34+
> - Resolved an issue where selecting a node did not deselect connections and vice versa
35+
> - Fixed a bug preventing ItemContainers from being selected when the mouse could not be captured
36+
> - Fixed an issue with key detection in Japanese IME environments, causing issues with the MouseGesture
37+
938
#### **Version 7.0.0**
1039

1140
> - Breaking Changes:

Examples/Nodify.Calculator/EditorView.xaml.cs

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,57 @@
1-
using System.Windows;
1+
using Nodify.Interactivity;
2+
using System.Windows;
23
using System.Windows.Controls;
34
using System.Windows.Input;
45

56
namespace Nodify.Calculator
67
{
7-
public partial class EditorView : UserControl
8+
public class OperationsMenuHandler : InputElementState<NodifyEditor>
89
{
9-
public EditorView()
10-
{
11-
InitializeComponent();
10+
private static InputGesture OpenGesture { get; } = new Interactivity.MouseGesture(MouseAction.RightClick);
11+
private static InputGesture CloseGesture { get; } = new Interactivity.MouseGesture(MouseAction.LeftClick);
12+
13+
private OperationsMenuViewModel ViewModel => ((CalculatorViewModel)Element.DataContext).OperationsMenu;
1214

13-
EventManager.RegisterClassHandler(typeof(NodifyEditor), MouseLeftButtonDownEvent, new MouseButtonEventHandler(CloseOperationsMenu), true);
14-
EventManager.RegisterClassHandler(typeof(NodifyEditor), MouseRightButtonUpEvent, new MouseButtonEventHandler(OpenOperationsMenu));
15+
public OperationsMenuHandler(NodifyEditor element) : base(element)
16+
{
1517
}
1618

17-
private void OpenOperationsMenu(object sender, MouseButtonEventArgs e)
19+
protected override void OnMouseUp(MouseButtonEventArgs e)
1820
{
19-
if (e.OriginalSource is NodifyEditor editor && editor.DataContext is CalculatorViewModel calculator)
21+
if (OpenGesture.Matches(e.Source, e))
2022
{
21-
e.Handled = true;
22-
calculator.OperationsMenu.OpenAt(editor.MouseLocation);
23+
ViewModel.OpenAt(Element.MouseLocation);
2324
}
2425
}
2526

26-
private void CloseOperationsMenu(object sender, MouseButtonEventArgs e)
27+
protected override void OnMouseDown(MouseButtonEventArgs e)
2728
{
28-
ItemContainer? itemContainer = sender as ItemContainer;
29-
NodifyEditor? editor = sender as NodifyEditor ?? itemContainer?.Editor;
30-
31-
if (editor?.DataContext is CalculatorViewModel calculator)
29+
if (CloseGesture.Matches(e.Source, e))
3230
{
33-
calculator.OperationsMenu.Close();
31+
ViewModel.Close();
3432
}
3533
}
34+
}
35+
36+
public partial class EditorView : UserControl
37+
{
38+
public EditorView()
39+
{
40+
InitializeComponent();
41+
}
42+
43+
static EditorView()
44+
{
45+
InputProcessor.Shared<NodifyEditor>.RegisterHandlerFactory(editor => new OperationsMenuHandler(editor));
46+
47+
// Ensure the selecting handler is executed after the OperationsMenuHandler, otherwise left click events will not be received.
48+
InputProcessor.Shared<NodifyEditor>.RemoveHandlerFactory<EditorState.Selecting>();
49+
InputProcessor.Shared<NodifyEditor>.RegisterHandlerFactory(editor => new EditorState.Selecting(editor));
50+
}
3651

3752
private void OnDropNode(object sender, DragEventArgs e)
3853
{
39-
if(e.Source is NodifyEditor editor && editor.DataContext is CalculatorViewModel calculator
54+
if (e.Source is NodifyEditor editor && editor.DataContext is CalculatorViewModel calculator
4055
&& e.Data.GetData(typeof(OperationInfoViewModel)) is OperationInfoViewModel operation)
4156
{
4257
OperationViewModel op = OperationFactory.GetOperation(operation);
@@ -49,8 +64,8 @@ private void OnDropNode(object sender, DragEventArgs e)
4964

5065
private void OnNodeDrag(object sender, MouseEventArgs e)
5166
{
52-
if(e.LeftButton == MouseButtonState.Pressed && ((FrameworkElement)sender).DataContext is OperationInfoViewModel operation)
53-
{
67+
if (e.LeftButton == MouseButtonState.Pressed && ((FrameworkElement)sender).DataContext is OperationInfoViewModel operation)
68+
{
5469
var data = new DataObject(typeof(OperationInfoViewModel), operation);
5570
DragDrop.DoDragDrop(this, data, DragDropEffects.Copy);
5671
}

Examples/Nodify.Shapes/Canvas/Gestures/UnboundGestureMappings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public class UnboundGestureMappings : EditorGestures
99
public UnboundGestureMappings()
1010
{
1111
Editor.Selection.Unbind();
12+
Editor.SelectAll.Unbind();
1213
ItemContainer.Selection.Unbind();
1314
Connection.Disconnect.Unbind();
1415
Connector.Connect.Unbind();

Nodify/Connections/CircuitConnection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ protected override void DrawDirectionalArrowsGeometry(StreamGeometryContext cont
8282
var (segment, to) = InterpolateLine(p0, p1, p2, t);
8383

8484
var direction = segment.SegmentStart - segment.SegmentEnd;
85-
base.DrawDirectionalArrowheadGeometry(context, direction, to);
85+
DrawDirectionalArrowheadGeometry(context, direction, to);
8686
}
8787
}
8888

Nodify/Connections/Connection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected override void DrawDirectionalArrowsGeometry(StreamGeometryContext cont
4242
var to = InterpolateCubicBezier(p0, p1, p2, p3, t);
4343
var direction = GetBezierTangent(p0, p1, p2, p3, t);
4444

45-
base.DrawDirectionalArrowheadGeometry(context, direction, to);
45+
DrawDirectionalArrowheadGeometry(context, direction, to);
4646
}
4747
}
4848

Nodify/Connections/ConnectionContainer.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ public event RoutedEventHandler Unselected
7575

7676
private SelectionType? _selectionType;
7777

78+
static ConnectionContainer()
79+
{
80+
FocusableProperty.OverrideMetadata(typeof(ConnectionContainer), new FrameworkPropertyMetadata(BoxValue.True));
81+
}
82+
7883
internal ConnectionContainer(ConnectionsMultiSelector selector)
7984
{
8085
Selector = selector;

Nodify/Connections/ConnectionsMultiSelector.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ private bool CanSelectMultipleItemsBase
4444
set => base.CanSelectMultipleItems = value;
4545
}
4646

47+
/// <summary>
48+
/// Gets the <see cref="NodifyEditor"/> that owns this <see cref="ConnectionsMultiSelector"/>.
49+
/// </summary>
50+
public NodifyEditor? Editor { get; private set; }
51+
4752
protected override DependencyObject GetContainerForItemOverride()
4853
=> new ConnectionContainer(this);
4954

@@ -66,6 +71,15 @@ public void Select(ConnectionContainer container)
6671
#endif
6772

6873
EndUpdateSelectedItems();
74+
75+
Editor?.UnselectAll();
76+
}
77+
78+
public override void OnApplyTemplate()
79+
{
80+
base.OnApplyTemplate();
81+
82+
Editor = this.GetParentOfType<NodifyEditor>();
6983
}
7084

7185
#region Selection Handlers

Nodify/Connections/LineConnection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected override void DrawDirectionalArrowsGeometry(StreamGeometryContext cont
8383
double t = (spacing * i + DirectionalArrowsOffset).WrapToRange(0d, 1d);
8484
var to = InterpolateLineSegment(p0, p1, t);
8585

86-
base.DrawDirectionalArrowheadGeometry(context, direction, to);
86+
DrawDirectionalArrowheadGeometry(context, direction, to);
8787
}
8888
}
8989

Nodify/Connections/StepConnection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ protected override void DrawDirectionalArrowsGeometry(StreamGeometryContext cont
163163
var (segment, to) = InterpolateLine(p0, p1, p2, p3, t);
164164

165165
var direction = segment.SegmentStart - segment.SegmentEnd;
166-
base.DrawDirectionalArrowheadGeometry(context, direction, to);
166+
DrawDirectionalArrowheadGeometry(context, direction, to);
167167
}
168168
}
169169

Nodify/Connectors/Connector.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ static Connector()
172172
public Connector()
173173
{
174174
InputProcessor.AddSharedHandlers(this);
175+
176+
Loaded += OnConnectorLoaded;
177+
Unloaded += OnConnectorUnloaded;
175178
}
176179

177180
/// <inheritdoc />
@@ -181,9 +184,6 @@ public override void OnApplyTemplate()
181184

182185
Container = this.GetParentOfType<ItemContainer>();
183186
Editor = Container?.Editor ?? this.GetParentOfType<NodifyEditor>();
184-
185-
Loaded += OnConnectorLoaded;
186-
Unloaded += OnConnectorUnloaded;
187187
}
188188

189189
#region Update Anchor

0 commit comments

Comments
 (0)