Implement path selection
This commit is contained in:
@@ -62,7 +62,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
foreach (var o in start.Outputs) {
|
||||
if (o.End == end) {
|
||||
return new(start, [(o, o.End)]);
|
||||
} else if (!valid(o.End)) {
|
||||
} else if (!valid(o.End) || (!o.IsTwoWay && o.End == start) || (o.IsTwoWay && o.End == start)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -91,13 +91,13 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
}
|
||||
}
|
||||
|
||||
public ISet<INode> Update(double x, double y) {
|
||||
public ISet<INode> Update(double x, double y, bool down) {
|
||||
HashSet<INode> hover = new();
|
||||
foreach (var e in Edges) {
|
||||
e.Update(x, y);
|
||||
e.Update();
|
||||
}
|
||||
foreach (var n in Nodes) {
|
||||
if (n.Update(x, y)) {
|
||||
if (n.Update(x, y, down)) {
|
||||
hover.Add(n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public Brush? Highlight { get; set; }
|
||||
|
||||
public void Draw(Canvas canvas);
|
||||
public bool Update(double x, double y);
|
||||
|
||||
public void Update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public ISet<IEdge> Outputs { get; }
|
||||
|
||||
public void Draw(Canvas canvas);
|
||||
public bool Update(double x, double y);
|
||||
public bool Update(double x, double y, bool down);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,5 +2,6 @@
|
||||
public interface ISource : INode {
|
||||
public double BottomY { get; }
|
||||
public bool IsFilled { get; }
|
||||
public bool IsSelected { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,10 +76,9 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
canvas.Children.Add(_inner2);
|
||||
}
|
||||
|
||||
public bool Update(double x, double y) {
|
||||
public void Update() {
|
||||
_inner1?.Stroke = Highlight ?? Brushes.DarkGray;
|
||||
_inner2?.Stroke = Highlight ?? Brushes.DarkGray;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,11 +86,10 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
canvas.Children.Add(_inner2);
|
||||
}
|
||||
|
||||
public bool Update(double x, double y) {
|
||||
public void Update() {
|
||||
_inner1?.Stroke = Highlight ?? Brushes.DarkGray;
|
||||
_inner2?.Stroke = Highlight ?? Brushes.DarkGray;
|
||||
_hopper?.Fill = Highlight ?? Brushes.DarkGray;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,10 +65,9 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
canvas.Children.Add(_inner2);
|
||||
}
|
||||
|
||||
public bool Update(double x, double y) {
|
||||
public void Update() {
|
||||
_inner1?.Stroke = Highlight ?? Brushes.DarkGray;
|
||||
_inner2?.Stroke = Highlight ?? Brushes.DarkGray;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
canvas.Children.Add(_rect);
|
||||
}
|
||||
|
||||
public bool Update(double x, double y) {
|
||||
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;
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
canvas.Children.Add(_text);
|
||||
}
|
||||
|
||||
public bool Update(double x, double y) {
|
||||
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;
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
canvas.Children.Add(_text);
|
||||
}
|
||||
|
||||
public bool Update(double x, double y) {
|
||||
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;
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public string Label { get; set; }
|
||||
public bool IsFull => CallbackIsFull();
|
||||
public bool IsFilled => CallbackIsFilled();
|
||||
public bool IsSelected { get; set; }
|
||||
|
||||
public ISet<IEdge> Inputs { get; init; }
|
||||
public ISet<IEdge> Outputs { get; init; }
|
||||
@@ -62,9 +63,9 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
canvas.Children.Add(_text);
|
||||
}
|
||||
|
||||
public bool Update(double x, double y) {
|
||||
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;
|
||||
_rect?.Fill = IsSelected ? Brushes.LightGray : hover ? Brushes.LightGray : Brushes.WhiteSmoke;
|
||||
return hover;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,28 @@
|
||||
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 Trough : INode, ISource {
|
||||
|
||||
public const double WIDTH = 100;
|
||||
public const double HEIGHT = 60;
|
||||
|
||||
public double CenterX { get; set; }
|
||||
public double CenterY { get; set; }
|
||||
public double BottomY => CenterY;
|
||||
public double BottomY => CenterY + HEIGHT / 2;
|
||||
public string Label { get; set; }
|
||||
public bool IsFilled => CallbackIsFilled();
|
||||
public bool IsSelected { get; set; }
|
||||
public ISet<IEdge> Inputs { get; init; }
|
||||
public ISet<IEdge> Outputs { get; init; }
|
||||
|
||||
protected Func<bool> CallbackIsFilled;
|
||||
|
||||
private Shape? _rect;
|
||||
private TextBlock? _text;
|
||||
|
||||
public Trough(string label, double x, double y, Func<bool> cbFilled) {
|
||||
CenterX = x;
|
||||
CenterY = y;
|
||||
@@ -23,11 +33,32 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
}
|
||||
|
||||
public void Draw(Canvas canvas) {
|
||||
|
||||
_rect = new Rectangle() {
|
||||
Width = WIDTH,
|
||||
Height = HEIGHT,
|
||||
Stroke = Brushes.Black,
|
||||
StrokeThickness = 2,
|
||||
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(_rect);
|
||||
canvas.Children.Add(_text);
|
||||
}
|
||||
|
||||
public bool Update(double x, double y) {
|
||||
return false;
|
||||
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 = IsSelected ? Brushes.LightGray : hover ? Brushes.LightGray : Brushes.WhiteSmoke;
|
||||
return hover;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,9 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
public double CenterX { get; set; }
|
||||
public double CenterY { get; set; }
|
||||
public string Label { get; set; }
|
||||
public Brush? Highlight { get; set; }
|
||||
|
||||
public bool IsLocked { get; set; }
|
||||
public bool IsOpen => CallbackIsOpen();
|
||||
public bool WantOpen => CallbackWantOpen();
|
||||
public ISet<IEdge> Inputs { get; init; }
|
||||
@@ -57,9 +59,9 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
|
||||
canvas.Children.Add(_text);
|
||||
}
|
||||
|
||||
public bool Update(double x, double y) {
|
||||
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.DarkGray;
|
||||
_circle?.Fill = IsLocked ? Brushes.Red : Highlight ?? (hover ? Brushes.LightGray : Brushes.DarkGray);
|
||||
return hover;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user