Skip to content

Commit

Permalink
Apply code preferences, removed unused namespace and use tabs everywh…
Browse files Browse the repository at this point in the history
…ere (#57)
  • Loading branch information
snakex64 authored Nov 22, 2024
1 parent 4325ff8 commit 2bacf05
Show file tree
Hide file tree
Showing 97 changed files with 2,274 additions and 2,457 deletions.
4 changes: 1 addition & 3 deletions src/NodeDev.Blazor.MAUI/Platforms/Windows/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Microsoft.UI.Xaml;

// To learn more about WinUI, the WinUI project structure,
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace NodeDev.Blazor.MAUI.WinUI
Expand Down
4 changes: 1 addition & 3 deletions src/NodeDev.Blazor/Components/DebuggerConsolePanel.razor.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Microsoft.AspNetCore.Components;
using NodeDev.Core;
using System.Diagnostics;
using System.Reactive.Subjects;
using System.Text;


namespace NodeDev.Blazor.Components;
Expand All @@ -29,7 +27,7 @@ protected override void OnInitialized()
base.OnInitialized();

RefreshRequiredDisposable = RefreshRequiredSubject.AcceptThenSample(TimeSpan.FromMilliseconds(100)).Subscribe(_ => InvokeAsync(StateHasChanged));

GraphExecutionChangedDisposable = Project.GraphExecutionChanged.Subscribe(OnGraphExecutionChanged);
}

Expand Down
6 changes: 3 additions & 3 deletions src/NodeDev.Blazor/Components/GraphCanvas.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
using Microsoft.AspNetCore.Components;
using NodeDev.Blazor.DiagramsModels;
using NodeDev.Blazor.NodeAttributes;
using NodeDev.Blazor.Services;
using NodeDev.Blazor.Services.GraphManager;
using NodeDev.Core;
using NodeDev.Core.Class;
using NodeDev.Core.Connections;
using NodeDev.Core.Nodes;
using NodeDev.Core.Types;
using System.Numerics;
using System.Reactive.Linq;
using NodeDev.Core.Class;
using NodeDev.Blazor.Services;
using NodeDev.Blazor.Services.GraphManager;

namespace NodeDev.Blazor.Components;

