Add press 1 and 2

This commit is contained in:
2026-07-13 23:43:05 +02:00
parent 74ec9527da
commit 0967249a22
9 changed files with 200 additions and 60 deletions
@@ -2,5 +2,6 @@
public interface ISink : INode {
public double TopY { get; }
public bool IsFull { get; }
public int? CapacityLiters { get; }
}
}
+2 -2
View File
@@ -28,8 +28,8 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
var y1 = Start.CenterY;
var x2 = Start.CenterX;
var y2 = Sink.TopY - 10;
var x3 = Start.CenterX + (Orientation ? -10 : 10);
var y3 = Sink.TopY + 10;
var x3 = Start.CenterX + (Orientation ? -20 : 20);
var y3 = Sink.TopY + 20;
_outer1 = new Line() {
X1 = x1,
Y1 = y1,
+2 -2
View File
@@ -46,7 +46,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
Y2 = y2,
StrokeThickness = 10,
Stroke = Brushes.Black,
StrokeStartLineCap = PenLineCap.Round,
StrokeStartLineCap = PenLineCap.Flat,
StrokeEndLineCap = PenLineCap.Round,
};
_inner1 = new Line() {
@@ -56,7 +56,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
Y2 = y2,
StrokeThickness = 6,
Stroke = Brushes.DarkGray,
StrokeStartLineCap = PenLineCap.Round,
StrokeStartLineCap = PenLineCap.Flat,
StrokeEndLineCap = PenLineCap.Round,
};
_outer2 = new Line() {
+68
View File
@@ -0,0 +1,68 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class Press : INode, ISink {
public const double DIAMETER = 120;
public double CenterX { get; set; }
public double CenterY { get; set; }
public string Label { get; set; }
public ISet<IEdge> Inputs { get; set; }
public ISet<IEdge> Outputs { get; set; }
protected Func<bool> CallbackIsFull;
public double TopY => CenterY - DIAMETER / 2;
public bool IsFull => CallbackIsFull();
public int? CapacityLiters { get; set; }
private Shape? _circle;
private TextBlock? _text;
public Press(string label, double x, double y, int capacityLiters, Func<bool> cbFull) {
CenterX = x;
CenterY = y;
Label = label;
CapacityLiters = capacityLiters;
CallbackIsFull = cbFull;
Inputs = new HashSet<IEdge>();
Outputs = new HashSet<IEdge>();
}
public void Draw(Canvas canvas) {
_circle = new Ellipse() {
Width = DIAMETER,
Height = DIAMETER,
Stroke = Brushes.Black,
StrokeThickness = 2,
Fill = Brushes.WhiteSmoke,
};
_text = new() {
Text = CapacityLiters.HasValue ? $"{Label}\n{CapacityLiters:N0}" : Label,
FontSize = 14,
Width = DIAMETER,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
_circle.SetValue(Canvas.LeftProperty, CenterX - DIAMETER / 2);
_circle.SetValue(Canvas.TopProperty, CenterY - DIAMETER / 2);
_text.SetValue(Canvas.LeftProperty, CenterX - DIAMETER / 2);
_text.SetValue(Canvas.TopProperty, CenterY - (CapacityLiters.HasValue ? 20 : 10));
canvas.Children.Add(_circle);
canvas.Children.Add(_text);
}
public bool Update(double x, double y) {
var hover = Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= DIAMETER / 2;
_circle?.Fill = hover ? Brushes.LightGray : Brushes.WhiteSmoke;
return hover;
}
}
}
+29 -7
View File
@@ -1,11 +1,12 @@
using System.Windows.Controls;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class Pump : INode {
public const double RADIUS = 24;
public const double DIAMETER = 24;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -15,6 +16,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public ISet<IEdge> Outputs { get; init; }
private Shape? _circle;
private Shape? _triangle;
private TextBlock? _text;
public Pump(string label, double x, double y) {
@@ -27,19 +29,39 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Draw(Canvas canvas) {
_circle = new Ellipse() {
Height = RADIUS,
Width = RADIUS,
Height = DIAMETER,
Width = DIAMETER,
Fill = Brushes.WhiteSmoke,
Stroke = Brushes.Black,
StrokeThickness = 2,
};
_circle.SetValue(Canvas.LeftProperty, CenterX - RADIUS / 2);
_circle.SetValue(Canvas.TopProperty, CenterY - RADIUS / 2);
var dx = Math.Cos(Math.PI / 6) * (DIAMETER / 2 - 2);
var dy = Math.Sin(Math.PI / 6) * (DIAMETER / 2 - 2);
_triangle = new Polygon() {
Points = [new(CenterX - dx, CenterY - dy), new(CenterX + dx, CenterY - dy), new(CenterX, CenterY + DIAMETER / 2 - 2)],
Fill = Brushes.Transparent,
Stroke = Brushes.Black,
StrokeThickness = 2,
};
_text = new() {
Text = Label,
FontSize = 14,
TextAlignment = TextAlignment.Left,
VerticalAlignment = VerticalAlignment.Center,
};
_circle.SetValue(Canvas.LeftProperty, CenterX - DIAMETER / 2);
_circle.SetValue(Canvas.TopProperty, CenterY - DIAMETER / 2);
_text.SetValue(Canvas.LeftProperty, CenterX + DIAMETER / 2 + 2);
_text.SetValue(Canvas.TopProperty, CenterY - 10);
canvas.Children.Add(_circle);
canvas.Children.Add(_triangle);
canvas.Children.Add(_text);
}
public bool Update(double x, double y) {
return false;
var hover = Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= DIAMETER / 2;
_circle?.Fill = hover ? Brushes.LightGray : Brushes.WhiteSmoke;
return hover;
}
}
}
+6 -3
View File
@@ -20,16 +20,19 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public ISet<IEdge> Inputs { get; init; }
public ISet<IEdge> Outputs { get; init; }
public int? CapacityLiters { get; set; }
protected Func<bool> CallbackIsFilled;
protected Func<bool> CallbackIsFull;
private Shape? _rect;
private TextBlock? _text;
public Tank(string label, double x, double y, Func<bool> cbFilled, Func<bool> cbFull) {
public Tank(string label, double x, double y, int capacityLiters, Func<bool> cbFilled, Func<bool> cbFull) {
CenterX = x;
CenterY = y;
Label = label;
CapacityLiters = capacityLiters;
CallbackIsFilled = cbFilled;
CallbackIsFull = cbFull;
Inputs = new HashSet<IEdge>();
@@ -45,7 +48,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
Fill = Brushes.WhiteSmoke,
};
_text = new() {
Text = Label,
Text = CapacityLiters.HasValue ? $"{Label}\n{CapacityLiters:N0}" : Label,
FontSize = 12,
Width = WIDTH,
TextAlignment = TextAlignment.Center,
@@ -54,7 +57,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
_rect.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
_rect.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2);
_text.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
_text.SetValue(Canvas.TopProperty, CenterY - 8);
_text.SetValue(Canvas.TopProperty, CenterY - (CapacityLiters.HasValue ? 16 : 8));
canvas.Children.Add(_rect);
canvas.Children.Add(_text);
}
+10 -10
View File
@@ -6,7 +6,7 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class Valve : INode {
public const double RADIUS = 24;
public const double DIAMETER = 24;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -35,30 +35,30 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Draw(Canvas canvas) {
_circle = new Ellipse() {
Height = RADIUS,
Width = RADIUS,
Height = DIAMETER,
Width = DIAMETER,
Fill = Brushes.DarkGray,
Stroke = Brushes.Black,
StrokeThickness = 2,
};
_circle.SetValue(Canvas.LeftProperty, CenterX - RADIUS / 2);
_circle.SetValue(Canvas.TopProperty, CenterY - RADIUS / 2);
_circle.SetValue(Canvas.LeftProperty, CenterX - DIAMETER / 2);
_circle.SetValue(Canvas.TopProperty, CenterY - DIAMETER / 2);
_text = new() {
Text = Label,
FontSize = 10,
Width = RADIUS,
Height = RADIUS,
Width = DIAMETER,
Height = DIAMETER,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
_text.SetValue(Canvas.LeftProperty, CenterX - RADIUS / 2);
_text.SetValue(Canvas.TopProperty, CenterY - RADIUS / 2 + 5);
_text.SetValue(Canvas.LeftProperty, CenterX - DIAMETER / 2);
_text.SetValue(Canvas.TopProperty, CenterY - DIAMETER / 2 + 5);
canvas.Children.Add(_circle);
canvas.Children.Add(_text);
}
public bool Update(double x, double y) {
var hover = Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= RADIUS / 2;
var hover = Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= DIAMETER / 2;
_circle?.Fill = hover ? Brushes.LightGray : Brushes.DarkGray;
return hover;
}