73 lines
2.5 KiB
C#
73 lines
2.5 KiB
C#
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Media;
|
|
using System.Windows.Shapes;
|
|
|
|
namespace PamhagenSysCtrl.Helpers.Pipeline {
|
|
public class Pipe : IEdge {
|
|
|
|
public INode Start { get; set; }
|
|
public INode End { get; set; }
|
|
public bool Orientation { get; set; }
|
|
public bool Highlight { get; set; }
|
|
|
|
private Line? _outer1;
|
|
private Line? _outer2;
|
|
private Line? _inner1;
|
|
private Line? _inner2;
|
|
|
|
public Pipe(INode start, INode end, bool orientation = false) {
|
|
Start = start;
|
|
End = end;
|
|
Orientation = orientation;
|
|
}
|
|
|
|
public void Draw(Canvas canvas) {
|
|
var x1 = Start.CenterX;
|
|
var y1 = Start.CenterY;
|
|
var x2 = Orientation ? Start.CenterX : End.CenterX;
|
|
var y2 = Orientation ? End.CenterY : Start.CenterY;
|
|
var x3 = End.CenterX;
|
|
var y3 = End.CenterY;
|
|
_outer1 = new Line() {
|
|
X1 = x1, Y1 = y1, X2 = x2, Y2 = y2,
|
|
StrokeThickness = 10,
|
|
Stroke = Brushes.Black,
|
|
StrokeStartLineCap = PenLineCap.Square,
|
|
StrokeEndLineCap = PenLineCap.Square,
|
|
};
|
|
_inner1 = new Line() {
|
|
X1 = x1, Y1 = y1, X2 = x2, Y2 = y2,
|
|
StrokeThickness = 6,
|
|
Stroke = Brushes.DarkGray,
|
|
StrokeStartLineCap = PenLineCap.Square,
|
|
StrokeEndLineCap = PenLineCap.Square,
|
|
};
|
|
_outer2 = new Line() {
|
|
X1 = x2, Y1 = y2, X2 = x3, Y2 = y3,
|
|
StrokeThickness = 10,
|
|
Stroke = Brushes.Black,
|
|
StrokeStartLineCap = PenLineCap.Square,
|
|
StrokeEndLineCap = PenLineCap.Square,
|
|
};
|
|
_inner2 = new Line() {
|
|
X1 = x2, Y1 = y2, X2 = x3, Y2 = y3,
|
|
StrokeThickness = 6,
|
|
Stroke = Brushes.DarkGray,
|
|
StrokeStartLineCap = PenLineCap.Square,
|
|
StrokeEndLineCap = PenLineCap.Square,
|
|
};
|
|
canvas.Children.Add(_outer1);
|
|
canvas.Children.Add(_outer2);
|
|
canvas.Children.Add(_inner1);
|
|
canvas.Children.Add(_inner2);
|
|
}
|
|
|
|
public bool Update(double x, double y) {
|
|
_inner1?.Stroke = Highlight ? Brushes.Green: Brushes.DarkGray;
|
|
_inner2?.Stroke = Highlight ? Brushes.Green : Brushes.DarkGray;
|
|
return false;
|
|
}
|
|
}
|
|
}
|