@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user