Skip to content

Commit 3ca8ad1

Browse files
author
YCode
committed
feat: Bezier Vertical Line
1 parent 22e92e2 commit 3ca8ad1

7 files changed

Lines changed: 72 additions & 11 deletions

File tree

YCode.Designer.Demo/Demo/AutoLayout/AutoLayout.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<Grid Background="#1E1E1E">
6060
<ycode:FluxoDesigner x:Name="Designer"
6161
GridType="Dot"
62-
EnableMove="False"
62+
Orientation="Vertical"
6363
Source="{Binding Source}"
6464
ToolTemplate="{StaticResource ToolDataTemplate}"
6565
ItemTemplateSelector="{StaticResource NodeTemplateSelector}"

YCode.Designer.Fluxo/FluxoDesigner.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,16 @@ public FluxoDesigner()
122122
public static readonly DependencyProperty EnableMoveProperty = DependencyProperty.Register(
123123
nameof(EnableMove), typeof(bool), typeof(FluxoDesigner), new PropertyMetadata(true));
124124

125+
public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register(
126+
nameof(Orientation), typeof(FluxoLayoutOrientation), typeof(FluxoDesigner),
127+
new PropertyMetadata(FluxoLayoutOrientation.Horizontal));
128+
129+
public FluxoLayoutOrientation Orientation
130+
{
131+
get => (FluxoLayoutOrientation)GetValue(OrientationProperty);
132+
set => SetValue(OrientationProperty, value);
133+
}
134+
125135
public bool EnableMove
126136
{
127137
get => (bool)GetValue(EnableMoveProperty);

YCode.Designer.Fluxo/Lines/Impl/FluxoBaseLine.cs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,45 @@ namespace YCode.Designer.Fluxo;
22

33
public abstract class FluxoBaseLine(LineType type, FluxoDesigner designer) : IFluxoLineGeometry
44
{
5-
protected readonly FluxoDesigner _designer = designer;
5+
private readonly FluxoDesigner _designer = designer;
6+
67
public LineType Type { get; } = type;
78

8-
public FluxoLineParameter Parameter { get; set; } = default!;
9+
protected FluxoLineParameter Parameter { get; set; } = default!;
910
protected List<Point> Points { get; } = [];
1011

1112
public virtual void DrawLine(FluxoLineParameter @params, StreamGeometryContext context)
1213
{
13-
//TODO: 算法策略
14+
this.Points.Clear();
1415

1516
this.Parameter = @params;
1617

17-
this.Points.Clear();
18-
19-
this.OnHorizontal();
18+
switch (_designer.Orientation)
19+
{
20+
case FluxoLayoutOrientation.Cross:
21+
{
22+
this.OnCross();
23+
}
24+
break;
25+
case FluxoLayoutOrientation.Vertical:
26+
{
27+
this.OnVertical();
28+
}
29+
break;
30+
case FluxoLayoutOrientation.Horizontal:
31+
default:
32+
{
33+
this.OnHorizontal();
34+
}
35+
break;
36+
}
2037
}
2138

2239
protected abstract void OnHorizontal();
2340

2441
protected abstract void OnVertical();
2542

26-
protected abstract void OnQuartet();
43+
protected abstract void OnCross();
2744

2845
public abstract Point GetPoint(double target);
2946

YCode.Designer.Fluxo/Lines/Impl/FluxoBezierLine.cs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,35 @@ protected override void OnHorizontal()
4848

4949
protected override void OnVertical()
5050
{
51-
throw new NotImplementedException();
51+
this.Parameter.Start = this.Parameter.Source.Top;
52+
53+
this.Parameter.End = this.Parameter.Target.Top;
54+
55+
var p1 = new Point(this.Parameter.Start.X, this.Parameter.Start.Y - 30);
56+
57+
var p2 = new Point(this.Parameter.End.X, this.Parameter.End.Y - 30);
58+
59+
if (this.Parameter.Source.Bottom.Y < this.Parameter.Target.Top.Y)
60+
{
61+
this.Parameter.Start = this.Parameter.Source.Bottom;
62+
63+
p1.Y = this.Parameter.Start.Y + 30;
64+
65+
p2.Y -= 30;
66+
}
67+
else if (this.Parameter.Target.Bottom.Y < this.Parameter.Source.Top.Y)
68+
{
69+
this.Parameter.End = this.Parameter.Target.Bottom;
70+
71+
p2.Y = this.Parameter.End.Y + 30;
72+
73+
p1.Y -= 30;
74+
}
75+
76+
this.Points.AddRange([this.Parameter.Start, p1, p2, this.Parameter.End]);
5277
}
5378

54-
protected override void OnQuartet()
79+
protected override void OnCross()
5580
{
5681
throw new NotImplementedException();
5782
}

YCode.Designer.Fluxo/Lines/Impl/FluxoStraightLine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ protected override void OnVertical()
3838
throw new NotImplementedException();
3939
}
4040

41-
protected override void OnQuartet()
41+
protected override void OnCross()
4242
{
4343
throw new NotImplementedException();
4444
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace YCode.Designer.Fluxo;
2+
3+
public enum FluxoLayoutOrientation
4+
{
5+
Horizontal,
6+
Vertical,
7+
Cross
8+
}

YCode.Designer.Fluxo/YCode.Designer.Fluxo.csproj.DotSettings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=gestures/@EntryIndexedValue">True</s:Boolean>
44
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=helpers/@EntryIndexedValue">True</s:Boolean>
55
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=lines/@EntryIndexedValue">True</s:Boolean>
6+
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=lines_005Cimpl/@EntryIndexedValue">True</s:Boolean>
67
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=models/@EntryIndexedValue">True</s:Boolean>
78
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=state/@EntryIndexedValue">True</s:Boolean>
89
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=viewmodels/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

0 commit comments

Comments
 (0)