Skip to content

Commit

Permalink
Merge conflicts fix
Browse files Browse the repository at this point in the history
  • Loading branch information
BAndysc committed Jun 23, 2024
1 parent 3747f05 commit 674e0d3
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Examples/Nodify.Playground/Editor/NodifyEditorView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
</DataTemplate>

<DataTemplate x:Key="StepConnectionTemplate">
<nodify:StepConnection Style="{StaticResource ConnectionStyle}"
<nodify:StepConnection Theme="{StaticResource ConnectionStyle}"
SourcePosition="{Binding ., Converter={StaticResource FlowToConnectorPositionConverter}, ConverterParameter=Output}"
TargetPosition="{Binding ., Converter={StaticResource FlowToConnectorPositionConverter}, ConverterParameter=Input}" />
</DataTemplate>
Expand Down
10 changes: 5 additions & 5 deletions Nodify/Connections/LineConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ protected static Point InterpolateLineSegment(Point p0, Point p1, double t)

protected static ((Point SegmentStart, Point SegmentEnd), Point InterpolatedPoint) InterpolateLine(Point p0, Point p1, Point p2, Point p3, double t)
{
double length1 = (p1 - p0).Length;
double length2 = (p2 - p1).Length;
double length3 = (p3 - p2).Length;
double length1 = (p1 - p0).Length();
double length2 = (p2 - p1).Length();
double length3 = (p3 - p2).Length();
double totalLength = length1 + length2 + length3;

double ratio1 = length1 / totalLength;
Expand All @@ -110,8 +110,8 @@ protected static ((Point SegmentStart, Point SegmentEnd), Point InterpolatedPoin

protected static ((Point SegmentStart, Point SegmentEnd), Point InterpolatedPoint) InterpolateLine(Point p0, Point p1, Point p2, double t)
{
double length1 = (p1 - p0).Length;
double length2 = (p2 - p1).Length;
double length1 = (p1 - p0).Length();
double length2 = (p2 - p1).Length();
double totalLength = length1 + length2;

double ratio1 = length1 / totalLength;
Expand Down
21 changes: 12 additions & 9 deletions Nodify/Connections/StepConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public enum ConnectorPosition

public class StepConnection : LineConnection
{
public static readonly DependencyProperty SourcePositionProperty = DependencyProperty.Register(nameof(SourcePosition), typeof(ConnectorPosition), typeof(StepConnection), new FrameworkPropertyMetadata(ConnectorPosition.Right, FrameworkPropertyMetadataOptions.AffectsRender, OnConnectorPositionChanged));
public static readonly DependencyProperty TargetPositionProperty = DependencyProperty.Register(nameof(TargetPosition), typeof(ConnectorPosition), typeof(StepConnection), new FrameworkPropertyMetadata(ConnectorPosition.Left, FrameworkPropertyMetadataOptions.AffectsRender, OnConnectorPositionChanged));
public static readonly AvaloniaProperty<ConnectorPosition> SourcePositionProperty = AvaloniaProperty.Register<StepConnection, ConnectorPosition>(nameof(SourcePosition), ConnectorPosition.Right);
public static readonly AvaloniaProperty<ConnectorPosition> TargetPositionProperty = AvaloniaProperty.Register<StepConnection, ConnectorPosition>(nameof(TargetPosition), ConnectorPosition.Left);

private static void OnConnectorPositionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
Expand All @@ -28,28 +28,31 @@ private static void OnConnectorPositionChanged(DependencyObject d, DependencyPro

static StepConnection()
{
SourceOrientationProperty.OverrideMetadata(typeof(StepConnection), new FrameworkPropertyMetadata(Orientation.Horizontal, null, CoerceSourceOrientation));
TargetOrientationProperty.OverrideMetadata(typeof(StepConnection), new FrameworkPropertyMetadata(Orientation.Horizontal, null, CoerceTargetOrientation));
DirectionProperty.OverrideMetadata(typeof(StepConnection), new FrameworkPropertyMetadata(ConnectionDirection.Forward, null, CoerceConnectionDirection));
SourcePositionProperty.Changed.AddClassHandler<StepConnection>(OnConnectorPositionChanged);
TargetPositionProperty.Changed.AddClassHandler<StepConnection>(OnConnectorPositionChanged);
AffectsRender<StepConnection>(SourcePositionProperty, TargetPositionProperty);
SourceOrientationProperty.OverrideMetadata<StepConnection>(new StyledPropertyMetadata<Orientation>(defaultValue: Orientation.Horizontal, coerce: CoerceSourceOrientation));
TargetOrientationProperty.OverrideMetadata<StepConnection>(new StyledPropertyMetadata<Orientation>(defaultValue: Orientation.Horizontal, coerce: CoerceTargetOrientation));
DirectionProperty.OverrideMetadata<StepConnection>(new StyledPropertyMetadata<ConnectionDirection>(defaultValue: ConnectionDirection.Forward, coerce: CoerceConnectionDirection));
}

private static object CoerceSourceOrientation(DependencyObject d, object baseValue)
private static Orientation CoerceSourceOrientation(DependencyObject d, Orientation baseValue)
{
var connection = (StepConnection)d;
return connection.SourcePosition == ConnectorPosition.Left || connection.SourcePosition == ConnectorPosition.Right
? Orientation.Horizontal
: Orientation.Vertical;
}

private static object CoerceTargetOrientation(DependencyObject d, object baseValue)
private static Orientation CoerceTargetOrientation(DependencyObject d, Orientation baseValue)
{
var connection = (StepConnection)d;
return connection.TargetPosition == ConnectorPosition.Left || connection.TargetPosition == ConnectorPosition.Right
? Orientation.Horizontal
: Orientation.Vertical;
}

private static object CoerceConnectionDirection(DependencyObject d, object baseValue)
private static ConnectionDirection CoerceConnectionDirection(DependencyObject d, ConnectionDirection baseValue)
{
var connection = (StepConnection)d;
return connection.TargetPosition == ConnectorPosition.Left || connection.TargetPosition == ConnectorPosition.Top
Expand Down Expand Up @@ -116,7 +119,7 @@ protected override Point GetTextPosition(FormattedText text, Point source, Point
return new Point((p3.X + p2.X - text.Width) / 2, (p3.Y + p2.Y - text.Height) / 2);

static Vector GetMax(in Vector a, in Vector b)
=> a.LengthSquared > b.LengthSquared ? a : b;
=> a.SquaredLength > b.SquaredLength ? a : b;
}

protected override void DrawDirectionalArrowsGeometry(StreamGeometryContext context, Point source, Point target)
Expand Down
1 change: 0 additions & 1 deletion Nodify/Themes/Brushes.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@
<!--STEP CONNECTION-->

<SolidColorBrush x:Key="StepConnection.StrokeBrush"
o:Freeze="True"
Color="{DynamicResource StepConnection.StrokeColor}" />

<!--PENDING CONNECTION-->
Expand Down
6 changes: 3 additions & 3 deletions Nodify/Themes/Controls.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@

<!--STEP CONNECTION-->

<Style TargetType="{x:Type local:StepConnection}"
BasedOn="{StaticResource {x:Type local:StepConnection}}">
<ControlTheme TargetType="{x:Type local:StepConnection}" x:Key="{x:Type local:StepConnection}"
BasedOn="{StaticResource {x:Type local:StepConnection}}">
<Setter Property="Stroke"
Value="{StaticResource StepConnection.StrokeBrush}" />
<Setter Property="Fill"
Value="{StaticResource StepConnection.StrokeBrush}" />
</Style>
</ControlTheme>

<!--PENDING CONNECTION-->

Expand Down
4 changes: 2 additions & 2 deletions Nodify/Themes/Styles/Connection.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
Value="30" />
</ControlTheme>

<Style TargetType="{x:Type local:StepConnection}">
<ControlTheme TargetType="{x:Type local:StepConnection}" x:Key="{x:Type local:StepConnection}">
<Setter Property="StrokeThickness"
Value="3" />
<Setter Property="Stroke"
Expand All @@ -44,6 +44,6 @@
Value="DodgerBlue" />
<Setter Property="Spacing"
Value="30" />
</Style>
</ControlTheme>

</ResourceDictionary>
2 changes: 0 additions & 2 deletions Nodify/Themes/Styles/DecoratorContainer.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Nodify">

<local:UnscaleTransformConverter x:Key="UnscaleTransformConverter" />

<ControlTheme TargetType="{x:Type local:DecoratorContainer}" x:Key="{x:Type local:DecoratorContainer}">
<Setter Property="KeyboardNavigation.IsTabStop"
Value="False" />
Expand Down
2 changes: 1 addition & 1 deletion Nodify/Themes/Styles/NodifyEditor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<local:UnscaleDoubleConverter x:Key="UnscaleDoubleConverter" />

<DataTemplate x:Key="ConnectionTemplate">
<local:Connection Style="{DynamicResource {x:Type local:Connection}}" />
<local:Connection Theme="{DynamicResource {x:Type local:Connection}}" />
</DataTemplate>

<DataTemplate x:Key="PendingConnectionTemplate">
Expand Down

0 comments on commit 674e0d3

Please sign in to comment.