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