Add press 1 and 2

This commit is contained in:
2026-07-13 23:43:05 +02:00
parent 74ec9527da
commit 0967249a22
9 changed files with 200 additions and 60 deletions
+10 -10
View File
@@ -6,7 +6,7 @@ using System.Windows.Shapes;
namespace PamhagenSysCtrl.Helpers.Pipeline {
public class Valve : INode {
public const double RADIUS = 24;
public const double DIAMETER = 24;
public double CenterX { get; set; }
public double CenterY { get; set; }
@@ -35,30 +35,30 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public void Draw(Canvas canvas) {
_circle = new Ellipse() {
Height = RADIUS,
Width = RADIUS,
Height = DIAMETER,
Width = DIAMETER,
Fill = Brushes.DarkGray,
Stroke = Brushes.Black,
StrokeThickness = 2,
};
_circle.SetValue(Canvas.LeftProperty, CenterX - RADIUS / 2);
_circle.SetValue(Canvas.TopProperty, CenterY - RADIUS / 2);
_circle.SetValue(Canvas.LeftProperty, CenterX - DIAMETER / 2);
_circle.SetValue(Canvas.TopProperty, CenterY - DIAMETER / 2);
_text = new() {
Text = Label,
FontSize = 10,
Width = RADIUS,
Height = RADIUS,
Width = DIAMETER,
Height = DIAMETER,
TextAlignment = TextAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
_text.SetValue(Canvas.LeftProperty, CenterX - RADIUS / 2);
_text.SetValue(Canvas.TopProperty, CenterY - RADIUS / 2 + 5);
_text.SetValue(Canvas.LeftProperty, CenterX - DIAMETER / 2);
_text.SetValue(Canvas.TopProperty, CenterY - DIAMETER / 2 + 5);
canvas.Children.Add(_circle);
canvas.Children.Add(_text);
}
public bool Update(double x, double y) {
var hover = Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= RADIUS / 2;
var hover = Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= DIAMETER / 2;
_circle?.Fill = hover ? Brushes.LightGray : Brushes.DarkGray;
return hover;
}