@@ -12,10 +12,10 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
|
||||
}
|
||||
|
||||
public Pipe CreatePipe(INode start, INode end, bool verticalFirst = false) {
|
||||
public Pipe CreatePipe(INode start, INode end, bool verticalFirst = false, string? label = null, double? labelOffsetX = null) {
|
||||
Nodes.Add(start);
|
||||
Nodes.Add(end);
|
||||
var p = new Pipe(start, end, verticalFirst);
|
||||
var p = new Pipe(start, end, label, verticalFirst, default, labelOffsetX);
|
||||
start.Outputs.Add(p);
|
||||
end.Inputs.Add(p);
|
||||
Edges.Add(p);
|
||||
@@ -25,7 +25,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public Pipe CreateTwoWayPipe(INode n1, INode n2, bool verticalFirst = false) {
|
||||
Nodes.Add(n1);
|
||||
Nodes.Add(n2);
|
||||
var p = new Pipe(n1, n2, verticalFirst, twoWay: true);
|
||||
var p = new Pipe(n1, n2, default, verticalFirst, twoWay: true);
|
||||
n1.Inputs.Add(p);
|
||||
n1.Outputs.Add(p);
|
||||
n2.Inputs.Add(p);
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
|
||||
public INode Start { get; }
|
||||
public INode End { get; }
|
||||
public string? Label { get; }
|
||||
public bool IsTwoWay { get; }
|
||||
public bool Orientation { get; }
|
||||
public Brush? Highlight { get; set; }
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public INode Start { get; set; }
|
||||
public INode End => Sink;
|
||||
public ISink Sink { get; set; }
|
||||
public string? Label => null;
|
||||
public bool IsTwoWay => false;
|
||||
public bool Orientation { get; set; }
|
||||
public Brush? Highlight { get; set; }
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public INode Start => Source;
|
||||
public INode End { get; set; }
|
||||
public ISource Source { get; set; }
|
||||
public string? Label => null;
|
||||
public bool IsTwoWay => false;
|
||||
public bool Orientation { get; set; }
|
||||
public Brush? Highlight { get; set; }
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
@@ -7,6 +8,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
|
||||
public INode Start { get; set; }
|
||||
public INode End { get; set; }
|
||||
public string? Label { get; set; }
|
||||
public bool IsTwoWay { get; set; }
|
||||
public bool Orientation { get; set; }
|
||||
public Brush? Highlight { get; set; }
|
||||
@@ -15,11 +17,15 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
|
||||
private Polyline? _outer;
|
||||
private Polyline? _inner;
|
||||
private TextBlock? _text;
|
||||
private FlowArrows? _flowArrows;
|
||||
private double? _textOffsetX;
|
||||
|
||||
public Pipe(INode start, INode end, bool orientation = false, bool twoWay = false) {
|
||||
public Pipe(INode start, INode end, string? label = null, bool orientation = false, bool twoWay = false, double? textOffsetX = null) {
|
||||
Start = start;
|
||||
End = end;
|
||||
Label = label;
|
||||
_textOffsetX = textOffsetX;
|
||||
Orientation = orientation;
|
||||
IsTwoWay = twoWay;
|
||||
}
|
||||
@@ -49,6 +55,20 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
};
|
||||
canvas.Children.Add(_outer);
|
||||
canvas.Children.Add(_inner);
|
||||
if (Label != null) {
|
||||
_text = new() {
|
||||
Text = Label,
|
||||
FontSize = 12,
|
||||
Width = 50,
|
||||
TextAlignment = TextAlignment.Center,
|
||||
VerticalAlignment = VerticalAlignment.Bottom,
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
SnapsToDevicePixels = true,
|
||||
};
|
||||
_text.SetValue(Canvas.LeftProperty, _textOffsetX != null ? (Orientation ? x2 : x1) + _textOffsetX : (Orientation ? (x2 + x3) / 2 : (x1 + x2) / 2) - 25);
|
||||
_text.SetValue(Canvas.TopProperty, y2 - 22);
|
||||
canvas.Children.Add(_text);
|
||||
}
|
||||
_flowArrows = FlowArrows.Create(canvas, _inner);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user