From 2f532a8536c7b45f41a0b42ff73e31be55f82dd3 Mon Sep 17 00:00:00 2001 From: Ankitkumar Satapara Date: Sat, 18 Apr 2026 18:59:05 +0530 Subject: [PATCH] Added different shapes based on the type of the model or variable types --- .../FunctionOperationViewModel.cs | 12 +++-- .../Operations/OperationFactory.cs | 50 +++++++++++++------ 2 files changed, 43 insertions(+), 19 deletions(-) diff --git a/Examples/Nodify.Calculator/FunctionOperationViewModel.cs b/Examples/Nodify.Calculator/FunctionOperationViewModel.cs index 7d0b98b..750c990 100644 --- a/Examples/Nodify.Calculator/FunctionOperationViewModel.cs +++ b/Examples/Nodify.Calculator/FunctionOperationViewModel.cs @@ -61,13 +61,15 @@ namespace Nodify.Calculator { Title = $"{inp.Name} ({inp.Type})", Shape = ConnectorShape.Circle, - IsInput = false + IsInput = false, + ConnectorColor = System.Drawing.Color.Gold }); // Also add an outer input connector on the function node Input.Add(new ConnectorViewModel { - Title = $"{inp.Name} ({inp.Type})" + Title = $"{inp.Name} ({inp.Type})", + ConnectorColor = System.Drawing.Color.Gold }); } @@ -77,14 +79,16 @@ namespace Nodify.Calculator InnerEnd.Input.Add(new ConnectorViewModel { Title = $"{outp.Name} ({outp.Type})", - Shape = ConnectorShape.Circle + Shape = ConnectorShape.Circle, + ConnectorColor = System.Drawing.Color.Gold }); // Also add an outer output connector on the function node Output.Add(new ConnectorViewModel { Title = $"{outp.Name} ({outp.Type})", - IsInput = false + IsInput = false, + ConnectorColor = System.Drawing.Color.Gold }); } } diff --git a/Examples/Nodify.Calculator/Operations/OperationFactory.cs b/Examples/Nodify.Calculator/Operations/OperationFactory.cs index 70a082c..cd0c2e7 100644 --- a/Examples/Nodify.Calculator/Operations/OperationFactory.cs +++ b/Examples/Nodify.Calculator/Operations/OperationFactory.cs @@ -213,7 +213,7 @@ namespace Nodify.Calculator Operation = info.Operation, Expression = "1 + sin {a} + cos {b}" }; - eo.Output.Add(new ConnectorViewModel()); + eo.Output.Add(new ConnectorViewModel { ConnectorColor = Color.DodgerBlue }); return eo; case OperationType.Calculator: return new CalculatorOperationViewModel @@ -230,7 +230,8 @@ namespace Nodify.Calculator Title = info.Title, Operation = info.Operation }; - o.Output.Add(new ConnectorViewModel()); + o.Output.Add(new ConnectorViewModel { ConnectorColor = Color.DodgerBlue }); + foreach (var ei in input) { ei.ConnectorColor = Color.DodgerBlue; } o.Input.AddRange(input); return o; @@ -265,11 +266,11 @@ namespace Nodify.Calculator IsInput = false }; _o.Output.Add(connectorViewModel2); - _o.Output.Add(new ConnectorViewModel()); + _o.Output.Add(new ConnectorViewModel { ConnectorColor = Color.LimeGreen }); _o.Input.Add(connectorViewModel); foreach (var item in input) { - item.ConnectorColor = Color.GreenYellow; + item.ConnectorColor = Color.LimeGreen; _o.Input.Add(item); } //_o.Input.AddRange(input); @@ -317,7 +318,7 @@ namespace Nodify.Calculator // Add data input connectors foreach (var inp in input) { - inp.ConnectorColor = System.Drawing.Color.Orange; + inp.ConnectorColor = Color.Orange; authOp.Input.Add(inp); } return authOp; @@ -329,7 +330,7 @@ namespace Nodify.Calculator SystemOperationType = info.sysOp }; - if (info.sysOp == SystemOperations.GET_SET && info.IsModelNode) + if (info.sysOp == SystemOperations.GET_SET && info.IsModelNode && !info.IsSimpleVariable) { if (info.Title == "GET") { @@ -403,24 +404,42 @@ namespace Nodify.Calculator sysOp.Input.Add(flowinputnode); sysOp.Output.Add(flowoutputnode); } + // Determine connector shape & color based on system operation type + ConnectorShape dataShape; + System.Drawing.Color dataColor; + if (info.IsModelNode && !info.IsSimpleVariable) + { + dataShape = ConnectorShape.Square; + dataColor = Color.MediumPurple; + } + else if (info.IsSimpleVariable) + { + dataShape = ConnectorShape.Circle; + dataColor = Color.LightGreen; + } + else + { + dataShape = ConnectorShape.Circle; + dataColor = Color.Cyan; + } + foreach (var item in info.Output) { + var isBeginEnd = info.sysOp == SystemOperations.BEGIN || info.sysOp == SystemOperations.END; var out1 = new ConnectorViewModel() { Title = string.IsNullOrEmpty(item) ? "" : item, IsInput = false, - ConnectorColor = Color.DarkRed, - Shape = (info.sysOp == SystemOperations.BEGIN || info.sysOp == SystemOperations.END) ? ConnectorShape.Triangle : ConnectorShape.Circle, + Shape = isBeginEnd ? ConnectorShape.Triangle : dataShape, + ConnectorColor = isBeginEnd ? Color.DarkRed : dataColor, }; - if (out1.Shape != ConnectorShape.Triangle) - { - out1.ConnectorColor = Color.DeepPink; - } sysOp.Output.Add(out1); } foreach (var item in input) { - item.Shape = (info.sysOp == SystemOperations.BEGIN || info.sysOp == SystemOperations.END) ? ConnectorShape.Triangle : ConnectorShape.Circle; + var isBeginEnd = info.sysOp == SystemOperations.BEGIN || info.sysOp == SystemOperations.END; + item.Shape = isBeginEnd ? ConnectorShape.Triangle : dataShape; + item.ConnectorColor = isBeginEnd ? Color.DarkRed : dataColor; sysOp.Input.Add(item); } return sysOp; @@ -435,10 +454,11 @@ namespace Nodify.Calculator { IsInput = false, Shape = ConnectorShape.Circle, - Title = "" + Title = "", + ConnectorColor = Color.DodgerBlue }; op.Output.Add(ccv); - + foreach (var di in input) { di.ConnectorColor = Color.DodgerBlue; } op.Input.AddRange(input); return op; }