Expand Down
57 changes: 26 additions & 31 deletions src/NodeDev.Blazor/DiagramsModels/GraphNodeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@
using NodeDev.Blazor.NodeAttributes;
using NodeDev.Core.Connections;
using NodeDev.Core.Nodes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace NodeDev.Blazor.DiagramsModels
{
public class GraphNodeModel : NodeModel
{
internal readonly Node Node;
public class GraphNodeModel : NodeModel
{
internal readonly Node Node;

/// <summary>
/// Set to true by the canvas when the user hit "f2" to edit the node name.
Expand All @@ -23,18 +18,18 @@ public class GraphNodeModel : NodeModel


public GraphNodeModel(Node node) : base(new(node.GetOrAddDecoration<NodeDecorationPosition>(() => new(Vector2.Zero)).X, node.GetOrAddDecoration<NodeDecorationPosition>(() => new(Vector2.Zero)).Y))
{
Node = node;
}
{
Node = node;
}

public GraphPortModel GetPort(Connection connection) => Ports.OfType<GraphPortModel>().First( x=> x.Connection == connection);
public GraphPortModel GetPort(Connection connection) => Ports.OfType<GraphPortModel>().First(x => x.Connection == connection);

internal void OnNodeExecuted(Connection exec)
{

}

internal void OnConnectionPathHighlighted(Connection connection)
internal void OnConnectionPathHighlighted(Connection connection)
{
var port = GetPort(connection);

Expand All @@ -47,7 +42,7 @@ internal void OnConnectionPathHighlighted(Connection connection)
}
}

internal void OnConnectionPathUnhighlighted(Connection connection)
internal void OnConnectionPathUnhighlighted(Connection connection)
{
var port = GetPort(connection);

Expand All @@ -60,23 +55,23 @@ internal void OnConnectionPathUnhighlighted(Connection connection)

internal async Task OnNodeExecuting(Connection exec)
{
var port = GetPort(exec);

foreach (var link in port.Links.OfType<LinkModel>())
{
if(!link.Classes.Contains("executing"))
link.Classes += " executing";

link.Refresh();
}

var currentCount = ++port.ExecutionCount;
await Task.Delay(100);
if (currentCount == port.ExecutionCount)
{
foreach (var link in port.Links.OfType<LinkModel>())
{
link.Classes = link.Classes.Replace(" executing", "");
var port = GetPort(exec);

foreach (var link in port.Links.OfType<LinkModel>())
{
if (!link.Classes.Contains("executing"))
link.Classes += " executing";

link.Refresh();
}

var currentCount = ++port.ExecutionCount;
await Task.Delay(100);
if (currentCount == port.ExecutionCount)
{
foreach (var link in port.Links.OfType<LinkModel>())
{
link.Classes = link.Classes.Replace(" executing", "");
link.Refresh();
}
}
Expand Down
38 changes: 19 additions & 19 deletions src/NodeDev.Blazor/DiagramsModels/GraphPortModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@

namespace NodeDev.Blazor.DiagramsModels;

public class GraphPortModel: PortModel
public class GraphPortModel : PortModel
{
internal readonly Connection Connection;
internal readonly Connection Connection;

internal int ExecutionCount = 0;
internal int ExecutionCount = 0;

internal string PortColor => GraphCanvas.GetTypeShapeColor(Connection.Type, Connection.Parent.TypeFactory);
internal string PortColor => GraphCanvas.GetTypeShapeColor(Connection.Type, Connection.Parent.TypeFactory);

public GraphPortModel(GraphNodeModel parent, Connection connection, bool isInput) : base(parent, isInput ? PortAlignment.Left : PortAlignment.Right)
{
Connection = connection;
}
public GraphPortModel(GraphNodeModel parent, Connection connection, bool isInput) : base(parent, isInput ? PortAlignment.Left : PortAlignment.Right)
{
Connection = connection;
}

public override bool CanAttachTo(ILinkable other)
{
if(!base.CanAttachTo(other))
return false;
public override bool CanAttachTo(ILinkable other)
{
if (!base.CanAttachTo(other))
return false;

if (other is not GraphPortModel otherPort)
return false;

if(Alignment == otherPort.Alignment) // can't plug input to input or output to output
return false;
if (other is not GraphPortModel otherPort)
return false;

return Connection.Type.IsAssignableTo(otherPort.Connection.Type, out _, out _);
}
if (Alignment == otherPort.Alignment) // can't plug input to input or output to output
return false;

return Connection.Type.IsAssignableTo(otherPort.Connection.Type, out _, out _);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ private Point GetCurvePoint(Anchor anchor, double pX, double pY, double cX, doub
if (anchor is SinglePortAnchor spa)
{
PortAlignment portAlignment;
if((isFirstInRoute && first) || (isLastInRoute && !first))
if ((isFirstInRoute && first) || (isLastInRoute && !first))
portAlignment = spa.Port.Alignment;
else if(pX < cX)
else if (pX < cX)
portAlignment = PortAlignment.Right;
else
portAlignment = PortAlignment.Left;
Expand Down
9 changes: 2 additions & 7 deletions src/NodeDev.Blazor/NodeDecorations/NodeDecorationPosition.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
using NodeDev.Core.NodeDecorations;
using NodeDev.Core.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

namespace NodeDev.Blazor.NodeAttributes
{
Expand All @@ -24,7 +19,7 @@ public NodeDecorationPosition(Vector2 position)


private record class SerializedNodeDecoration(float X, float Y);

public string Serialize()
{
return JsonSerializer.Serialize(new SerializedNodeDecoration(X, Y));
Expand All @@ -36,5 +31,5 @@ public static INodeDecoration Deserialize(TypeFactory typeFactory, string Json)

return new NodeDecorationPosition(new(serializedNodeDecoration.X, serializedNodeDecoration.Y));
}
}
}
}
5 changes: 1 addition & 4 deletions src/NodeDev.Blazor/Services/DebuggedPathService.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@

using Microsoft.AspNetCore.Components;
using NodeDev.Core;
using NodeDev.Core;
using NodeDev.Core.Connections;
using NodeDev.Core.Nodes;
using static MudBlazor.Defaults;

namespace NodeDev.Blazor.Services;

Expand Down
Loading

0 comments on commit 2bacf05

Please sign in to comment.