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