diff --git a/CHANGELOG.md b/CHANGELOG.md index 2203ffc5..4ea19da2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ > - Breaking Changes: > - Features: +> - Added OutlineBrush and OutlineThickness dependency properties to BaseConnection to support increasing the selection area without increasing the stroke thickness > - Bugfixes: #### **Version 6.3.0** diff --git a/Examples/Nodify.Playground/Editor/NodifyEditorView.xaml b/Examples/Nodify.Playground/Editor/NodifyEditorView.xaml index 4219332b..05260d5b 100644 --- a/Examples/Nodify.Playground/Editor/NodifyEditorView.xaml +++ b/Examples/Nodify.Playground/Editor/NodifyEditorView.xaml @@ -43,45 +43,76 @@ Transform="{Binding ViewportTransform, ElementName=Editor}" Drawing="{StaticResource LargeGridGeometry}" /> - - - - + + + + + + - + Storyboard.TargetProperty="(UIElement.Opacity)" + Duration="0:0:0.3" + From="1" + To="0.3" /> + @@ -358,7 +373,8 @@ - + /// Gets or sets the start point of this connection. /// @@ -291,6 +298,24 @@ public ICommand? DisconnectCommand set => SetValue(DisconnectCommandProperty, value); } + /// + /// The thickness of the outline. + /// + public double OutlineThickness + { + get => (double)GetValue(OutlineThicknessProperty); + set => SetValue(OutlineThicknessProperty, value); + } + + /// + /// The brush used to render the outline. + /// + public Brush? OutlineBrush + { + get => (Brush?)GetValue(OutlineBrushProperty); + set => SetValue(OutlineBrushProperty, value); + } + /// /// The brush used to render the . /// @@ -373,6 +398,8 @@ public event ConnectionEventHandler Split /// protected static readonly Vector ZeroVector = new Vector(0d, 0d); + private Pen? _outlinePen; + private readonly StreamGeometry _geometry = new StreamGeometry { FillRule = FillRule.EvenOdd @@ -734,8 +761,18 @@ protected override void OnMouseUp(MouseButtonEventArgs e) } } + private Pen GetOutlinePen() + { + return _outlinePen ??= new Pen(OutlineBrush, StrokeThickness + OutlineThickness * 2d); + } + protected override void OnRender(DrawingContext drawingContext) { + if (OutlineBrush != null) + { + drawingContext.DrawGeometry(OutlineBrush, GetOutlinePen(), DefiningGeometry); + } + base.OnRender(drawingContext); if (!string.IsNullOrEmpty(Text)) diff --git a/Nodify/Helpers/BoxValue.cs b/Nodify/Helpers/BoxValue.cs index 0c9e5f7f..42c30fdd 100644 --- a/Nodify/Helpers/BoxValue.cs +++ b/Nodify/Helpers/BoxValue.cs @@ -13,6 +13,7 @@ public static class BoxValue public static readonly object Double0 = 0d; public static readonly object Double1 = 1d; public static readonly object Double2 = 2d; + public static readonly object Double5 = 5d; public static readonly object Double45 = 45d; public static readonly object Double1000 = 1000d; public static readonly object Int0 = 0;