Resolved save load issues for the nodes by chaning the unique node id to guid
Some checks failed
Build / build (push) Has been cancelled
Some checks failed
Build / build (push) Has been cancelled
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System.Diagnostics;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@@ -85,7 +86,7 @@ namespace Nodify.Calculator
|
|||||||
Operations.WhenAdded(x =>
|
Operations.WhenAdded(x =>
|
||||||
{
|
{
|
||||||
x.Input.WhenRemoved(RemoveConnection);
|
x.Input.WhenRemoved(RemoveConnection);
|
||||||
if (!IsLoading) x.NodeId = (Operations.Count + 1).ToString();
|
if (!IsLoading) x.NodeId = Guid.NewGuid().ToString("N");
|
||||||
Debug.WriteLine($"Currently adding the node with node id : {x.NodeId} , Title : {x.Title}");
|
Debug.WriteLine($"Currently adding the node with node id : {x.NodeId} , Title : {x.Title}");
|
||||||
if (x is CalculatorInputOperationViewModel ci)
|
if (x is CalculatorInputOperationViewModel ci)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,12 +16,11 @@ namespace Nodify.Calculator
|
|||||||
var operations = calculator.Operations;
|
var operations = calculator.Operations;
|
||||||
var connections = calculator.Connections;
|
var connections = calculator.Connections;
|
||||||
|
|
||||||
// Ensure all nodes have IDs
|
// Ensure all nodes have unique IDs
|
||||||
int idCounter = 1;
|
|
||||||
foreach (var op in operations)
|
foreach (var op in operations)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(op.NodeId))
|
if (string.IsNullOrEmpty(op.NodeId))
|
||||||
op.NodeId = $"node_{idCounter++}";
|
op.NodeId = Guid.NewGuid().ToString("N");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serialize nodes
|
// Serialize nodes
|
||||||
|
|||||||
Reference in New Issue
Block a user