@@ -14,17 +14,21 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public double Angle { get; set; }
|
||||
|
||||
public bool IsAnimationActive {
|
||||
get => !(_storyboard?.GetIsPaused() ?? true);
|
||||
set {
|
||||
if (value) {
|
||||
_storyboard?.Resume();
|
||||
} else {
|
||||
_storyboard?.Pause();
|
||||
if (_storyboard == null) return;
|
||||
if (value && _storyboard.GetIsPaused()) {
|
||||
_storyboard.Resume();
|
||||
} else if (!value && !_storyboard.GetIsPaused()) {
|
||||
_storyboard.Pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Polyline? _polyline;
|
||||
private Storyboard? _storyboard;
|
||||
private DoubleAnimation? _leftSlide;
|
||||
private Canvas? _clipCanvas;
|
||||
|
||||
public Auger(double x, double y, double width, double height, double angle = 0) {
|
||||
CenterX = x;
|
||||
@@ -35,41 +39,45 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
}
|
||||
|
||||
public void Draw(Canvas canvas) {
|
||||
var d = Height / 4;
|
||||
int n = (int)(Width / d / 4) + 2;
|
||||
_polyline = new Polyline() {
|
||||
Points = [.. Enumerable.Range(0, n).SelectMany(i => new List<Point>() {
|
||||
new(i * 4 * d, Height / 2), new((i * 4 + 1) * d, 0),
|
||||
new((i * 4 + 2) * d, Height / 2), new((i * 4 + 3) * d, Height)
|
||||
}), new(n * 4 * d, Height / 2), new(0, Height / 2)],
|
||||
Fill = Brushes.Transparent,
|
||||
Stroke = Brushes.Black,
|
||||
StrokeThickness = 2,
|
||||
};
|
||||
_polyline.SetValue(Canvas.LeftProperty, 0.0);
|
||||
|
||||
var slideLeft = new DoubleAnimation {
|
||||
_leftSlide = new DoubleAnimation {
|
||||
From = 0,
|
||||
To = -d * 4,
|
||||
Duration = new Duration(TimeSpan.FromSeconds(1)),
|
||||
RepeatBehavior = RepeatBehavior.Forever,
|
||||
};
|
||||
_storyboard = new Storyboard();
|
||||
_storyboard.Children.Add(slideLeft);
|
||||
Storyboard.SetTarget(slideLeft, _polyline);
|
||||
Storyboard.SetTargetProperty(slideLeft, new PropertyPath(Canvas.LeftProperty));
|
||||
var clipCanvas = new Canvas() {
|
||||
Width = Width,
|
||||
Height = Height,
|
||||
_storyboard.Children.Add(_leftSlide);
|
||||
Storyboard.SetTarget(_leftSlide, _polyline);
|
||||
Storyboard.SetTargetProperty(_leftSlide, new PropertyPath(Canvas.LeftProperty));
|
||||
_clipCanvas = new Canvas() {
|
||||
ClipToBounds = true,
|
||||
RenderTransform = new RotateTransform(Angle, Width / 2, Height / 2),
|
||||
};
|
||||
clipCanvas.SetValue(Canvas.TopProperty, CenterY - Height / 2);
|
||||
clipCanvas.SetValue(Canvas.LeftProperty, CenterX - Width / 2);
|
||||
clipCanvas.Children.Add(_polyline);
|
||||
canvas.Children.Add(clipCanvas);
|
||||
_clipCanvas.Children.Add(_polyline);
|
||||
canvas.Children.Add(_clipCanvas);
|
||||
_storyboard.Begin();
|
||||
_storyboard.Pause();
|
||||
}
|
||||
|
||||
public void Scale(double scale) {
|
||||
var border = Graph.ToBorder(scale);
|
||||
var d = Height / 4 * scale;
|
||||
int n = (int)(Width * scale / d / 4) + 2;
|
||||
_polyline?.Points = [.. Enumerable.Range(0, n).SelectMany(i => new List<Point>() {
|
||||
new(i * 4 * d, Height / 2 * scale), new((i * 4 + 1) * d, 0),
|
||||
new((i * 4 + 2) * d, Height / 2 * scale), new((i * 4 + 3) * d, Height * scale)
|
||||
}), new(n * 4 * d, Height / 2 * scale), new(0, Height / 2 * scale)];
|
||||
_polyline?.StrokeThickness = border;
|
||||
_leftSlide?.To = -d / 4;
|
||||
_clipCanvas?.Width = Width * scale;
|
||||
_clipCanvas?.Height = Height * scale;
|
||||
_clipCanvas?.RenderTransform = new RotateTransform(Angle, Width / 2 * scale, Height / 2 * scale);
|
||||
_clipCanvas?.SetValue(Canvas.TopProperty, (CenterY - Height / 2) * scale);
|
||||
_clipCanvas?.SetValue(Canvas.LeftProperty,( CenterX - Width / 2) * scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,30 @@ 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) {
|
||||
var border = Graph.ToBorder(scale);
|
||||
Graph.SetCenter(_circle, CenterX, CenterY, DIAMETER, DIAMETER, scale);
|
||||
_circle?.StrokeThickness = border;
|
||||
_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;
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
@@ -18,22 +18,23 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
|
||||
public bool IsActive => CallbackActive();
|
||||
public bool IsAnimationActive {
|
||||
get => _animationActive;
|
||||
get => !(_storyboard?.GetIsPaused() ?? true);
|
||||
set {
|
||||
_animationActive = value;
|
||||
if (value) {
|
||||
_storyboard?.Resume();
|
||||
} else {
|
||||
_storyboard?.Pause();
|
||||
if (_storyboard == null) return;
|
||||
if (value && _storyboard.GetIsPaused()) {
|
||||
_storyboard.Resume();
|
||||
} else if (!value && !_storyboard.GetIsPaused()) {
|
||||
_storyboard.Pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected Func<bool> CallbackActive;
|
||||
|
||||
private bool _animationActive;
|
||||
private Shape? _rect;
|
||||
private Rectangle? _rect;
|
||||
private Polyline? _polyline;
|
||||
private DoubleAnimation? _slideUp;
|
||||
private Canvas? _clipCanvas;
|
||||
private Storyboard? _storyboard;
|
||||
|
||||
public ConveyorBelt(string label, double x, double y, Func<bool> cbActive) {
|
||||
@@ -47,52 +48,58 @@ 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;
|
||||
_polyline = new Polyline() {
|
||||
Points = [.. Enumerable.Range(0, n).SelectMany(i => new List<Point>() {
|
||||
new(-WIDTH, i * d), new(WIDTH, i * d), new(-WIDTH, i * d)
|
||||
})],
|
||||
Fill = Brushes.Transparent,
|
||||
Stroke = Brushes.Black,
|
||||
StrokeThickness = 2,
|
||||
};
|
||||
_polyline.SetValue(Canvas.TopProperty, 0.0);
|
||||
|
||||
var slideUp = new DoubleAnimation {
|
||||
_slideUp = new DoubleAnimation {
|
||||
From = 0,
|
||||
To = -d,
|
||||
Duration = new Duration(TimeSpan.FromSeconds(1)),
|
||||
RepeatBehavior = RepeatBehavior.Forever,
|
||||
};
|
||||
_storyboard = new Storyboard();
|
||||
_storyboard.Children.Add(slideUp);
|
||||
Storyboard.SetTarget(slideUp, _polyline);
|
||||
Storyboard.SetTargetProperty(slideUp, new PropertyPath(Canvas.TopProperty));
|
||||
var clipCanvas = new Canvas() {
|
||||
Width = WIDTH - 15,
|
||||
Height = HEIGHT - 8,
|
||||
_storyboard.Children.Add(_slideUp);
|
||||
Storyboard.SetTarget(_slideUp, _polyline);
|
||||
Storyboard.SetTargetProperty(_slideUp, new PropertyPath(Canvas.TopProperty));
|
||||
_clipCanvas = new Canvas() {
|
||||
ClipToBounds = true,
|
||||
};
|
||||
clipCanvas.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2 + 4);
|
||||
clipCanvas.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2 + 7.5);
|
||||
clipCanvas.Children.Add(_polyline);
|
||||
_clipCanvas.Children.Add(_polyline);
|
||||
|
||||
canvas.Children.Add(_rect);
|
||||
canvas.Children.Add(clipCanvas);
|
||||
canvas.Children.Add(_clipCanvas);
|
||||
_storyboard.Begin();
|
||||
_storyboard.Pause();
|
||||
}
|
||||
|
||||
public void Scale(double scale) {
|
||||
var border = Graph.ToBorder(scale);
|
||||
_rect?.Width = WIDTH * scale;
|
||||
_rect?.Height = HEIGHT * scale;
|
||||
_rect?.StrokeThickness = border;
|
||||
_rect?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
|
||||
_rect?.SetValue(Canvas.TopProperty, (CenterY - HEIGHT / 2) * scale);
|
||||
|
||||
var d = 3 * scale;
|
||||
int n = (int)(HEIGHT * scale / d) + 2;
|
||||
_polyline?.Points = [.. Enumerable.Range(0, n).SelectMany(i => new List<Point>() {
|
||||
new(-WIDTH * scale, i * d), new(WIDTH * scale, i * d), new(-WIDTH * scale, i * d)
|
||||
})];
|
||||
_polyline?.StrokeThickness = border;
|
||||
_slideUp?.To = -d;
|
||||
|
||||
_clipCanvas?.Width = (WIDTH - 2.2) * scale - border * 2;
|
||||
_clipCanvas?.Height = (HEIGHT - 0.8) * scale - border * 2;
|
||||
_clipCanvas?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2 + 1.1) * scale + border);
|
||||
_clipCanvas?.SetValue(Canvas.TopProperty, (CenterY - HEIGHT / 2 + 0.4) * scale + border);
|
||||
}
|
||||
|
||||
public bool IsInside(double x, double y) {
|
||||
|
||||
@@ -6,8 +6,8 @@ using System.Windows.Shapes;
|
||||
namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public class EncasedAuger : INode {
|
||||
|
||||
public const double WIDTH = 80;
|
||||
public const double HEIGHT = 20;
|
||||
public const double WIDTH = 16;
|
||||
public const double HEIGHT = 4;
|
||||
|
||||
public double CenterX { get; set; }
|
||||
public double CenterY { get; set; }
|
||||
@@ -29,8 +29,9 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
protected Func<bool> CallbackActive;
|
||||
|
||||
private bool _animationActive;
|
||||
private Shape? _inner;
|
||||
private Shape? _outer;
|
||||
private Canvas? _canvas;
|
||||
private Rectangle? _inner;
|
||||
private Rectangle? _outer;
|
||||
private Auger? _auger;
|
||||
private TextBlock? _text;
|
||||
|
||||
@@ -46,41 +47,49 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
}
|
||||
|
||||
public void Draw(Canvas canvas) {
|
||||
var c = new Canvas() {
|
||||
RenderTransform = new RotateTransform(Angle, WIDTH / 2, HEIGHT / 2),
|
||||
_canvas = new Canvas() {
|
||||
RenderTransform = new RotateTransform(Angle),
|
||||
};
|
||||
_outer = new Rectangle() {
|
||||
Width = WIDTH,
|
||||
Height = HEIGHT,
|
||||
Fill = Brushes.Black,
|
||||
};
|
||||
_inner = new Rectangle() {
|
||||
Width = WIDTH,
|
||||
Height = HEIGHT - 4,
|
||||
Fill = Brushes.WhiteSmoke,
|
||||
};
|
||||
c.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
|
||||
c.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2);
|
||||
_inner.SetValue(Canvas.TopProperty, 2.0);
|
||||
c.Children.Add(_outer);
|
||||
c.Children.Add(_inner);
|
||||
canvas.Children.Add(c);
|
||||
|
||||
_canvas.Children.Add(_outer);
|
||||
_canvas.Children.Add(_inner);
|
||||
canvas.Children.Add(_canvas);
|
||||
|
||||
_text = new() {
|
||||
Text = Label,
|
||||
Width = WIDTH,
|
||||
FontSize = 12,
|
||||
TextAlignment = TextAlignment.Center,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
};
|
||||
_text.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
|
||||
_text.SetValue(Canvas.TopProperty, CenterY + HEIGHT / 2);
|
||||
canvas.Children.Add(_text);
|
||||
|
||||
_auger = new Auger(CenterX, CenterY, WIDTH, 12, Angle);
|
||||
_auger = new Auger(CenterX, CenterY, WIDTH, 2.4, Angle);
|
||||
_auger.Draw(canvas);
|
||||
}
|
||||
|
||||
public void Scale(double scale) {
|
||||
var border = Graph.ToBorder(scale);
|
||||
_canvas?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
|
||||
_canvas?.SetValue(Canvas.TopProperty, (CenterY - HEIGHT / 2) * scale);
|
||||
_canvas?.RenderTransform = new RotateTransform(Angle, WIDTH / 2 * scale, HEIGHT / 2 * scale);
|
||||
_outer?.Width = WIDTH * scale;
|
||||
_outer?.Height = HEIGHT * scale;
|
||||
_inner?.Width = WIDTH * scale;
|
||||
_inner?.Height = HEIGHT * scale - border * 2;
|
||||
_inner?.SetValue(Canvas.TopProperty, border);
|
||||
|
||||
_text?.FontSize = 12;
|
||||
_text?.Width = WIDTH * scale;
|
||||
_text?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
|
||||
_text?.SetValue(Canvas.TopProperty, (CenterY + HEIGHT / 2) * scale);
|
||||
_auger?.Scale(scale);
|
||||
}
|
||||
|
||||
public bool IsInside(double x, double y) {
|
||||
return Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= WIDTH / 2;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ using System.Windows.Shapes;
|
||||
namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
class EntryTrough : INode {
|
||||
|
||||
public const double WIDTH = 150;
|
||||
public const double HEIGHT = 60;
|
||||
public const double WIDTH = 30;
|
||||
public const double HEIGHT = 12;
|
||||
|
||||
public double CenterX { get; set; }
|
||||
public double CenterY { get; set; }
|
||||
@@ -20,9 +20,8 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public bool IsAnimationActive {
|
||||
get => _animationActive;
|
||||
set {
|
||||
_animationActive = value;
|
||||
_auger?.IsAnimationActive = value;
|
||||
if (value) {
|
||||
if (value && !_animationActive) {
|
||||
_doorTransform?.BeginAnimation(
|
||||
RotateTransform.AngleProperty,
|
||||
new DoubleAnimation {
|
||||
@@ -30,7 +29,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
To = 60,
|
||||
Duration = TimeSpan.FromSeconds(Math.Abs(_doorTransform.Angle - 60) / 60.0)
|
||||
});
|
||||
} else {
|
||||
} else if (!value && _animationActive) {
|
||||
_doorTransform?.BeginAnimation(
|
||||
RotateTransform.AngleProperty,
|
||||
new DoubleAnimation {
|
||||
@@ -39,17 +38,23 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
Duration = TimeSpan.FromSeconds(Math.Abs(_doorTransform.Angle - 0) / 60.0)
|
||||
});
|
||||
}
|
||||
_animationActive = value;
|
||||
}
|
||||
}
|
||||
|
||||
public double Top => CenterY - HEIGHT / 2;
|
||||
public double Right => CenterX + WIDTH / 2;
|
||||
public double Bottom => CenterY + HEIGHT / 2;
|
||||
public double Left => CenterX - WIDTH / 2;
|
||||
|
||||
protected Func<bool> CallbackActive;
|
||||
|
||||
private bool _animationActive;
|
||||
private Shape? _inner;
|
||||
private Shape? _outer;
|
||||
private Polygon? _inner;
|
||||
private Polygon? _outer;
|
||||
private TextBlock? _text;
|
||||
private Auger? _auger;
|
||||
private Shape? _door;
|
||||
private Line? _door;
|
||||
private RotateTransform? _doorTransform;
|
||||
|
||||
public EntryTrough(string label, double x, double y, Func<bool> cbActive) {
|
||||
@@ -62,42 +67,62 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
}
|
||||
|
||||
public void Draw(Canvas canvas) {
|
||||
var top = CenterY - HEIGHT / 2;
|
||||
var right = CenterX + WIDTH / 2;
|
||||
var bottom = CenterY + HEIGHT / 2;
|
||||
var left = CenterX - WIDTH / 2;
|
||||
_outer = new Polygon() {
|
||||
Points = [new(left, top), new(right, top), new(right - 20, bottom), new(left, bottom), new(left, bottom - 20), new(left + 12.5, bottom - 20)],
|
||||
Fill = Brushes.Black,
|
||||
};
|
||||
_inner = new Polygon() {
|
||||
Points = [new(left + 2, top), new(right - 2, top), new(right - 20 - 2, bottom - 2), new(left, bottom - 2), new(left, bottom - 18), new(left + 15.5, bottom - 18)],
|
||||
Fill = Brushes.WhiteSmoke,
|
||||
};
|
||||
_doorTransform = new RotateTransform(0, left, bottom - 24);
|
||||
_doorTransform = new RotateTransform(0);
|
||||
_door = new Line() {
|
||||
X1 = left, Y1 = bottom - 24, X2 = left, Y2 = bottom + 4,
|
||||
Stroke = Brushes.Black,
|
||||
StrokeThickness = 4,
|
||||
RenderTransform = _doorTransform,
|
||||
};
|
||||
_text = new() {
|
||||
Text = Label,
|
||||
FontSize = 12,
|
||||
Width = WIDTH,
|
||||
TextAlignment = TextAlignment.Center,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
};
|
||||
_text.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
|
||||
_text.SetValue(Canvas.TopProperty, CenterY - 7.5 - 8);
|
||||
canvas.Children.Add(_outer);
|
||||
canvas.Children.Add(_inner);
|
||||
canvas.Children.Add(_text);
|
||||
canvas.Children.Add(_door);
|
||||
_auger = new(CenterX - 11, CenterY + HEIGHT / 2 - 9, WIDTH - 25, 12);
|
||||
_auger = new(CenterX - 2.2, CenterY + HEIGHT / 2 - 1.8, WIDTH - 5, 2.4);
|
||||
_auger.Draw(canvas);
|
||||
}
|
||||
|
||||
public void Scale(double scale) {
|
||||
var border = Graph.ToBorder(scale);
|
||||
_outer?.Points = [
|
||||
new(Left * scale, Top * scale),
|
||||
new(Right * scale, Top * scale),
|
||||
new((Right - 4) * scale, Bottom * scale),
|
||||
new(Left * scale, Bottom * scale),
|
||||
new(Left * scale, (Bottom - 4) * scale),
|
||||
new((Left + 2.5) * scale, (Bottom - 4) * scale),
|
||||
];
|
||||
_inner?.Points = [
|
||||
new(Left * scale + border, Top * scale),
|
||||
new(Right * scale - border, Top * scale),
|
||||
new((Right - 4) * scale - border, Bottom * scale - border),
|
||||
new(Left * scale, Bottom * scale - border),
|
||||
new(Left * scale, (Bottom - 3.6) * scale),
|
||||
new((Left + 3.1) * scale, (Bottom - 3.6) * scale),
|
||||
];
|
||||
_door?.X1 = Left * scale;
|
||||
_door?.Y1 = (Bottom - 4.8) * scale;
|
||||
_door?.X2 = Left * scale;
|
||||
_door?.Y2 = (Bottom + 0.8) * scale;
|
||||
_door?.StrokeThickness = border * 2;
|
||||
_doorTransform?.CenterX = Left * scale;
|
||||
_doorTransform?.CenterY = (Bottom - 4.8) * scale;
|
||||
_text?.FontSize = 12;
|
||||
_text?.Width = WIDTH * scale;
|
||||
_text?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
|
||||
_text?.SetValue(Canvas.TopProperty, (CenterY - 1.5) * scale - 8);
|
||||
_auger?.Scale(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]);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Media3D;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
@@ -102,22 +104,67 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
}
|
||||
}
|
||||
|
||||
public void Draw(Canvas canvas) {
|
||||
canvas.Children.Add(new Rectangle() {
|
||||
public void Draw(Canvas canvas, double scale) {
|
||||
var bg = new Rectangle() {
|
||||
Fill = Brushes.White,
|
||||
Width = 5000,
|
||||
Height = 5000,
|
||||
});
|
||||
Width = 8000,
|
||||
Height = 8000,
|
||||
};
|
||||
SetPos(bg, -4000, -4000, 1);
|
||||
canvas.Children.Add(bg);
|
||||
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 static double ToPx(double v, double scale) {
|
||||
return Math.Round(v * scale);
|
||||
}
|
||||
|
||||
public static Point ToPx(double x, double y, double scale, double dxpx = 0, double dypx = 0, bool round = true) {
|
||||
var p = new Point(x * scale + dxpx, y * scale + dypx);
|
||||
return round ? new(Math.Round(p.X), Math.Round(p.Y)) : p;
|
||||
}
|
||||
|
||||
public static Point ToPx(Point p, double scale) {
|
||||
return ToPx(p.X, p.Y, scale);
|
||||
}
|
||||
|
||||
public static double ToBorder(double scale) {
|
||||
return scale > 10 ? 4 : scale > 7.5 ? 3 : scale > 4 ? 2 : 1;
|
||||
}
|
||||
|
||||
public static void SetPos(FrameworkElement? s, double x, double y, double scale, double dxpx = 0, double dypx = 0) {
|
||||
s?.SetValue(Canvas.LeftProperty, ToPx(x, scale) + dxpx);
|
||||
s?.SetValue(Canvas.TopProperty, ToPx(y, scale) + dypx);
|
||||
}
|
||||
|
||||
public static void SetWH(Shape? s, double w, double h, double scale) {
|
||||
s?.Width = ToPx(w, scale);
|
||||
s?.Height = ToPx(h, scale);
|
||||
}
|
||||
|
||||
public static void SetCenter(Shape? s, double cx, double cy, double w, double h, double scale) {
|
||||
Graph.SetWH(s, w, h, scale);
|
||||
Graph.SetPos(s, cx - w / 2, cy - h / 2, 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,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 = 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) {
|
||||
var border = Graph.ToBorder(scale);
|
||||
Graph.SetWH(_rect, WIDTH, HEIGHT, scale);
|
||||
Graph.SetPos(_rect, CenterX - WIDTH / 2, CenterY - HEIGHT / 2, scale);
|
||||
_rect?.StrokeThickness = border;
|
||||
_text?.FontSize = 12;
|
||||
_text?.Width = Math.Round(HEIGHT * scale);
|
||||
Graph.SetPos(_text, CenterX, CenterY + HEIGHT / 2, scale, dxpx: -9);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,33 @@ 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() {
|
||||
Stroke = Brushes.Black,
|
||||
StrokeStartLineCap = PenLineCap.Round,
|
||||
StrokeLineJoin = PenLineJoin.Round,
|
||||
StrokeEndLineCap = PenLineCap.Flat,
|
||||
};
|
||||
_inner2 = new Line() {
|
||||
X1 = x2,
|
||||
Y1 = y2,
|
||||
X2 = x3,
|
||||
Y2 = y3,
|
||||
StrokeThickness = 6,
|
||||
_inner = new Polyline() {
|
||||
Stroke = Brushes.DarkGray,
|
||||
StrokeStartLineCap = PenLineCap.Round,
|
||||
StrokeLineJoin = PenLineJoin.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) {
|
||||
var border = Graph.ToBorder(scale);
|
||||
_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;
|
||||
_flowArrows?.Update(Flow);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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,13 @@ 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,
|
||||
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,
|
||||
Stroke = Brushes.DarkGray,
|
||||
StrokeStartLineCap = PenLineCap.Round,
|
||||
StrokeEndLineCap = PenLineCap.Round,
|
||||
@@ -58,20 +55,28 @@ 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) {
|
||||
var border = Graph.ToBorder(scale);
|
||||
_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;
|
||||
_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);
|
||||
|
||||
@@ -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; }
|
||||
@@ -16,7 +16,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public ISet<IEdge> Inputs { get; init; }
|
||||
public ISet<IEdge> Outputs { get; init; }
|
||||
|
||||
private Shape? _rect;
|
||||
private Polygon? _rect;
|
||||
|
||||
public PipeJoin(double x, double y) {
|
||||
CenterX = x;
|
||||
@@ -26,14 +26,22 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
}
|
||||
|
||||
public void Draw(Canvas canvas) {
|
||||
var it = Inputs.Any(e => (e.Start.CenterY < CenterY && (!e.Orientation || e.Start.CenterX == CenterX)) || (e.IsTwoWay && e.End.CenterY < CenterY && (!e.Orientation || e.End.CenterX == CenterX)));
|
||||
var ot = Outputs.Any(e => (e.End.CenterY < CenterY && ( e.Orientation || e.End.CenterX == CenterX)) || (e.IsTwoWay && e.Start.CenterY < CenterY && ( e.Orientation || e.Start.CenterX == CenterX)));
|
||||
var ir = Inputs.Any(e => (e.Start.CenterX > CenterX && ( e.Orientation || e.Start.CenterY == CenterY)) || (e.IsTwoWay && e.End.CenterX > CenterX && ( e.Orientation || e.End.CenterY == CenterY)));
|
||||
var or = Outputs.Any(e => (e.End.CenterX > CenterX && (!e.Orientation || e.End.CenterY == CenterY)) || (e.IsTwoWay && e.Start.CenterX > CenterX && (!e.Orientation || e.Start.CenterY == CenterY)));
|
||||
var ib = Inputs.Any(e => (e.Start.CenterY > CenterY && (!e.Orientation || e.Start.CenterX == CenterX)) || (e.IsTwoWay && e.End.CenterY > CenterY && (!e.Orientation || e.End.CenterX == CenterX)));
|
||||
var ob = Outputs.Any(e => (e.End.CenterY > CenterY && ( e.Orientation || e.End.CenterX == CenterX)) || (e.IsTwoWay && e.Start.CenterY > CenterY && ( e.Orientation || e.Start.CenterX == CenterX)));
|
||||
var il = Inputs.Any(e => (e.Start.CenterX < CenterX && ( e.Orientation || e.Start.CenterY == CenterY)) || (e.IsTwoWay && e.End.CenterX < CenterX && ( e.Orientation || e.End.CenterY == CenterY)));
|
||||
var ol = Outputs.Any(e => (e.End.CenterX < CenterX && (!e.Orientation || e.End.CenterY == CenterY)) || (e.IsTwoWay && e.Start.CenterX < CenterX && (!e.Orientation || e.Start.CenterY == CenterY)));
|
||||
_rect = new Polygon() {
|
||||
Fill = Brushes.Black,
|
||||
Stroke = Brushes.Black,
|
||||
};
|
||||
canvas.Children.Add(_rect);
|
||||
}
|
||||
|
||||
public void Scale(double scale) {
|
||||
var it = Inputs.Any(e => (e.Start.CenterY < CenterY && (!e.Orientation || e.Start.CenterX == CenterX)) || (e.IsTwoWay && e.End.CenterY < CenterY && (!e.Orientation || e.End.CenterX == CenterX)));
|
||||
var ot = Outputs.Any(e => (e.End.CenterY < CenterY && (e.Orientation || e.End.CenterX == CenterX)) || (e.IsTwoWay && e.Start.CenterY < CenterY && (e.Orientation || e.Start.CenterX == CenterX)));
|
||||
var ir = Inputs.Any(e => (e.Start.CenterX > CenterX && (e.Orientation || e.Start.CenterY == CenterY)) || (e.IsTwoWay && e.End.CenterX > CenterX && (e.Orientation || e.End.CenterY == CenterY)));
|
||||
var or = Outputs.Any(e => (e.End.CenterX > CenterX && (!e.Orientation || e.End.CenterY == CenterY)) || (e.IsTwoWay && e.Start.CenterX > CenterX && (!e.Orientation || e.Start.CenterY == CenterY)));
|
||||
var ib = Inputs.Any(e => (e.Start.CenterY > CenterY && (!e.Orientation || e.Start.CenterX == CenterX)) || (e.IsTwoWay && e.End.CenterY > CenterY && (!e.Orientation || e.End.CenterX == CenterX)));
|
||||
var ob = Outputs.Any(e => (e.End.CenterY > CenterY && (e.Orientation || e.End.CenterX == CenterX)) || (e.IsTwoWay && e.Start.CenterY > CenterY && (e.Orientation || e.Start.CenterX == CenterX)));
|
||||
var il = Inputs.Any(e => (e.Start.CenterX < CenterX && (e.Orientation || e.Start.CenterY == CenterY)) || (e.IsTwoWay && e.End.CenterX < CenterX && (e.Orientation || e.End.CenterY == CenterY)));
|
||||
var ol = Outputs.Any(e => (e.End.CenterX < CenterX && (!e.Orientation || e.End.CenterY == CenterY)) || (e.IsTwoWay && e.Start.CenterX < CenterX && (!e.Orientation || e.Start.CenterY == CenterY)));
|
||||
|
||||
var points = new List<Point> {
|
||||
new(0, 0)
|
||||
@@ -70,15 +78,10 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
points.AddRange([new(0, SIZE / 2 + POINT), new(POINT, SIZE / 2), new(0, SIZE / 2 - POINT)]);
|
||||
}
|
||||
|
||||
_rect = new Polygon() {
|
||||
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);
|
||||
_rect?.Points = [.. points.Select(p => new Point(p.X * scale, p.Y * scale))];
|
||||
_rect?.StrokeThickness = 2;
|
||||
_rect?.SetValue(Canvas.LeftProperty, (CenterX - SIZE / 2) * scale);
|
||||
_rect?.SetValue(Canvas.TopProperty, (CenterY - SIZE / 2) * scale);
|
||||
}
|
||||
|
||||
public bool IsInside(double x, double y) {
|
||||
|
||||
@@ -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; }
|
||||
@@ -24,8 +23,8 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
|
||||
protected Func<FillState> CallbackFillState;
|
||||
|
||||
private Shape? _frame;
|
||||
private Shape? _circle;
|
||||
private Polygon? _frame;
|
||||
private Ellipse? _circle;
|
||||
private TextBlock? _text;
|
||||
|
||||
public Press(string label, double x, double y, int capacityLiters, Func<FillState> cbFillState) {
|
||||
@@ -40,39 +39,40 @@ 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)
|
||||
],
|
||||
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) {
|
||||
var border = Graph.ToBorder(scale);
|
||||
_circle?.StrokeThickness = border;
|
||||
Graph.SetCenter(_circle, CenterX, CenterY, DIAMETER, DIAMETER, scale);
|
||||
_frame?.Points = [
|
||||
Graph.ToPx(CenterX - DIAMETER / 2 - 2, CenterY, scale), Graph.ToPx(CenterX + DIAMETER / 2 + 2, CenterY, scale),
|
||||
Graph.ToPx(CenterX + DIAMETER / 2 + 2, CenterY + DIAMETER / 2 + 6, scale), Graph.ToPx(CenterX + DIAMETER / 2 - 4, CenterY + DIAMETER / 2 + 6, scale),
|
||||
Graph.ToPx(CenterX + DIAMETER / 2 - 4, CenterY + DIAMETER / 2 + 2, scale), Graph.ToPx(CenterX - DIAMETER / 2 + 4, CenterY + DIAMETER / 2 + 2, scale),
|
||||
Graph.ToPx(CenterX - DIAMETER / 2 + 4, CenterY + DIAMETER / 2 + 6, scale), Graph.ToPx(CenterX - DIAMETER / 2 - 2, CenterY + DIAMETER / 2 + 6, scale),
|
||||
];
|
||||
_frame?.StrokeThickness = border;
|
||||
_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);
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
@@ -25,8 +25,8 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
protected Func<bool> CallbackClearance;
|
||||
protected Func<Pump, bool> CallbackSelected;
|
||||
|
||||
private Shape? _circle;
|
||||
private Shape? _triangle;
|
||||
private Ellipse? _circle;
|
||||
private Polygon? _triangle;
|
||||
private TextBlock? _text;
|
||||
|
||||
public Pump(string label, double x, double y, Func<MotorState> cbState, Func<bool> cbClearance, Func<Pump, bool> cbSelected) {
|
||||
@@ -42,35 +42,43 @@ 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);
|
||||
_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 void Scale(double scale) {
|
||||
var border = Graph.ToBorder(scale);;
|
||||
_circle?.Width = DIAMETER * scale;
|
||||
_circle?.Height = DIAMETER * scale;
|
||||
_circle?.StrokeThickness = border;
|
||||
_circle?.SetValue(Canvas.LeftProperty, (CenterX - DIAMETER / 2) * scale);
|
||||
_circle?.SetValue(Canvas.TopProperty, (CenterY - DIAMETER / 2) * scale);
|
||||
var dx = Math.Cos(Math.PI / 6) * (DIAMETER / 2);
|
||||
var dy = Math.Sin(Math.PI / 6) * (DIAMETER / 2);
|
||||
_triangle?.Points = [
|
||||
Graph.ToPx(CenterX - dx, CenterY - dy, scale, dxpx: border, dypx: border / 2, round: false),
|
||||
Graph.ToPx(CenterX + dx, CenterY - dy, scale, dxpx: -border, dypx: border / 2, round: false),
|
||||
Graph.ToPx(CenterX, CenterY + DIAMETER / 2, scale, dypx: -border, round: false),
|
||||
];
|
||||
_triangle?.StrokeThickness = border;
|
||||
_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;
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
@@ -20,11 +20,11 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
protected Func<bool> CallbackActive;
|
||||
|
||||
private TextBlock? _text;
|
||||
private Shape? _rect;
|
||||
private Shape? _hopperOuter;
|
||||
private Shape? _hopperInner;
|
||||
private Shape? _bottomInner;
|
||||
private Shape? _bottomOuter;
|
||||
private Rectangle? _rect;
|
||||
private Polygon? _hopperOuter;
|
||||
private Polygon? _hopperInner;
|
||||
private Polygon? _bottomInner;
|
||||
private Polygon? _bottomOuter;
|
||||
|
||||
public Rebler(string label, double x, double y, Func<bool> cbActive) {
|
||||
CenterX = x;
|
||||
@@ -37,54 +37,58 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
|
||||
public void Draw(Canvas canvas) {
|
||||
_rect = new Rectangle() {
|
||||
Width = WIDTH,
|
||||
Height = HEIGHT,
|
||||
Fill = Brushes.WhiteSmoke,
|
||||
Stroke = Brushes.Black,
|
||||
StrokeThickness = 2,
|
||||
};
|
||||
var left = CenterX - WIDTH / 2;
|
||||
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;
|
||||
_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)],
|
||||
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)],
|
||||
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)],
|
||||
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)],
|
||||
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(_bottomInner);
|
||||
canvas.Children.Add(_rect);
|
||||
canvas.Children.Add(_hopperInner);
|
||||
canvas.Children.Add(_bottomInner);
|
||||
canvas.Children.Add(_text);
|
||||
}
|
||||
|
||||
public void Scale(double scale) {
|
||||
var border = Graph.ToBorder(scale);
|
||||
Graph.SetCenter(_rect, CenterX, CenterY, WIDTH, HEIGHT, scale);
|
||||
_rect?.StrokeThickness = border;
|
||||
|
||||
var left = CenterX - WIDTH / 2;
|
||||
var right = CenterX + WIDTH / 2;
|
||||
var top = CenterY - HEIGHT / 2;
|
||||
var bottom = CenterY + HEIGHT / 2;
|
||||
var hx = right - 4;
|
||||
var h = 3;
|
||||
var w = 5;
|
||||
_hopperOuter?.Points = [Graph.ToPx(hx - w, top - h, scale), Graph.ToPx(hx - w + 1, top, scale, dypx: border), Graph.ToPx(hx + w - 1, top, scale, dypx: border), Graph.ToPx(hx + w, top - h, scale)];
|
||||
_hopperInner?.Points = [Graph.ToPx(hx - w, top - h, scale, dxpx: border), Graph.ToPx(hx - w + 1, top, scale, dxpx: border, dypx: border), Graph.ToPx(hx + w - 1, top, scale, dxpx: -border, dypx: border), Graph.ToPx(hx + w, top - h, scale, dxpx: -border)];
|
||||
_bottomOuter?.Points = [Graph.ToPx(left + 4, bottom, scale), Graph.ToPx(right - 4, bottom, scale), Graph.ToPx(right - 3, bottom + 2, scale), Graph.ToPx(left + 3, bottom + 2, scale)];
|
||||
_bottomInner?.Points = [Graph.ToPx(left + 4, bottom, scale, dxpx: border), Graph.ToPx(right - 4, bottom, scale, dxpx: -border), Graph.ToPx(right - 3, bottom + 2, scale, dxpx: -border), Graph.ToPx(left + 3, bottom + 2, scale, dxpx: border)];
|
||||
|
||||
_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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,31 @@ 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) {
|
||||
var border = Graph.ToBorder(scale);
|
||||
_rect?.Height = Graph.ToPx(HEIGHT, scale);
|
||||
_rect?.Width = Graph.ToPx(WIDTH, scale);
|
||||
_rect?.StrokeThickness = border;
|
||||
_rect?.SetValue(Canvas.LeftProperty, (CenterX - WIDTH / 2) * scale);
|
||||
_rect?.SetValue(Canvas.TopProperty, (CenterY - HEIGHT / 2) * scale);
|
||||
_text?.Width = Graph.ToPx(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;
|
||||
}
|
||||
|
||||
@@ -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,37 @@ 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) {
|
||||
var border = Graph.ToBorder(scale);
|
||||
_outer?.Width = WIDTH * scale;
|
||||
_outer?.Height = HEIGHT * scale;
|
||||
_inner?.Width = WIDTH * scale - border * 2;
|
||||
_inner?.Height = HEIGHT * scale - border;
|
||||
_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 + border);
|
||||
_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;
|
||||
}
|
||||
|
||||
@@ -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,30 @@ 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) {
|
||||
var border = Graph.ToBorder(scale);
|
||||
Graph.SetCenter(_circle, CenterX, CenterY, DIAMETER, DIAMETER, scale);
|
||||
_circle?.StrokeThickness = border;
|
||||
_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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user