public async Task<bool> RemoveNode(LiteGraph.Node node) { return await Task.Run(() => { if (engine == null) return false; Nodes.Node oldNode = engine.GetNode(node.id); if (oldNode == null) { engine.LogEngineError($"Can`t remove node [{node.id}]. Does not exist."); return false; } if (oldNode.GetNodeOptions().ProtectedAccess) { if (!User.HasClaim(x => x.Type == UserClaims.EditorProtectedAccess)) { engine.LogEngineError( $"Can`t remove node [{oldNode.Category}/{oldNode.Type}]. No permissions for protected access."); return false; } } engine.RemoveNode(oldNode); return true; }); }
public async Task<bool> UpdateNode(LiteGraph.Node node) { return await Task.Run(() => { if (engine == null) return false; Nodes.Node oldNode = engine.GetNode(node.id); if (oldNode == null) { engine.LogEngineError($"Can`t update node [{node.id}]. Does not exist."); return false; } if (oldNode.Position == null || oldNode.Size == null || oldNode.Position.X != node.pos[0] || oldNode.Position.Y != node.pos[1] || oldNode.Size.Width != node.size[0] || oldNode.Size.Height != node.size[1]) { if (node.pos != null) oldNode.Position = new Position { X = node.pos[0], Y = node.pos[1] }; if (node.size != null) oldNode.Size = new Size { Width = node.size[0], Height = node.size[1] }; engine.UpdateNodeInEditor(oldNode); engine.UpdateNodeInDb(oldNode); } return true; }); }
public async Task<bool> AddNode(LiteGraph.Node node) { return await Task.Run(() => { if (engine == null) return false; string type = node.properties["ObjectType"]; string assemblyName = node.properties["Assembly"]; Nodes.Node newNode = CreateNode(type, assemblyName); if (newNode == null) { engine.LogEngineError($"Can`t create node [{node.properties["ObjectType"]}]. Type does not exist."); return false; } if (newNode.GetNodeOptions().ProtectedAccess) { if (!User.HasClaim(x => x.Type == UserClaims.EditorProtectedAccess)) { engine.LogEngineError( $"Can`t create node [{node.properties["ObjectType"]}]. No permissions for protected access."); return false; } } newNode.Position = new Position { X = node.pos[0], Y = node.pos[1] }; if (node.size.Length == 2) newNode.Size = new Size { Width = node.size[0], Height = node.size[1] }; //newNode.Id = node.id; newNode.PanelId = node.panel_id ?? MAIN_PANEL_ID; engine.AddNode(newNode); return true; }); }
public async Task<bool> CreateLink(LiteGraph.Link link) { return await Task.Run(() => { if (engine == null) return false; Nodes.Node outNode = SystemController.nodesEngine.GetNode(link.origin_id); Nodes.Node inNode = SystemController.nodesEngine.GetNode(link.target_id); if (outNode == null || inNode == null) { engine.LogEngineError( $"Can`t create link from [{link.origin_id}] to [{link.target_id}]. Does not exist."); return false; } if (outNode.GetNodeOptions().ProtectedAccess || inNode.GetNodeOptions().ProtectedAccess) { if (!User.HasClaim(x => x.Type == UserClaims.EditorProtectedAccess)) { engine.LogEngineError( $"Can`t create link from [{link.origin_id}] to [{link.target_id}]. No permissions for protected access."); return false; } } engine.AddLink(outNode.Outputs[link.origin_slot], inNode.Inputs[link.target_slot]); return true; }); }
public bool UpdateNode(LiteGraph.Node node) { LogicalNode oldNode = engine.GetNode(node.id); oldNode.Position = new Position { X = node.pos[0], Y = node.pos[1] }; oldNode.Size = new Size{ Width = node.size[0], Height = node.size[1] }; engine.UpdateNode(oldNode); return true; }
public bool DeleteNode(LiteGraph.Node node) { LogicalNode oldNode = engine.GetNode(node.id); engine.RemoveNode(oldNode); return true; }
public bool CreateNode(LiteGraph.Node node) { string type = node.properties["objectType"]; var newObject = Activator.CreateInstance("LogicalNodes", type); LogicalNode newNode = (LogicalNode)newObject.Unwrap(); //LogicalNode newNode = newObject as LogicalNode; newNode.Position = new Position { X = node.pos[0], Y = node.pos[1] }; newNode.Size = new Size { Width = node.size[0], Height = node.size[1] }; newNode.Id = node.id; engine.AddNode(newNode); return true; }