Add Rebler
This commit is contained in:
@@ -19,7 +19,8 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
|
||||
protected Func<bool> CallbackIsFilled;
|
||||
|
||||
private Shape? _rect;
|
||||
private Shape? _inner;
|
||||
private Shape? _outer;
|
||||
private TextBlock? _text;
|
||||
|
||||
public Trough(string label, double x, double y, Func<bool> cbFilled) {
|
||||
@@ -32,11 +33,14 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
}
|
||||
|
||||
public void Draw(Canvas canvas) {
|
||||
_rect = new Rectangle() {
|
||||
_outer = new Rectangle() {
|
||||
Width = WIDTH,
|
||||
Height = HEIGHT,
|
||||
Stroke = Brushes.Black,
|
||||
StrokeThickness = 2,
|
||||
Fill = Brushes.Black,
|
||||
};
|
||||
_inner = new Rectangle() {
|
||||
Width = WIDTH - 4,
|
||||
Height = HEIGHT - 2,
|
||||
Fill = Brushes.WhiteSmoke,
|
||||
};
|
||||
_text = new() {
|
||||
@@ -46,18 +50,23 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
TextAlignment = TextAlignment.Center,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
};
|
||||
_rect.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
|
||||
_rect.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2);
|
||||
_outer.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
|
||||
_outer.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2);
|
||||
_inner.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2 + 2);
|
||||
_inner.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2);
|
||||
_text.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
|
||||
_text.SetValue(Canvas.TopProperty, CenterY - 8);
|
||||
canvas.Children.Add(_rect);
|
||||
canvas.Children.Add(_outer);
|
||||
canvas.Children.Add(_inner);
|
||||
canvas.Children.Add(_text);
|
||||
}
|
||||
|
||||
public bool Update(double x, double y, bool down) {
|
||||
var hover = Math.Abs(x - CenterX) <= WIDTH / 2 && Math.Abs(y - CenterY) <= HEIGHT / 2;
|
||||
_rect?.Fill = hover ? Brushes.LightGray : Brushes.WhiteSmoke;
|
||||
return hover;
|
||||
public bool IsInside(double x, double y) {
|
||||
return Math.Abs(x - CenterX) <= WIDTH / 2 && Math.Abs(y - CenterY) <= HEIGHT / 2;
|
||||
}
|
||||
|
||||
public void Update(bool isHovering, bool isPressed) {
|
||||
_inner?.Fill = isHovering ? Brushes.LightGray : Brushes.WhiteSmoke;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user