Add conveyor belt and augers
This commit is contained in:
@@ -11,6 +11,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public double CenterY { get; set; }
|
||||
public double Width { get; set; }
|
||||
public double Height { get; set; }
|
||||
public double Angle { get; set; }
|
||||
|
||||
public bool IsActive {
|
||||
set {
|
||||
@@ -25,11 +26,12 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
private Polyline? _polyline;
|
||||
private Storyboard? _storyboard;
|
||||
|
||||
public Auger(double x, double y, double width, double height) {
|
||||
public Auger(double x, double y, double width, double height, double angle = 0) {
|
||||
CenterX = x;
|
||||
CenterY = y;
|
||||
Width = width;
|
||||
Height = height;
|
||||
Angle = angle;
|
||||
}
|
||||
|
||||
public void Draw(Canvas canvas) {
|
||||
@@ -60,6 +62,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
Width = Width,
|
||||
Height = Height,
|
||||
ClipToBounds = true,
|
||||
RenderTransform = new RotateTransform(Angle, Width / 2, Height / 2),
|
||||
};
|
||||
clipCanvas.SetValue(Canvas.TopProperty, CenterY - Height / 2);
|
||||
clipCanvas.SetValue(Canvas.LeftProperty, CenterX - Width / 2);
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media.Media3D;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public class ConveyorBelt : INode {
|
||||
|
||||
public const double WIDTH = 35;
|
||||
public const double HEIGHT = 120;
|
||||
|
||||
public double CenterX { get; set; }
|
||||
public double CenterY { get; set; }
|
||||
public string Label { get; set; }
|
||||
public ISet<IEdge> Inputs { get; init; }
|
||||
public ISet<IEdge> Outputs { get; init; }
|
||||
|
||||
public bool IsActive {
|
||||
get => _active;
|
||||
set {
|
||||
_active = value;
|
||||
if (value) {
|
||||
_storyboard?.Resume();
|
||||
} else {
|
||||
_storyboard?.Pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _active;
|
||||
private Shape? _rect;
|
||||
private Polyline? _polyline;
|
||||
private Storyboard? _storyboard;
|
||||
|
||||
public ConveyorBelt(string label, double x, double y) {
|
||||
CenterX = x;
|
||||
CenterY = y;
|
||||
Label = label;
|
||||
Inputs = new HashSet<IEdge>();
|
||||
Outputs = new HashSet<IEdge>();
|
||||
}
|
||||
|
||||
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 = 20;
|
||||
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 {
|
||||
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 - 20,
|
||||
Height = HEIGHT - 2,
|
||||
ClipToBounds = true,
|
||||
};
|
||||
clipCanvas.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2 + 2);
|
||||
clipCanvas.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2 + 10);
|
||||
clipCanvas.Children.Add(_polyline);
|
||||
|
||||
canvas.Children.Add(_rect);
|
||||
canvas.Children.Add(clipCanvas);
|
||||
_storyboard.Begin();
|
||||
_storyboard.Pause();
|
||||
|
||||
}
|
||||
|
||||
public bool IsInside(double x, double y) {
|
||||
return Math.Abs(x - CenterX) <= WIDTH / 2 && Math.Abs(y - CenterY) <= HEIGHT / 2;
|
||||
}
|
||||
|
||||
public void Update(bool isHovering, bool isPressed) {
|
||||
_rect?.Fill =
|
||||
IsActive && isHovering && isPressed ? PamhagenBrushes.Red :
|
||||
IsActive && isHovering ? PamhagenBrushes.Red :
|
||||
!IsActive && isHovering && isPressed ? PamhagenBrushes.Green :
|
||||
!IsActive && isHovering ? PamhagenBrushes.Green :
|
||||
IsActive ? PamhagenBrushes.Green :
|
||||
Brushes.WhiteSmoke;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public class EncasedAuger : INode {
|
||||
|
||||
public const double WIDTH = 80;
|
||||
public const double HEIGHT = 20;
|
||||
|
||||
public double CenterX { get; set; }
|
||||
public double CenterY { get; set; }
|
||||
public double Angle { get; set; }
|
||||
public string Label { get; set; }
|
||||
public ISet<IEdge> Inputs { get; init; }
|
||||
public ISet<IEdge> Outputs { get; init; }
|
||||
|
||||
public bool IsActive {
|
||||
get => _active;
|
||||
set {
|
||||
_active = value;
|
||||
_auger?.IsActive = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool _active;
|
||||
private Shape? _inner;
|
||||
private Shape? _outer;
|
||||
private Auger? _auger;
|
||||
private TextBlock? _text;
|
||||
|
||||
public EncasedAuger(string label, double x, double y, double angle = 0) {
|
||||
CenterX = x;
|
||||
CenterY = y;
|
||||
Label = label;
|
||||
Angle = angle;
|
||||
Inputs = new HashSet<IEdge>();
|
||||
Outputs = new HashSet<IEdge>();
|
||||
}
|
||||
|
||||
public void Draw(Canvas canvas) {
|
||||
var c = new Canvas() {
|
||||
RenderTransform = new RotateTransform(Angle, WIDTH / 2, HEIGHT / 2),
|
||||
};
|
||||
_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);
|
||||
|
||||
_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.Draw(canvas);
|
||||
}
|
||||
|
||||
public bool IsInside(double x, double y) {
|
||||
return Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= WIDTH / 2;
|
||||
}
|
||||
|
||||
public void Update(bool isHovering, bool isPressed) {
|
||||
_inner?.Fill =
|
||||
IsActive && isHovering && isPressed ? PamhagenBrushes.Red :
|
||||
IsActive && isHovering ? PamhagenBrushes.Red :
|
||||
!IsActive && isHovering && isPressed ? PamhagenBrushes.Green :
|
||||
!IsActive && isHovering ? PamhagenBrushes.Green :
|
||||
IsActive ? PamhagenBrushes.Green :
|
||||
Brushes.WhiteSmoke;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,14 +41,6 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
}
|
||||
}
|
||||
|
||||
public EntryTrough(string label, double x, double y) {
|
||||
CenterX = x;
|
||||
CenterY = y;
|
||||
Label = label;
|
||||
Inputs = new HashSet<IEdge>();
|
||||
Outputs = new HashSet<IEdge>();
|
||||
}
|
||||
|
||||
private bool _active;
|
||||
private Shape? _inner;
|
||||
private Shape? _outer;
|
||||
@@ -57,6 +49,14 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
private Shape? _door;
|
||||
private RotateTransform? _doorTransform;
|
||||
|
||||
public EntryTrough(string label, double x, double y) {
|
||||
CenterX = x;
|
||||
CenterY = y;
|
||||
Label = label;
|
||||
Inputs = new HashSet<IEdge>();
|
||||
Outputs = new HashSet<IEdge>();
|
||||
}
|
||||
|
||||
public void Draw(Canvas canvas) {
|
||||
var top = CenterY - HEIGHT / 2;
|
||||
var right = CenterX + WIDTH / 2;
|
||||
@@ -85,7 +85,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
};
|
||||
_text.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
|
||||
_text.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 6 - 8);
|
||||
_text.SetValue(Canvas.TopProperty, CenterY - 7.5 - 8);
|
||||
canvas.Children.Add(_outer);
|
||||
canvas.Children.Add(_inner);
|
||||
canvas.Children.Add(_text);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
Reference in New Issue
Block a user