Display filling level
This commit is contained in:
@@ -54,8 +54,11 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
return Math.Abs(x - CenterX) <= WIDTH / 2 && Math.Abs(y - CenterY) <= HEIGHT / 2;
|
||||
}
|
||||
|
||||
public void Update(bool isHovering, bool isPresed) {
|
||||
_rect?.Fill = isHovering ? Brushes.LightGray : Brushes.WhiteSmoke;
|
||||
public void Update(bool isHovering, bool isPressed) {
|
||||
_rect?.Fill =
|
||||
isHovering && isPressed ? Brushes.DarkGray :
|
||||
isHovering ? Brushes.LightGray :
|
||||
Brushes.WhiteSmoke;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,23 +15,24 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public ISet<IEdge> Inputs { get; set; }
|
||||
public ISet<IEdge> Outputs { get; set; }
|
||||
|
||||
protected Func<bool> CallbackIsFull;
|
||||
|
||||
public double TopY => CenterY - DIAMETER / 2;
|
||||
public bool IsFull => CallbackIsFull();
|
||||
public FillState FillState => CallbackFillState();
|
||||
public bool IsFull => FillState == FillState.Full;
|
||||
|
||||
public int? CapacityLiters { get; set; }
|
||||
|
||||
protected Func<FillState> CallbackFillState;
|
||||
|
||||
private Shape? _circle;
|
||||
private TextBlock? _text;
|
||||
|
||||
|
||||
public Press(string label, double x, double y, int capacityLiters, Func<bool> cbFull) {
|
||||
public Press(string label, double x, double y, int capacityLiters, Func<FillState> cbFillState) {
|
||||
CenterX = x;
|
||||
CenterY = y;
|
||||
Label = label;
|
||||
CapacityLiters = capacityLiters;
|
||||
CallbackIsFull = cbFull;
|
||||
CallbackFillState = cbFillState;
|
||||
Inputs = new HashSet<IEdge>();
|
||||
Outputs = new HashSet<IEdge>();
|
||||
}
|
||||
@@ -64,7 +65,11 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
}
|
||||
|
||||
public void Update(bool isHovering, bool isPressed) {
|
||||
_circle?.Fill = isHovering ? Brushes.LightGray : Brushes.WhiteSmoke;
|
||||
_circle?.Fill = PamhagenBrushes.ForFillState(FillState,
|
||||
isHovering && isPressed ? Brushes.DarkGray :
|
||||
isHovering ? Brushes.LightGray :
|
||||
Brushes.WhiteSmoke
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
@@ -39,8 +38,11 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
Stroke = Brushes.Black,
|
||||
StrokeThickness = 2,
|
||||
};
|
||||
var hx = CenterX + WIDTH / 2 - 10;
|
||||
var left = CenterX - WIDTH / 2;
|
||||
var right = CenterX + WIDTH / 2;
|
||||
var top = CenterY - HEIGHT / 2;
|
||||
var bottom = CenterY + HEIGHT / 2;
|
||||
var hx = right - 10;
|
||||
var h = 15;
|
||||
var w = 25;
|
||||
_hopperOuter = new Polygon() {
|
||||
@@ -51,6 +53,14 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
Points = [new(hx - w + 2, top - h), new(hx, top + 26), new(hx + w - 2, top - h)],
|
||||
Fill = Brushes.WhiteSmoke,
|
||||
};
|
||||
_bottomOuter = new Polygon() {
|
||||
Points = [new(left + 20, bottom), new(right - 20, bottom), new(right - 15, bottom + 10), new(left + 15, bottom + 10)],
|
||||
Fill = Brushes.Black,
|
||||
};
|
||||
_bottomInner = new Polygon() {
|
||||
Points = [new(left + 20 + 2, bottom), new(right - 20 - 2, bottom), new(right - 15 - 2, bottom + 10), new(left + 15 + 2, bottom + 10)],
|
||||
Fill = Brushes.WhiteSmoke,
|
||||
};
|
||||
_text = new() {
|
||||
Text = Label,
|
||||
FontSize = 12,
|
||||
@@ -63,8 +73,10 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
_text.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
|
||||
_text.SetValue(Canvas.TopProperty, CenterY - 8);
|
||||
canvas.Children.Add(_hopperOuter);
|
||||
canvas.Children.Add(_bottomOuter);
|
||||
canvas.Children.Add(_rect);
|
||||
canvas.Children.Add(_hopperInner);
|
||||
canvas.Children.Add(_bottomInner);
|
||||
canvas.Children.Add(_text);
|
||||
}
|
||||
|
||||
@@ -73,9 +85,18 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
}
|
||||
|
||||
public void Update(bool isHovering, bool isPressed) {
|
||||
_rect?.Fill = isHovering ? Brushes.LightGray : Brushes.WhiteSmoke;
|
||||
_hopperInner?.Fill = isHovering ? Brushes.LightGray : Brushes.WhiteSmoke;
|
||||
_bottomInner?.Fill = isHovering ? Brushes.LightGray : Brushes.WhiteSmoke;
|
||||
_rect?.Fill =
|
||||
isHovering && isPressed ? Brushes.DarkGray :
|
||||
isHovering ? Brushes.LightGray :
|
||||
Brushes.WhiteSmoke;
|
||||
_hopperInner?.Fill =
|
||||
isHovering && isPressed ? Brushes.DarkGray :
|
||||
isHovering ? Brushes.LightGray :
|
||||
Brushes.WhiteSmoke;
|
||||
_bottomInner?.Fill =
|
||||
isHovering && isPressed ? Brushes.DarkGray :
|
||||
isHovering ? Brushes.LightGray :
|
||||
Brushes.WhiteSmoke;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,27 +14,26 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public double TopY => CenterY - HEIGHT / 2;
|
||||
public double BottomY => CenterY + HEIGHT / 2;
|
||||
public string Label { get; set; }
|
||||
public bool IsFull => CallbackIsFull();
|
||||
public bool IsFilled => CallbackIsFilled();
|
||||
public FillState FillState => CallbackFillState();
|
||||
public bool IsFull => FillState == FillState.Full;
|
||||
public bool IsFilled => FillState != FillState.Empty;
|
||||
|
||||
public ISet<IEdge> Inputs { get; init; }
|
||||
public ISet<IEdge> Outputs { get; init; }
|
||||
|
||||
public int? CapacityLiters { get; set; }
|
||||
|
||||
protected Func<bool> CallbackIsFilled;
|
||||
protected Func<bool> CallbackIsFull;
|
||||
protected Func<FillState> CallbackFillState;
|
||||
|
||||
private Shape? _rect;
|
||||
private TextBlock? _text;
|
||||
|
||||
public Tank(string label, double x, double y, int capacityLiters, Func<bool> cbFilled, Func<bool> cbFull) {
|
||||
public Tank(string label, double x, double y, int capacityLiters, Func<FillState> cbFillState) {
|
||||
CenterX = x;
|
||||
CenterY = y;
|
||||
Label = label;
|
||||
CapacityLiters = capacityLiters;
|
||||
CallbackIsFilled = cbFilled;
|
||||
CallbackIsFull = cbFull;
|
||||
CallbackFillState = cbFillState;
|
||||
Inputs = new HashSet<IEdge>();
|
||||
Outputs = new HashSet<IEdge>();
|
||||
}
|
||||
@@ -67,7 +66,11 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
}
|
||||
|
||||
public void Update(bool isHovering, bool isPressed) {
|
||||
_rect?.Fill = isHovering ? Brushes.LightGray : Brushes.WhiteSmoke;
|
||||
_rect?.Fill = PamhagenBrushes.ForFillState(FillState,
|
||||
isHovering && isPressed ? Brushes.DarkGray :
|
||||
isHovering ? Brushes.LightGray :
|
||||
Brushes.WhiteSmoke
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,21 +13,22 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public double CenterY { get; set; }
|
||||
public double BottomY => CenterY + HEIGHT / 2;
|
||||
public string Label { get; set; }
|
||||
public bool IsFilled => CallbackIsFilled();
|
||||
public FillState FillState => CallbackFillState();
|
||||
public bool IsFilled => FillState != FillState.Empty;
|
||||
public ISet<IEdge> Inputs { get; init; }
|
||||
public ISet<IEdge> Outputs { get; init; }
|
||||
|
||||
protected Func<bool> CallbackIsFilled;
|
||||
protected Func<FillState> CallbackFillState;
|
||||
|
||||
private Shape? _inner;
|
||||
private Shape? _outer;
|
||||
private TextBlock? _text;
|
||||
|
||||
public Trough(string label, double x, double y, Func<bool> cbFilled) {
|
||||
public Trough(string label, double x, double y, Func<FillState> cbFillState) {
|
||||
CenterX = x;
|
||||
CenterY = y;
|
||||
Label = label;
|
||||
CallbackIsFilled = cbFilled;
|
||||
CallbackFillState = cbFillState;
|
||||
Inputs = new HashSet<IEdge>();
|
||||
Outputs = new HashSet<IEdge>();
|
||||
}
|
||||
@@ -45,7 +46,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
};
|
||||
_text = new() {
|
||||
Text = Label,
|
||||
FontSize = 12,
|
||||
FontSize = 14,
|
||||
Width = WIDTH,
|
||||
TextAlignment = TextAlignment.Center,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
@@ -55,7 +56,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
_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);
|
||||
_text.SetValue(Canvas.TopProperty, CenterY - 10);
|
||||
canvas.Children.Add(_outer);
|
||||
canvas.Children.Add(_inner);
|
||||
canvas.Children.Add(_text);
|
||||
@@ -66,7 +67,11 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
}
|
||||
|
||||
public void Update(bool isHovering, bool isPressed) {
|
||||
_inner?.Fill = isHovering ? Brushes.LightGray : Brushes.WhiteSmoke;
|
||||
_inner?.Fill = PamhagenBrushes.ForFillState(FillState,
|
||||
isHovering && isPressed ? Brushes.DarkGray :
|
||||
isHovering ? Brushes.LightGray :
|
||||
Brushes.WhiteSmoke
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,10 +66,10 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
|
||||
public void Update(bool isHovering, bool isPressed) {
|
||||
_circle?.Fill =
|
||||
IsLocked && !WantOpen && !IsOpen ? Brushes.Orange :
|
||||
IsLocked && !WantOpen && IsOpen ? Brushes.Red :
|
||||
IsLocked && WantOpen && !IsOpen ? Brushes.Yellow :
|
||||
IsLocked && WantOpen && IsOpen ? Brushes.Green :
|
||||
IsLocked && !WantOpen && !IsOpen ? PamhagenBrushes.DimOrange :
|
||||
IsLocked && !WantOpen && IsOpen ? PamhagenBrushes.Red :
|
||||
IsLocked && WantOpen && !IsOpen ? PamhagenBrushes.Yellow :
|
||||
IsLocked && WantOpen && IsOpen ? PamhagenBrushes.Green :
|
||||
Highlight ?? (isHovering ? Brushes.LightGray : Brushes.DarkGray);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user