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