[WIP] Scaling
Test / Run tests (push) Successful in 14s

This commit is contained in:
2026-08-12 16:39:02 +02:00
parent 2dee3a9ae9
commit 31e1347376
22 changed files with 430 additions and 409 deletions
+14 -11
View File
@@ -6,7 +6,7 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class CenterValve : INode {
public const double DIAMETER = 24;
public const double DIAMETER = 4.8;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -33,29 +33,32 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Draw(Canvas canvas) {
_circle = new Ellipse() {
Height = DIAMETER,
Width = DIAMETER,
Fill = Brushes.DarkGray,
Stroke = Brushes.Black,
StrokeThickness = 2,
};
_circle.SetValue(Canvas.LeftProperty, CenterX - DIAMETER / 2);
_circle.SetValue(Canvas.TopProperty, CenterY - DIAMETER / 2);
_text = new() {
Text = Label,
FontSize = 10,
Width = DIAMETER,
Height = DIAMETER,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
SnapsToDevicePixels = true,
};
_text.SetValue(Canvas.LeftProperty, CenterX - DIAMETER / 2 + 0.5);
_text.SetValue(Canvas.TopProperty, CenterY - DIAMETER / 2 + 5.5);
canvas.Children.Add(_circle);
canvas.Children.Add(_text);
}
public void Scale(double scale) {
_circle?.Width = DIAMETER * scale;
_circle?.Height = DIAMETER * scale;
_circle?.StrokeThickness = 2;
_circle?.SetValue(Canvas.LeftProperty, (CenterX - DIAMETER / 2) * scale);
_circle?.SetValue(Canvas.TopProperty, (CenterY - DIAMETER / 2) * scale);
_text?.FontSize = 10;
_text?.Width = DIAMETER * scale;
_text?.Height = DIAMETER * scale;
_text?.SetValue(Canvas.LeftProperty, (CenterX - DIAMETER / 2) * scale + 0.5);
_text?.SetValue(Canvas.TopProperty, (CenterY - DIAMETER / 2) * scale + 5.5);
}
public bool IsInside(double x, double y) {
return Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= DIAMETER / 2;
}
@@ -7,8 +7,8 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class ConveyorBelt : INode {
public const double WIDTH = 30;
public const double HEIGHT = 120;
public const double WIDTH = 6;
public const double HEIGHT = 24;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -47,15 +47,10 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Draw(Canvas canvas) {
_rect = new Rectangle() {
Width = WIDTH,
Height = HEIGHT,
Stroke = Brushes.Black,
StrokeThickness = 2,
Fill = Brushes.WhiteSmoke,
StrokeLineJoin = PenLineJoin.Round,
};
_rect.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
_rect.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2);
var d = 15;
int n = (int)(HEIGHT / d) + 2;
@@ -80,8 +75,8 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
Storyboard.SetTarget(slideUp, _polyline);
Storyboard.SetTargetProperty(slideUp, new PropertyPath(Canvas.TopProperty));
var clipCanvas = new Canvas() {
Width = WIDTH - 15,
Height = HEIGHT - 8,
Width = WIDTH - 3,
Height = HEIGHT - 1.6,
ClipToBounds = true,
};
clipCanvas.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2 + 4);
@@ -92,7 +87,17 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
canvas.Children.Add(clipCanvas);
_storyboard.Begin();
_storyboard.Pause();
}
public void Scale(double scale) {
_rect?.Width = WIDTH * scale;
_rect?.Height = HEIGHT * scale;
_rect?.StrokeThickness = 2;
_rect?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
_rect?.SetValue(Canvas.TopProperty, (CenterY - HEIGHT / 2) * scale);
// TODO clipCanvas
// TODO _polyline
}
public bool IsInside(double x, double y) {
@@ -81,6 +81,10 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
_auger.Draw(canvas);
}
public void Scale(double scale) {
}
public bool IsInside(double x, double y) {
return Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= WIDTH / 2;
}
@@ -98,6 +98,10 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
_auger.Draw(canvas);
}
public void Scale(double scale) {
}
public bool IsInside(double x, double y) {
return Math.Abs(x - CenterX) <= WIDTH / 2 && Math.Abs(y - CenterY) <= HEIGHT / 2;
}
@@ -33,14 +33,6 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
canvas.Children.Add(_layer);
}
public static FlowArrows Create(Canvas canvas, Line first, Line second) {
return new FlowArrows(canvas, [
new Point(first.X1, first.Y1),
new Point(first.X2, first.Y2),
new Point(second.X2, second.Y2),
]);
}
public static FlowArrows Create(Canvas canvas, Polyline path) {
return new FlowArrows(canvas, [.. path.Points]);
}
+14 -3
View File
@@ -102,7 +102,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
}
public void Draw(Canvas canvas) {
public void Draw(Canvas canvas, double scale) {
canvas.Children.Add(new Rectangle() {
Fill = Brushes.White,
Width = 5000,
@@ -110,14 +110,25 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
});
foreach (var e in Edges) {
e.Draw(canvas);
e.Scale(scale);
}
foreach (var n in Nodes) {
n.Draw(canvas);
n.Scale(scale);
}
}
public ISet<INode> GetHover(double x, double y) {
return Nodes.Where(n => n.IsInside(x, y)).ToHashSet();
public void Scale(double scale) {
foreach (var e in Edges) {
e.Scale(scale);
}
foreach (var n in Nodes) {
n.Scale(scale);
}
}
public ISet<INode> GetHover(double x, double y, double scale) {
return Nodes.Where(n => n.IsInside(x / scale, y / scale)).ToHashSet();
}
public void Update(ISet<INode> hovering, bool isPressed) {
@@ -6,8 +6,8 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class HeatExchanger : INode {
public const double WIDTH = 30;
public const double HEIGHT = 120;
public const double WIDTH = 6;
public const double HEIGHT = 24;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -28,29 +28,32 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Draw(Canvas canvas) {
_rect = new Rectangle() {
Width = WIDTH,
Height = HEIGHT,
Stroke = Brushes.Black,
StrokeThickness = 2,
Fill = Brushes.WhiteSmoke,
};
_text = new() {
Text = Label,
FontSize = 12,
Width = HEIGHT,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
RenderTransform = new RotateTransform(270),
SnapsToDevicePixels = true,
};
_rect.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
_rect.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2);
_text.SetValue(Canvas.LeftProperty, CenterX - 9);
_text.SetValue(Canvas.TopProperty, CenterY + HEIGHT / 2);
canvas.Children.Add(_rect);
canvas.Children.Add(_text);
}
public void Scale(double scale) {
_rect?.Width = WIDTH * scale;
_rect?.Height = HEIGHT * scale;
_rect?.StrokeThickness = 2;
_rect?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
_rect?.SetValue(Canvas.TopProperty, (CenterY - HEIGHT / 2) * scale);
_text?.FontSize = 12;
_text?.Width = HEIGHT * scale;
_text?.SetValue(Canvas.LeftProperty, (CenterX * scale) - 9);
_text?.SetValue(Canvas.TopProperty, (CenterY + HEIGHT / 2) * scale);
}
public bool IsInside(double x, double y) {
return Math.Abs(x - CenterX) <= WIDTH / 2 && Math.Abs(y - CenterY) <= HEIGHT / 2;
}
@@ -14,6 +14,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public double FlowLength { get; }
public void Draw(Canvas canvas);
public void Scale(double scale);
public void Update();
}
}
+1 -1
View File
@@ -10,8 +10,8 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public ISet<IEdge> Outputs { get; }
public void Draw(Canvas canvas);
public void Scale(double scale);
public void Update(bool isHovering, bool isPressed);
public bool IsInside(double x, double y);
}
}
+24 -49
View File
@@ -15,10 +15,15 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public (bool TowardEnd, double PathOffset)? Flow { get; set; }
public double FlowLength => _flowArrows?.Length ?? 0;
private Line? _outer1;
private Line? _outer2;
private Line? _inner1;
private Line? _inner2;
public double X1 => Start.CenterX;
public double Y1 => Start.CenterY;
public double X2 => Start.CenterX;
public double Y2 => Orientation ? Sink.CenterY - 2 : Sink.TopY - 2;
public double X3 => Orientation ? Sink.CenterX : Start.CenterX + (Start.CenterX == End.CenterX ? 0 : Start.CenterX > End.CenterX ? -4 : 4);
public double Y3 => Orientation ? Sink.CenterY - 2 : Sink.TopY + 4;
private Polyline? _outer;
private Polyline? _inner;
private FlowArrows? _flowArrows;
public Inlet(INode start, ISink end, bool orientation = false) {
@@ -28,62 +33,32 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
public void Draw(Canvas canvas) {
var x1 = Start.CenterX;
var y1 = Start.CenterY;
var x2 = Start.CenterX;
var y2 = Orientation ? Sink.CenterY - 10 : Sink.TopY - 10;
var x3 = Orientation ? Sink.CenterX : Start.CenterX + (Start.CenterX == End.CenterX ? 0 : Start.CenterX > End.CenterX ? -20 : 20);
var y3 = Orientation ? Sink.CenterY - 10 : Sink.TopY + 20;
_outer1 = new Line() {
X1 = x1,
Y1 = y1,
X2 = x2,
Y2 = y2,
StrokeThickness = 10,
Stroke = Brushes.Black,
StrokeStartLineCap = PenLineCap.Round,
StrokeEndLineCap = PenLineCap.Round,
};
_inner1 = new Line() {
X1 = x1,
Y1 = y1,
X2 = x2,
Y2 = y2,
StrokeThickness = 6,
Stroke = Brushes.DarkGray,
StrokeStartLineCap = PenLineCap.Round,
StrokeEndLineCap = PenLineCap.Round,
};
_outer2 = new Line() {
X1 = x2,
Y1 = y2,
X2 = x3,
Y2 = y3,
StrokeThickness = 10,
_outer = new Polyline() {
Points = [new(X1, Y1), new(X2, Y2), new (X3, Y3)],
Stroke = Brushes.Black,
StrokeStartLineCap = PenLineCap.Round,
StrokeEndLineCap = PenLineCap.Flat,
};
_inner2 = new Line() {
X1 = x2,
Y1 = y2,
X2 = x3,
Y2 = y3,
StrokeThickness = 6,
_inner = new Polyline() {
Points = [new(X1, Y1), new(X2, Y2), new(X3, Y3)],
Stroke = Brushes.DarkGray,
StrokeStartLineCap = PenLineCap.Round,
StrokeEndLineCap = PenLineCap.Flat,
};
canvas.Children.Add(_outer1);
canvas.Children.Add(_outer2);
canvas.Children.Add(_inner1);
canvas.Children.Add(_inner2);
_flowArrows = FlowArrows.Create(canvas, _inner1!, _inner2!);
canvas.Children.Add(_outer);
canvas.Children.Add(_inner);
_flowArrows = FlowArrows.Create(canvas, _inner);
}
public void Scale(double scale) {
_outer?.RenderTransform = new ScaleTransform(scale, scale);
_outer?.StrokeThickness = 10 / scale;
_inner?.RenderTransform = new ScaleTransform(scale, scale);
_inner?.StrokeThickness = 6 / scale;
}
public void Update() {
_inner1?.Stroke = Highlight ?? Brushes.DarkGray;
_inner2?.Stroke = Highlight ?? Brushes.DarkGray;
_inner?.Stroke = Highlight ?? Brushes.DarkGray;
_flowArrows?.Update(Flow);
}
}
+28 -52
View File
@@ -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)],
Points = [new(X1 - POINT, Y1 - 0.4), new(X1 + POINT, Y1 - 0.4), 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() {
Points = [new(X1, Y1), new(X2, Y2), new(X3, Y3)],
Stroke = Brushes.Black,
StrokeStartLineCap = PenLineCap.Round,
StrokeEndLineCap = PenLineCap.Round,
};
_inner1 = new Line() {
X1 = x1,
Y1 = y1,
X2 = x2,
Y2 = y2,
StrokeThickness = 6,
_inner = new Polyline() {
Points = [new(X1, Y1), new(X2, Y2), new(X3, Y3)],
Stroke = Brushes.DarkGray,
StrokeStartLineCap = PenLineCap.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) {
_hopper?.RenderTransform = new ScaleTransform(scale, scale);
_hopper?.StrokeThickness = 2 / scale;
_outer?.RenderTransform = new ScaleTransform(scale, scale);
_outer?.StrokeThickness = 10 / scale;
_inner?.RenderTransform = new ScaleTransform(scale, scale);
_inner?.StrokeThickness = 6 / scale;
}
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);
}
+20 -14
View File
@@ -15,6 +15,13 @@ 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 => Start.CenterY;
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 Polyline? _outer;
private Polyline? _inner;
private TextBlock? _text;
@@ -31,23 +38,15 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
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;
_outer = new Polyline() {
Points = [new(x1, y1), new(x2, y2), new(x3, y3)],
StrokeThickness = 10,
Points = [new(X1, Y1), new(X2, Y2), new(X3, Y3)],
Stroke = Brushes.Black,
StrokeStartLineCap = PenLineCap.Round,
StrokeEndLineCap = PenLineCap.Round,
StrokeLineJoin = PenLineJoin.Round,
};
_inner = new Polyline() {
Points = [new(x1, y1), new(x2, y2), new(x3, y3)],
StrokeThickness = 6,
Points = [new(X1, Y1), new(X2, Y2), new(X3, Y3)],
Stroke = Brushes.DarkGray,
StrokeStartLineCap = PenLineCap.Round,
StrokeEndLineCap = PenLineCap.Round,
@@ -58,20 +57,27 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
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);
}
public void Scale(double scale) {
_outer?.RenderTransform = new ScaleTransform(scale, scale);
_outer?.StrokeThickness = 10 / scale;
_inner?.RenderTransform = new ScaleTransform(scale, scale);
_inner?.StrokeThickness = 6 / scale;
_text?.FontSize = 12;
_text?.Width = 10 * scale;
_text?.SetValue(Canvas.LeftProperty, (_textOffsetX != null ? (Orientation ? X2 : X1) + _textOffsetX : (Orientation ? (X2 + X3) / 2 : (X1 + X2) / 2) - 5) * scale);
_text?.SetValue(Canvas.TopProperty, Y2 * scale - 22);
}
public void Update() {
_inner?.Stroke = Highlight ?? Brushes.DarkGray;
_flowArrows?.Update(Flow);
+9 -5
View File
@@ -6,8 +6,8 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class PipeJoin : INode {
public const double SIZE = 18;
public const double POINT = 4;
public const double SIZE = 3.6;
public const double POINT = 0.8;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -74,13 +74,17 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
Points = [..points],
Fill = Brushes.Black,
Stroke = Brushes.Black,
StrokeThickness = 2,
};
_rect.SetValue(Canvas.LeftProperty, CenterX - SIZE / 2);
_rect.SetValue(Canvas.TopProperty, CenterY - SIZE / 2);
canvas.Children.Add(_rect);
}
public void Scale(double scale) {
_rect?.RenderTransform = new ScaleTransform(scale, scale);
_rect?.StrokeThickness = 2 / scale;
_rect?.SetValue(Canvas.LeftProperty, (CenterX - SIZE / 2) * scale);
_rect?.SetValue(Canvas.TopProperty, (CenterY - SIZE / 2) * scale);
}
public bool IsInside(double x, double y) {
return Math.Abs(x - CenterX) <= SIZE / 2 && Math.Abs(y - CenterY) <= SIZE / 2;
}
+19 -16
View File
@@ -1,13 +1,12 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Media3D;
using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class Press : INode, ISink {
public const double DIAMETER = 120;
public const double DIAMETER = 24;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -40,39 +39,43 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Draw(Canvas canvas) {
_circle = new Ellipse() {
Width = DIAMETER,
Height = DIAMETER,
Stroke = Brushes.Black,
StrokeThickness = 2,
Fill = Brushes.WhiteSmoke,
};
_frame = new Polygon() {
Points = [
new(CenterX - DIAMETER / 2 - 10, CenterY), new(CenterX + DIAMETER / 2 + 10, CenterY),
new(CenterX + DIAMETER / 2 + 10, CenterY + DIAMETER / 2 + 30), new(CenterX + DIAMETER / 2 - 20, CenterY + DIAMETER / 2 + 30),
new(CenterX + DIAMETER / 2 - 20, CenterY + DIAMETER / 2 + 10), new(CenterX - DIAMETER / 2 + 20, CenterY + DIAMETER / 2 + 10),
new(CenterX - DIAMETER / 2 + 20, CenterY + DIAMETER / 2 + 30), new(CenterX - DIAMETER / 2 - 10, CenterY + DIAMETER / 2 + 30)
new(CenterX - DIAMETER / 2 - 2, CenterY), new(CenterX + DIAMETER / 2 + 2, CenterY),
new(CenterX + DIAMETER / 2 + 2, CenterY + DIAMETER / 2 + 6), new(CenterX + DIAMETER / 2 - 4, CenterY + DIAMETER / 2 + 6),
new(CenterX + DIAMETER / 2 - 4, CenterY + DIAMETER / 2 + 2), new(CenterX - DIAMETER / 2 + 4, CenterY + DIAMETER / 2 + 2),
new(CenterX - DIAMETER / 2 + 4, CenterY + DIAMETER / 2 + 6), new(CenterX - DIAMETER / 2 - 2, CenterY + DIAMETER / 2 + 6)
],
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(_frame);
canvas.Children.Add(_circle);
canvas.Children.Add(_text);
}
public void Scale(double scale) {
_circle?.Width = DIAMETER * scale;
_circle?.Height = DIAMETER * scale;
_circle?.StrokeThickness = 2;
_circle?.SetValue(Canvas.LeftProperty, (CenterX - DIAMETER / 2) * scale);
_circle?.SetValue(Canvas.TopProperty, (CenterY - DIAMETER / 2) * scale);
_frame?.RenderTransform = new ScaleTransform(scale, scale);
_frame?.StrokeThickness = 2 / scale;
_text?.FontSize = 14;
_text?.Width = DIAMETER * scale;
_text?.SetValue(Canvas.LeftProperty, (CenterX - DIAMETER / 2) * scale);
_text?.SetValue(Canvas.TopProperty, (CenterY * scale) - (CapacityLiters.HasValue ? 20 : 10));
}
public bool IsInside(double x, double y) {
return Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= DIAMETER / 2 || (Math.Abs(x - CenterX) <= DIAMETER / 2 + 10 && y >= CenterY && y <= CenterY + DIAMETER / 2 + 30);
}
+17 -13
View File
@@ -6,7 +6,7 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class Pump : INode {
public const double DIAMETER = 24;
public const double DIAMETER = 4.8;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -42,35 +42,39 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Draw(Canvas canvas) {
_circle = new Ellipse() {
Height = DIAMETER,
Width = DIAMETER,
Fill = Brushes.WhiteSmoke,
Stroke = Brushes.Black,
StrokeThickness = 2,
};
var dx = Math.Cos(Math.PI / 6) * (DIAMETER / 2 - 2);
var dy = Math.Sin(Math.PI / 6) * (DIAMETER / 2 - 2);
var dx = Math.Cos(Math.PI / 6) * (DIAMETER / 2 - 0.4);
var dy = Math.Sin(Math.PI / 6) * (DIAMETER / 2 - 0.4);
_triangle = new Polygon() {
Points = [new(CenterX - dx, CenterY - dy), new(CenterX + dx, CenterY - dy), new(CenterX, CenterY + DIAMETER / 2 - 2)],
Points = [new(CenterX - dx, CenterY - dy), new(CenterX + dx, CenterY - dy), new(CenterX, CenterY + DIAMETER / 2 - 0.4)],
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 void Scale(double scale) {
_circle?.Width = DIAMETER * scale;
_circle?.Height = DIAMETER * scale;
_circle?.StrokeThickness = 2;
_circle?.SetValue(Canvas.LeftProperty, (CenterX - DIAMETER / 2) * scale);
_circle?.SetValue(Canvas.TopProperty, (CenterY - DIAMETER / 2) * scale);
_triangle?.RenderTransform = new ScaleTransform(scale, scale);
_triangle?.StrokeThickness = 2 / scale;
_text?.FontSize = 14;
_text?.SetValue(Canvas.LeftProperty, (CenterX + DIAMETER / 2) * scale + 2);
_text?.SetValue(Canvas.TopProperty, CenterY * scale - 10);
}
public bool IsInside(double x, double y) {
return Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= DIAMETER / 2;
}
+25 -17
View File
@@ -6,8 +6,8 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class Rebler : INode {
public const double WIDTH = 120;
public const double HEIGHT = 60;
public const double WIDTH = 24;
public const double HEIGHT = 12;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -37,8 +37,6 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Draw(Canvas canvas) {
_rect = new Rectangle() {
Width = WIDTH,
Height = HEIGHT,
Fill = Brushes.WhiteSmoke,
Stroke = Brushes.Black,
StrokeThickness = 2,
@@ -47,36 +45,30 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
var right = CenterX + WIDTH / 2;
var top = CenterY - HEIGHT / 2;
var bottom = CenterY + HEIGHT / 2;
var hx = right - 20;
var h = 15;
var w = 25;
var hx = right - 4;
var h = 3;
var w = 5;
_hopperOuter = new Polygon() {
Points = [new(hx - w, top - h), new(hx - w + 5, top + 2), new(hx + w - 5, top + 2), new(hx + w, top - h)],
Points = [new(hx - w, top - h), new(hx - w + 1, top + 0.4), new(hx + w - 1, top + 0.4), new(hx + w, top - h)],
Fill = Brushes.Black,
};
_hopperInner = new Polygon() {
Points = [new(hx - w + 2, top - h), new(hx - w + 5 + 2, top + 2), new(hx + w - 5 - 2, top + 2), new(hx + w - 2, top - h)],
Points = [new(hx - w + 0.4, top - h), new(hx - w + 1 + 0.4, top + 0.4), new(hx + w - 1 - 0.4, top + 0.4), new(hx + w - 0.4, top - h)],
Fill = Brushes.WhiteSmoke,
};
_bottomOuter = new Polygon() {
Points = [new(left + 20, bottom), new(right - 20, bottom), new(right - 15, bottom + 10), new(left + 15, bottom + 10)],
Points = [new(left + 4, bottom), new(right - 4, bottom), new(right - 3, bottom + 2), new(left + 3, bottom + 2)],
Fill = Brushes.Black,
};
_bottomInner = new Polygon() {
Points = [new(left + 20 + 2, bottom), new(right - 20 - 2, bottom), new(right - 15 - 2, bottom + 10), new(left + 15 + 2, bottom + 10)],
Points = [new(left + 4 + 0.4, bottom), new(right - 4 - 0.4, bottom), new(right - 3 - 0.4, bottom + 2), new(left + 3 + 0.4, bottom + 2)],
Fill = Brushes.WhiteSmoke,
};
_text = new() {
Text = Label,
FontSize = 12,
Width = WIDTH,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
_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);
canvas.Children.Add(_hopperOuter);
canvas.Children.Add(_bottomOuter);
canvas.Children.Add(_rect);
@@ -85,6 +77,22 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
canvas.Children.Add(_text);
}
public void Scale(double scale) {
_rect?.Width = WIDTH * scale;
_rect?.Height = HEIGHT * scale;
_rect?.StrokeThickness = 2;
_rect?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
_rect?.SetValue(Canvas.TopProperty, (CenterY - HEIGHT / 2) * scale);
_hopperOuter?.RenderTransform = new ScaleTransform(scale, scale);
_hopperInner?.RenderTransform = new ScaleTransform(scale, scale);
_bottomOuter?.RenderTransform = new ScaleTransform(scale, scale);
_bottomInner?.RenderTransform = new ScaleTransform(scale, scale);
_text?.FontSize = 12;
_text?.Width = WIDTH * scale;
_text?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
_text?.SetValue(Canvas.TopProperty, (CenterY * scale) - 8);
}
public bool IsInside(double x, double y) {
return Math.Abs(x - CenterX) <= WIDTH / 2 && Math.Abs(y - CenterY) <= HEIGHT / 2;
}
+23 -10
View File
@@ -6,8 +6,8 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class Switcher : INode {
public const double WIDTH = 100;
public const double HEIGHT = 50;
public const double WIDTH = 20;
public const double HEIGHT = 10;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -34,21 +34,15 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
public void Draw(Canvas canvas) {
_mainTransform = new RotateTransform(0, CenterX, CenterY);
_shadowTransform = new RotateTransform(0, CenterX, CenterY);
_mainTransform = new RotateTransform(0);
_shadowTransform = new RotateTransform(0);
_main = new Line() {
X1 = CenterX - WIDTH / 2, Y1 = CenterY,
X2 = CenterX + WIDTH / 2, Y2 = CenterY,
StrokeThickness = 5,
Stroke = Brushes.Black,
StrokeStartLineCap = PenLineCap.Square,
StrokeEndLineCap = PenLineCap.Square,
RenderTransform = _mainTransform,
};
_shadow = new Line() {
X1 = CenterX - WIDTH / 2, Y1 = CenterY,
X2 = CenterX + WIDTH / 2, Y2 = CenterY,
StrokeThickness = 5,
Stroke = Brushes.DarkGray,
StrokeStartLineCap = PenLineCap.Square,
StrokeEndLineCap = PenLineCap.Square,
@@ -58,6 +52,25 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
canvas.Children.Add(_main);
}
public void Scale(double scale) {
_mainTransform?.CenterX = CenterX * scale;
_mainTransform?.CenterY = CenterY * scale;
_shadowTransform?.CenterX = CenterX * scale;
_shadowTransform?.CenterY = CenterY * scale;
_main?.X1 = (CenterX - WIDTH / 2) * scale;
_main?.Y1 = CenterY * scale;
_main?.X2 = (CenterX + WIDTH / 2) * scale;
_main?.Y2 = CenterY * scale;
_main?.StrokeThickness = 1 * scale;
_shadow?.X1 = (CenterX - WIDTH / 2) * scale;
_shadow?.Y1 = CenterY * scale;
_shadow?.X2 = (CenterX + WIDTH / 2) * scale;
_shadow?.Y2 = CenterY * scale;
_shadow?.StrokeThickness = 1 * scale;
}
public bool IsInside(double x, double y) {
return Math.Abs(x - CenterX) <= WIDTH / 2 && Math.Abs(y - CenterY) <= HEIGHT / 2;
}
+14 -11
View File
@@ -6,8 +6,8 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class Tank : INode, ISink, ISource {
public const double WIDTH = 60;
public const double HEIGHT = 100;
public const double WIDTH = 12;
public const double HEIGHT = 20;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -40,27 +40,30 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Draw(Canvas canvas) {
_rect = new Rectangle() {
Width = WIDTH,
Height = HEIGHT,
Stroke = Brushes.Black,
StrokeThickness = 2,
Fill = Brushes.WhiteSmoke,
};
_text = new() {
Text = CapacityLiters.HasValue ? $"{Label}\n{CapacityLiters:N0}" : Label,
FontSize = 12,
Width = WIDTH,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
_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 - (CapacityLiters.HasValue ? 16 : 8));
canvas.Children.Add(_rect);
canvas.Children.Add(_text);
}
public void Scale(double scale) {
_rect?.Height = HEIGHT * scale;
_rect?.Width = WIDTH * scale;
_rect?.StrokeThickness = 2;
_rect?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
_rect?.SetValue(Canvas.TopProperty, (CenterY - HEIGHT / 2) * scale);
_text?.Width = WIDTH * scale;
_text?.FontSize = 12;
_text?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
_text?.SetValue(Canvas.TopProperty, (CenterY * scale) - (CapacityLiters.HasValue ? 16 : 8));
}
public bool IsInside(double x, double y) {
return Math.Abs(x - CenterX) <= WIDTH / 2 && Math.Abs(y - CenterY) <= HEIGHT / 2;
}
+17 -14
View File
@@ -6,8 +6,8 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class Trough : INode, ISource {
public const double WIDTH = 100;
public const double HEIGHT = 60;
public const double WIDTH = 20;
public const double HEIGHT = 12;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -35,33 +35,36 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Draw(Canvas canvas) {
_outer = new Rectangle() {
Width = WIDTH,
Height = HEIGHT,
Fill = Brushes.Black,
};
_inner = new Rectangle() {
Width = WIDTH - 4,
Height = HEIGHT - 2,
Fill = Brushes.WhiteSmoke,
};
_text = new() {
Text = Label,
FontSize = 14,
Width = WIDTH,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
_outer.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
_outer.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2);
_inner.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2 + 2);
_inner.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2);
_text.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
_text.SetValue(Canvas.TopProperty, CenterY - 10);
canvas.Children.Add(_outer);
canvas.Children.Add(_inner);
canvas.Children.Add(_text);
}
public void Scale(double scale) {
_outer?.Width = WIDTH * scale;
_outer?.Height = HEIGHT * scale;
_inner?.Width = WIDTH * scale - 4;
_inner?.Height = HEIGHT * scale - 2;
_text?.Width = WIDTH * scale;
_text?.FontSize = 14;
_outer?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
_outer?.SetValue(Canvas.TopProperty, (CenterY - HEIGHT / 2) * scale);
_inner?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale + 2);
_inner?.SetValue(Canvas.TopProperty, (CenterY - HEIGHT / 2) * scale);
_text?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
_text?.SetValue(Canvas.TopProperty, (CenterY * scale) - 10);
}
public bool IsInside(double x, double y) {
return Math.Abs(x - CenterX) <= WIDTH / 2 && Math.Abs(y - CenterY) <= HEIGHT / 2;
}
+14 -11
View File
@@ -6,7 +6,7 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class Valve : INode {
public const double DIAMETER = 24;
public const double DIAMETER = 4.8;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -40,29 +40,32 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Draw(Canvas canvas) {
_circle = new Ellipse() {
Height = DIAMETER,
Width = DIAMETER,
Fill = Brushes.DarkGray,
Stroke = Brushes.Black,
StrokeThickness = 2,
};
_circle.SetValue(Canvas.LeftProperty, CenterX - DIAMETER / 2);
_circle.SetValue(Canvas.TopProperty, CenterY - DIAMETER / 2);
_text = new() {
Text = Label,
FontSize = 10,
Width = DIAMETER,
Height = DIAMETER,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
SnapsToDevicePixels = true,
};
_text.SetValue(Canvas.LeftProperty, CenterX - DIAMETER / 2 + 0.5);
_text.SetValue(Canvas.TopProperty, CenterY - DIAMETER / 2 + 5.5);
canvas.Children.Add(_circle);
canvas.Children.Add(_text);
}
public void Scale(double scale) {
_circle?.Width = DIAMETER * scale;
_circle?.Height = DIAMETER * scale;
_circle?.StrokeThickness = 2;
_circle?.SetValue(Canvas.LeftProperty, (CenterX - DIAMETER / 2) * scale);
_circle?.SetValue(Canvas.TopProperty, (CenterY - DIAMETER / 2) * scale);
_text?.Width = DIAMETER * scale;
_text?.Height = DIAMETER * scale;
_text?.FontSize = 2 * scale;
_text?.SetValue(Canvas.LeftProperty, (CenterX - DIAMETER / 2 + 0.1) * scale);
_text?.SetValue(Canvas.TopProperty, (CenterY - DIAMETER / 2 + 1.1) * scale);
}
public bool IsInside(double x, double y) {
return Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= DIAMETER / 2;
}