Completed the split node functionality
This commit is contained in:
@@ -76,7 +76,7 @@ namespace Nodify.Calculator
|
||||
IsFlowNode = false
|
||||
};
|
||||
splitNode.Input.Add("");
|
||||
splitNode.Output.Add("");
|
||||
// No default output - outputs are added dynamically on connection
|
||||
|
||||
var takeNode = new OperationInfoViewModel()
|
||||
{
|
||||
@@ -330,6 +330,19 @@ namespace Nodify.Calculator
|
||||
SystemOperationType = info.sysOp
|
||||
};
|
||||
|
||||
if (info.sysOp == SystemOperations.SPLIT)
|
||||
{
|
||||
sysOp.Title = info.Title;
|
||||
// Square input to accept model/class objects
|
||||
foreach (var item in input)
|
||||
{
|
||||
item.Shape = ConnectorShape.Square;
|
||||
item.ConnectorColor = Color.MediumPurple;
|
||||
sysOp.Input.Add(item);
|
||||
}
|
||||
return sysOp;
|
||||
}
|
||||
|
||||
if (info.sysOp == SystemOperations.GET_SET && info.IsModelNode && !info.IsSimpleVariable)
|
||||
{
|
||||
if (info.Title == "GET")
|
||||
@@ -345,44 +358,100 @@ namespace Nodify.Calculator
|
||||
var flpath = System.IO.Path.Combine(customModelDir, info.ClassName + ".cs");
|
||||
if (File.Exists(flpath))
|
||||
{
|
||||
//Read all the properties from the file
|
||||
var fileContent = File.ReadAllText(flpath);
|
||||
|
||||
// Parse and analyze properties
|
||||
var properties = GetPropertiesFromClass(fileContent);
|
||||
|
||||
// Print out the extracted properties and their types
|
||||
Console.WriteLine("Properties found:");
|
||||
foreach (var property in properties)
|
||||
{
|
||||
Console.WriteLine($"Property Name: {property.Name}, Type: {property.Type}");
|
||||
info.Output.Add(property.Name);
|
||||
}
|
||||
}
|
||||
|
||||
info.IsFlowNode = true;
|
||||
|
||||
// Build the node with flow connectors first
|
||||
var flTitle = $"{info.Title} {info.ClassName}";
|
||||
sysOp.Title = flTitle;
|
||||
|
||||
// Flow connectors
|
||||
sysOp.Input.Add(new ConnectorViewModel { Title = "", Shape = ConnectorShape.Triangle });
|
||||
sysOp.Output.Add(new ConnectorViewModel { Title = "", Shape = ConnectorShape.Triangle, IsInput = false });
|
||||
|
||||
// Input: Square connector for the class object
|
||||
foreach (var item in input)
|
||||
{
|
||||
item.Shape = ConnectorShape.Square;
|
||||
item.ConnectorColor = Color.MediumPurple;
|
||||
sysOp.Input.Add(item);
|
||||
}
|
||||
|
||||
// Outputs: Circle connectors per property, colored by type
|
||||
foreach (var property in properties)
|
||||
{
|
||||
var propColor = ConnectorViewModel.GetColorForType(property.Type);
|
||||
var propType = property.Type.ToLower();
|
||||
sysOp.Output.Add(new ConnectorViewModel
|
||||
{
|
||||
Title = $"{property.Name} ({property.Type})",
|
||||
IsInput = false,
|
||||
Shape = ConnectorShape.Circle,
|
||||
ConnectorColor = propColor,
|
||||
DataType = propType
|
||||
});
|
||||
}
|
||||
|
||||
return sysOp;
|
||||
}
|
||||
|
||||
info.IsFlowNode = true;
|
||||
}
|
||||
var flTitle = $"{info.Title} {info.ClassName}";
|
||||
sysOp.Title = flTitle;
|
||||
var flTitle2 = $"{info.Title} {info.ClassName}";
|
||||
sysOp.Title = flTitle2;
|
||||
}
|
||||
|
||||
if (info.sysOp == SystemOperations.GET_SET && info.IsSimpleVariable)
|
||||
{
|
||||
var varLabel = $"{info.Title} {info.ClassName} ({info.VariableType})";
|
||||
sysOp.Title = varLabel;
|
||||
var varType = info.VariableType.ToLower();
|
||||
var varColor = ConnectorViewModel.GetColorForType(varType);
|
||||
|
||||
if (info.Title == "GET")
|
||||
{
|
||||
// GET variable: output the value, no flow needed
|
||||
info.Output.Add("Value");
|
||||
info.IsFlowNode = false;
|
||||
|
||||
// Flow connectors not needed, output connector with type color
|
||||
sysOp.Output.Add(new ConnectorViewModel
|
||||
{
|
||||
Title = "Value",
|
||||
IsInput = false,
|
||||
Shape = ConnectorShape.Circle,
|
||||
ConnectorColor = varColor,
|
||||
DataType = varType
|
||||
});
|
||||
|
||||
return sysOp;
|
||||
}
|
||||
else if (info.Title == "SET")
|
||||
{
|
||||
// SET variable: input connector for the value, flow node
|
||||
info.Input.Add("Value");
|
||||
info.IsFlowNode = true;
|
||||
|
||||
// Flow connectors
|
||||
sysOp.Input.Add(new ConnectorViewModel { Title = "", Shape = ConnectorShape.Triangle });
|
||||
sysOp.Output.Add(new ConnectorViewModel { Title = "", Shape = ConnectorShape.Triangle, IsInput = false });
|
||||
|
||||
// Data input with type color
|
||||
sysOp.Input.Add(new ConnectorViewModel
|
||||
{
|
||||
Title = "Value",
|
||||
Shape = ConnectorShape.Circle,
|
||||
ConnectorColor = varColor,
|
||||
DataType = varType
|
||||
});
|
||||
|
||||
return sysOp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,6 +534,8 @@ namespace Nodify.Calculator
|
||||
}
|
||||
}
|
||||
|
||||
public static List<CustomProperty> GetPropertiesFromClassPublic(string classContent) => GetPropertiesFromClass(classContent);
|
||||
|
||||
static List<CustomProperty> GetPropertiesFromClass(string classContent)
|
||||
{
|
||||
// Parse the C# class content using Roslyn
|
||||
@@ -500,7 +571,7 @@ namespace Nodify.Calculator
|
||||
}
|
||||
}
|
||||
|
||||
class CustomProperty // <- Renamed to avoid conflicts with System.Reflection.PropertyInfo
|
||||
public class CustomProperty // <- Renamed to avoid conflicts with System.Reflection.PropertyInfo
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Type { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user