From d80132b87653cd3beeecfd17099972c1e8f5f6d6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Mar 2026 02:03:04 +0000 Subject: [PATCH] Address code review feedback: extract constants, improve self-connection check, fix comment Co-authored-by: LoogLong <86428208+LoogLong@users.noreply.github.com> --- FModel/ViewModels/AnimGraphViewModel.cs | 18 ++++++++++++------ FModel/Views/AnimGraphViewer.xaml.cs | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/FModel/ViewModels/AnimGraphViewModel.cs b/FModel/ViewModels/AnimGraphViewModel.cs index fd133123..6b85b367 100644 --- a/FModel/ViewModels/AnimGraphViewModel.cs +++ b/FModel/ViewModels/AnimGraphViewModel.cs @@ -40,6 +40,11 @@ public class AnimGraphConnection public class AnimGraphViewModel { + private const int GridColumns = 4; + private const int NodeHorizontalSpacing = 300; + private const int NodeVerticalSpacing = 200; + private const int MaxPropertyValueDisplayLength = 100; + public string PackageName { get; set; } = string.Empty; public List Nodes { get; } = []; public List Connections { get; } = []; @@ -87,8 +92,8 @@ public class AnimGraphViewModel { Name = propName, ExportType = structType, - NodePosX = nodeIndex % 4 * 300, - NodePosY = nodeIndex / 4 * 200 + NodePosX = nodeIndex % GridColumns * NodeHorizontalSpacing, + NodePosY = nodeIndex / GridColumns * NodeVerticalSpacing }; // Try to extract property values from the CDO @@ -146,7 +151,7 @@ public class AnimGraphViewModel break; default: // Store additional properties for display in tooltip - if (value.Length <= 100) + if (value.Length <= MaxPropertyValueDisplayLength) node.AdditionalProperties[name] = value; break; } @@ -229,11 +234,12 @@ public class AnimGraphViewModel return; var targetPropName = animNodeProps[linkId].name; - if (!nodeByName.TryGetValue(targetPropName, out var targetNode)) - return; // Avoid self-connections - if (sourceNode == targetNode) return; + if (targetPropName == sourceNode.Name) return; + + if (!nodeByName.TryGetValue(targetPropName, out var targetNode)) + return; vm.Connections.Add(new AnimGraphConnection { diff --git a/FModel/Views/AnimGraphViewer.xaml.cs b/FModel/Views/AnimGraphViewer.xaml.cs index a9823ddf..1f23287c 100644 --- a/FModel/Views/AnimGraphViewer.xaml.cs +++ b/FModel/Views/AnimGraphViewer.xaml.cs @@ -64,7 +64,7 @@ public partial class AnimGraphViewer DrawNode(node); } - // Draw connection lines with actual pin positions + // Draw connection lines between pin positions foreach (var conn in _viewModel.Connections) { DrawConnectionLine(conn);