Add Rebler
This commit is contained in:
@@ -32,6 +32,9 @@ namespace PamhagenSysCtrl.Helpers {
|
||||
double t8X = t7X + 80;
|
||||
double t9X = t8X + 80;
|
||||
|
||||
var rebler = new Rebler("Rebler", (mw1X + mw2X) / 2, 100);
|
||||
Nodes.Add(rebler);
|
||||
|
||||
MW1 = new Trough("MW1", mw1X, mpY - 70, () => App.Plant?.FillLevelA1 != FillState.Empty);
|
||||
MW2 = new Trough("MW2", mw2X, mpY - 70, () => App.Plant?.FillLevelA1 != FillState.Empty);
|
||||
var mp1 = new Pump("MP1", mw1X, mpY);
|
||||
|
||||
@@ -106,17 +106,17 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
}
|
||||
}
|
||||
|
||||
public ISet<INode> Update(double x, double y, bool down) {
|
||||
HashSet<INode> hover = new();
|
||||
public ISet<INode> GetHover(double x, double y) {
|
||||
return Nodes.Where(n => n.IsInside(x, y)).ToHashSet();
|
||||
}
|
||||
|
||||
public void Update(ISet<INode> hovering, bool isPressed) {
|
||||
foreach (var e in Edges) {
|
||||
e.Update();
|
||||
}
|
||||
foreach (var n in Nodes) {
|
||||
if (n.Update(x, y, down)) {
|
||||
hover.Add(n);
|
||||
n.Update(hovering.Contains(n), isPressed);
|
||||
}
|
||||
}
|
||||
return hover;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,10 +50,12 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
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 isPresed) {
|
||||
_rect?.Fill = isHovering ? Brushes.LightGray : Brushes.WhiteSmoke;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public ISet<IEdge> Outputs { get; }
|
||||
|
||||
public void Draw(Canvas canvas);
|
||||
public bool Update(double x, double y, bool down);
|
||||
public void Update(bool isHovering, bool isPressed);
|
||||
public bool IsInside(double x, double y);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,10 +81,12 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
canvas.Children.Add(_rect);
|
||||
}
|
||||
|
||||
public bool Update(double x, double y, bool down) {
|
||||
var hover = Math.Abs(x - CenterX) <= SIZE / 2 && Math.Abs(y - CenterY) <= SIZE / 2;
|
||||
_rect?.Stroke = hover ? Brushes.Black : Brushes.Black;
|
||||
return hover;
|
||||
public bool IsInside(double x, double y) {
|
||||
return Math.Abs(x - CenterX) <= SIZE / 2 && Math.Abs(y - CenterY) <= SIZE / 2;
|
||||
}
|
||||
|
||||
public void Update(bool isHovering, bool isPressed) {
|
||||
_rect?.Stroke = isHovering ? Brushes.Black : Brushes.Black;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,10 +59,12 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
canvas.Children.Add(_text);
|
||||
}
|
||||
|
||||
public bool Update(double x, double y, bool down) {
|
||||
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;
|
||||
public bool IsInside(double x, double y) {
|
||||
return Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= DIAMETER / 2;
|
||||
}
|
||||
|
||||
public void Update(bool isHovering, bool isPressed) {
|
||||
_circle?.Fill = isHovering ? Brushes.LightGray : Brushes.WhiteSmoke;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,10 +58,12 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
canvas.Children.Add(_text);
|
||||
}
|
||||
|
||||
public bool Update(double x, double y, bool down) {
|
||||
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;
|
||||
public bool IsInside(double x, double y) {
|
||||
return Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= DIAMETER / 2;
|
||||
}
|
||||
|
||||
public void Update(bool isHovering, bool isPresed) {
|
||||
_circle?.Fill = isHovering ? Brushes.LightGray : Brushes.WhiteSmoke;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public class Rebler : INode {
|
||||
|
||||
public const double WIDTH = 120;
|
||||
public const double HEIGHT = 60;
|
||||
|
||||
public double CenterX { get; set; }
|
||||
public double CenterY { get; set; }
|
||||
public string Label { get; set; }
|
||||
public ISet<IEdge> Inputs { get; init; }
|
||||
public ISet<IEdge> Outputs { get; init; }
|
||||
|
||||
private TextBlock? _text;
|
||||
private Shape? _rect;
|
||||
private Shape? _hopperOuter;
|
||||
private Shape? _hopperInner;
|
||||
private Shape? _bottomInner;
|
||||
private Shape? _bottomOuter;
|
||||
|
||||
public Rebler(string label, double x, double y) {
|
||||
CenterX = x;
|
||||
CenterY = y;
|
||||
Label = label;
|
||||
Inputs = new HashSet<IEdge>();
|
||||
Outputs = new HashSet<IEdge>();
|
||||
}
|
||||
|
||||
public void Draw(Canvas canvas) {
|
||||
_rect = new Rectangle() {
|
||||
Width = WIDTH,
|
||||
Height = HEIGHT,
|
||||
Fill = Brushes.WhiteSmoke,
|
||||
Stroke = Brushes.Black,
|
||||
StrokeThickness = 2,
|
||||
};
|
||||
var hx = CenterX + WIDTH / 2 - 10;
|
||||
var top = CenterY - HEIGHT / 2;
|
||||
var h = 15;
|
||||
var w = 25;
|
||||
_hopperOuter = new Polygon() {
|
||||
Points = [new(hx - w, top - h), new(hx, top + 30), new(hx + w, top - h)],
|
||||
Fill = Brushes.Black,
|
||||
};
|
||||
_hopperInner = new Polygon() {
|
||||
Points = [new(hx - w + 2, top - h), new(hx, top + 26), new(hx + w - 2, top - h)],
|
||||
Fill = Brushes.WhiteSmoke,
|
||||
};
|
||||
_text = new() {
|
||||
Text = Label,
|
||||
FontSize = 12,
|
||||
Width = WIDTH,
|
||||
TextAlignment = TextAlignment.Center,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
};
|
||||
_rect.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
|
||||
_rect.SetValue(Canvas.TopProperty, CenterY - HEIGHT / 2);
|
||||
_text.SetValue(Canvas.LeftProperty, CenterX - WIDTH / 2);
|
||||
_text.SetValue(Canvas.TopProperty, CenterY - 8);
|
||||
canvas.Children.Add(_hopperOuter);
|
||||
canvas.Children.Add(_rect);
|
||||
canvas.Children.Add(_hopperInner);
|
||||
canvas.Children.Add(_text);
|
||||
}
|
||||
|
||||
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) {
|
||||
_rect?.Fill = isHovering ? Brushes.LightGray : Brushes.WhiteSmoke;
|
||||
_hopperInner?.Fill = isHovering ? Brushes.LightGray : Brushes.WhiteSmoke;
|
||||
_bottomInner?.Fill = isHovering ? Brushes.LightGray : Brushes.WhiteSmoke;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,10 +62,12 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
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) {
|
||||
_rect?.Fill = isHovering ? Brushes.LightGray : Brushes.WhiteSmoke;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,20 +55,22 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
};
|
||||
_text.SetValue(Canvas.LeftProperty, CenterX - DIAMETER / 2);
|
||||
_text.SetValue(Canvas.TopProperty, CenterY - DIAMETER / 2 + 5);
|
||||
_text.SetValue(Canvas.TopProperty, CenterY - DIAMETER / 2 + 5.5);
|
||||
canvas.Children.Add(_circle);
|
||||
canvas.Children.Add(_text);
|
||||
}
|
||||
|
||||
public bool Update(double x, double y, bool down) {
|
||||
var hover = Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= DIAMETER / 2;
|
||||
public bool IsInside(double x, double y) {
|
||||
return Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= DIAMETER / 2;
|
||||
}
|
||||
|
||||
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 :
|
||||
Highlight ?? (hover ? Brushes.LightGray : Brushes.DarkGray);
|
||||
return hover;
|
||||
Highlight ?? (isHovering ? Brushes.LightGray : Brushes.DarkGray);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace PamhagenSysCtrl.Windows {
|
||||
foreach (var p in Graph.SelectedPaths) {
|
||||
Graph.ColorPipesAdjacientToPath(p, Brushes.Green, Brushes.Orange);
|
||||
}
|
||||
var hover = Graph.Update(pos.X, pos.Y, down);
|
||||
var hover = Graph.GetHover(pos.X, pos.Y);
|
||||
if (_lastSource != null && (hover.Count > 0 || _path.Count > 0)) {
|
||||
List<INode> points = [_lastSource, .. _path];
|
||||
if (hover.Count > 0 && !points.Contains(hover.First())) {
|
||||
@@ -90,7 +90,7 @@ namespace PamhagenSysCtrl.Windows {
|
||||
edge.Highlight = Brushes.Green;
|
||||
}
|
||||
}
|
||||
Graph.Update(pos.X, pos.Y, down);
|
||||
Graph.Update(hover, down);
|
||||
return hover;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user