Add press 1 and 2
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
using System.Windows.Controls;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public class Pump : INode {
|
||||
|
||||
public const double RADIUS = 24;
|
||||
public const double DIAMETER = 24;
|
||||
|
||||
public double CenterX { get; set; }
|
||||
public double CenterY { get; set; }
|
||||
@@ -15,6 +16,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public ISet<IEdge> Outputs { get; init; }
|
||||
|
||||
private Shape? _circle;
|
||||
private Shape? _triangle;
|
||||
private TextBlock? _text;
|
||||
|
||||
public Pump(string label, double x, double y) {
|
||||
@@ -27,19 +29,39 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
|
||||
public void Draw(Canvas canvas) {
|
||||
_circle = new Ellipse() {
|
||||
Height = RADIUS,
|
||||
Width = RADIUS,
|
||||
Height = DIAMETER,
|
||||
Width = DIAMETER,
|
||||
Fill = Brushes.WhiteSmoke,
|
||||
Stroke = Brushes.Black,
|
||||
StrokeThickness = 2,
|
||||
};
|
||||
_circle.SetValue(Canvas.LeftProperty, CenterX - RADIUS / 2);
|
||||
_circle.SetValue(Canvas.TopProperty, CenterY - RADIUS / 2);
|
||||
var dx = Math.Cos(Math.PI / 6) * (DIAMETER / 2 - 2);
|
||||
var dy = Math.Sin(Math.PI / 6) * (DIAMETER / 2 - 2);
|
||||
_triangle = new Polygon() {
|
||||
Points = [new(CenterX - dx, CenterY - dy), new(CenterX + dx, CenterY - dy), new(CenterX, CenterY + DIAMETER / 2 - 2)],
|
||||
Fill = Brushes.Transparent,
|
||||
Stroke = Brushes.Black,
|
||||
StrokeThickness = 2,
|
||||
};
|
||||
_text = new() {
|
||||
Text = Label,
|
||||
FontSize = 14,
|
||||
TextAlignment = TextAlignment.Left,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
};
|
||||
_circle.SetValue(Canvas.LeftProperty, CenterX - DIAMETER / 2);
|
||||
_circle.SetValue(Canvas.TopProperty, CenterY - DIAMETER / 2);
|
||||
_text.SetValue(Canvas.LeftProperty, CenterX + DIAMETER / 2 + 2);
|
||||
_text.SetValue(Canvas.TopProperty, CenterY - 10);
|
||||
canvas.Children.Add(_circle);
|
||||
canvas.Children.Add(_triangle);
|
||||
canvas.Children.Add(_text);
|
||||
}
|
||||
|
||||
public bool Update(double x, double y) {
|
||||
return false;
|
||||
var hover = Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= DIAMETER / 2;
|
||||
_circle?.Fill = hover ? Brushes.LightGray : Brushes.WhiteSmoke;
|
||||
return hover;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user