@@ -5,7 +5,7 @@ using System.Windows.Shapes;
|
||||
namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public class Outlet : IEdge {
|
||||
|
||||
public const double POINT = 16;
|
||||
public const double POINT = 3.2;
|
||||
|
||||
public INode Start => Source;
|
||||
public INode End { get; set; }
|
||||
@@ -17,12 +17,17 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public (bool TowardEnd, double PathOffset)? Flow { get; set; }
|
||||
public double FlowLength => _flowArrows?.Length ?? 0;
|
||||
|
||||
public double X1 => Start.CenterX;
|
||||
public double Y1 => Source.BottomY;
|
||||
public double X2 => Orientation ? Start.CenterX : End.CenterX;
|
||||
public double Y2 => Orientation ? End.CenterY : Start.CenterY;
|
||||
public double X3 => End.CenterX;
|
||||
public double Y3 => End.CenterY;
|
||||
|
||||
private Polygon? _hopper;
|
||||
private FlowArrows? _flowArrows;
|
||||
private Line? _outer1;
|
||||
private Line? _outer2;
|
||||
private Line? _inner1;
|
||||
private Line? _inner2;
|
||||
private Polyline? _outer;
|
||||
private Polyline? _inner;
|
||||
|
||||
public Outlet(ISource start, INode end) {
|
||||
Source = start;
|
||||
@@ -31,69 +36,40 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
}
|
||||
|
||||
public void Draw(Canvas canvas) {
|
||||
var x1 = Start.CenterX ;
|
||||
var y1 = Source.BottomY;
|
||||
var x2 = Orientation ? Start.CenterX : End.CenterX;
|
||||
var y2 = Orientation ? End.CenterY : Start.CenterY;
|
||||
var x3 = End.CenterX;
|
||||
var y3 = End.CenterY;
|
||||
_hopper = new Polygon() {
|
||||
Points = [new(x1 - POINT, y1 - 2), new(x1 + POINT, y1 - 2), new(x1, y1 + POINT)],
|
||||
Fill = Brushes.DarkGray,
|
||||
Stroke = Brushes.Black,
|
||||
StrokeThickness = 2,
|
||||
};
|
||||
_outer1 = new Line() {
|
||||
X1 = x1,
|
||||
Y1 = y1,
|
||||
X2 = x2,
|
||||
Y2 = y2,
|
||||
StrokeThickness = 10,
|
||||
_outer = new Polyline() {
|
||||
Stroke = Brushes.Black,
|
||||
StrokeStartLineCap = PenLineCap.Round,
|
||||
StrokeLineJoin = PenLineJoin.Round,
|
||||
StrokeEndLineCap = PenLineCap.Round,
|
||||
};
|
||||
_inner1 = new Line() {
|
||||
X1 = x1,
|
||||
Y1 = y1,
|
||||
X2 = x2,
|
||||
Y2 = y2,
|
||||
StrokeThickness = 6,
|
||||
_inner = new Polyline() {
|
||||
Stroke = Brushes.DarkGray,
|
||||
StrokeStartLineCap = PenLineCap.Round,
|
||||
StrokeLineJoin = PenLineJoin.Round,
|
||||
StrokeEndLineCap = PenLineCap.Round,
|
||||
};
|
||||
_outer2 = new Line() {
|
||||
X1 = x2,
|
||||
Y1 = y2,
|
||||
X2 = x3,
|
||||
Y2 = y3,
|
||||
StrokeThickness = 10,
|
||||
Stroke = Brushes.Black,
|
||||
StrokeStartLineCap = PenLineCap.Round,
|
||||
StrokeEndLineCap = PenLineCap.Round,
|
||||
};
|
||||
_inner2 = new Line() {
|
||||
X1 = x2,
|
||||
Y1 = y2,
|
||||
X2 = x3,
|
||||
Y2 = y3,
|
||||
StrokeThickness = 6,
|
||||
Stroke = Brushes.DarkGray,
|
||||
StrokeStartLineCap = PenLineCap.Round,
|
||||
StrokeEndLineCap = PenLineCap.Round,
|
||||
};
|
||||
canvas.Children.Add(_outer1);
|
||||
canvas.Children.Add(_outer2);
|
||||
canvas.Children.Add(_outer);
|
||||
canvas.Children.Add(_hopper);
|
||||
canvas.Children.Add(_inner1);
|
||||
canvas.Children.Add(_inner2);
|
||||
_flowArrows = FlowArrows.Create(canvas, _inner1!, _inner2!);
|
||||
canvas.Children.Add(_inner);
|
||||
_flowArrows = FlowArrows.Create(canvas, _inner);
|
||||
}
|
||||
|
||||
public void Scale(double scale) {
|
||||
var border = Graph.ToBorder(scale);
|
||||
_hopper?.Points = [Graph.ToPx(X1 - POINT, Y1, scale, dypx: -border * 2), Graph.ToPx(X1 + POINT, Y1, scale, dypx: -border * 2), Graph.ToPx(X1, Y1 + POINT, scale)];
|
||||
_hopper?.StrokeThickness = border;
|
||||
_outer?.Points = [Graph.ToPx(X1, Y1, scale), Graph.ToPx(X2, Y2, scale), Graph.ToPx(X3, Y3, scale)];
|
||||
_inner?.Points = [Graph.ToPx(X1, Y1, scale), Graph.ToPx(X2, Y2, scale), Graph.ToPx(X3, Y3, scale)];
|
||||
_inner?.StrokeThickness = Math.Round(1.2 * scale / 2) * 2;
|
||||
_outer?.StrokeThickness = Math.Round(1.2 * scale / 2) * 2 + border * 2;
|
||||
}
|
||||
|
||||
public void Update() {
|
||||
_inner1?.Stroke = Highlight ?? Brushes.DarkGray;
|
||||
_inner2?.Stroke = Highlight ?? Brushes.DarkGray;
|
||||
_inner?.Stroke = Highlight ?? Brushes.DarkGray;
|
||||
_hopper?.Fill = Highlight ?? Brushes.DarkGray;
|
||||
_flowArrows?.Update(Flow);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user