Ejemplo n.º 1
0
        public static IVisualNode Create(IGraphController graphController, IStorage storage)
        {
            if (graphController == null || storage == null)
            {
                throw new ArgumentNullException("graphcontroller, storage");
            }

            storage.Seek(12, SeekOrigin.Current); //Skip NodeSignature
            NodeType type = (NodeType)storage.ReadInteger(FieldCode.NodeType);

            storage.Seek(-24, SeekOrigin.Current); //Shift cursor back to the start point of reading NodeSignature
            VisualNode node = null;

            switch (type)
            {
            case NodeType.CodeBlock:
                node = new CodeBlockNode(graphController);
                node.Deserialize(storage);
                break;

            case NodeType.Condensed:
                node = new CondensedNode(graphController);
                node.Deserialize(storage);
                break;

            case NodeType.Driver:
                node = new DriverNode(graphController);
                node.Deserialize(storage);
                break;

            case NodeType.Function:
                node = new FunctionNode(graphController);
                node.Deserialize(storage);
                break;

            case NodeType.Identifier:
                node = new IdentifierNode(graphController);
                node.Deserialize(storage);
                break;

            case NodeType.Property:
                node = new PropertyNode(graphController);
                node.Deserialize(storage);
                break;

            case NodeType.Render:
                node = new RenderNode(graphController);
                node.Deserialize(storage);
                break;

            default:
                throw new ArgumentException("Invalid 'nodeType'");
            }

            return(node);
        }
        private bool HandleCreateRenderNode(GraphCommand command)
        {
            double mouseX = ((double)command.GetArgument(0));
            double mouseY = ((double)command.GetArgument(1));

            RenderNode node = new RenderNode(this, 0);

            this.CreateNodeInternal(node, mouseX, mouseY);
            return(true);
        }
Ejemplo n.º 3
0
        public void TestDeserializeNullException()
        {
            IGraphController graphController = new GraphController(null);
            IStorage storage = null;
            IVisualNode node = new RenderNode(graphController, 1);

            Assert.Throws<ArgumentNullException>(() =>
            {
                node.Deserialize(storage);
            });
        }
Ejemplo n.º 4
0
        public void TestDeserilaizeOperationException()
        {
            IGraphController graphController = new GraphController(null);
            IStorage storage = new BinaryStorage();
            IVisualNode node = new RenderNode(graphController, 1);

            ulong signature = Utilities.MakeEightCC('T', 'E', 'S', 'T', ' ', ' ', ' ', ' ');
            storage.WriteUnsignedInteger(signature, 21);
            storage.Seek(0, SeekOrigin.Begin);

            bool result = node.Deserialize(storage);
            Assert.AreEqual(result, false);
        }
Ejemplo n.º 5
0
        public void TestSerializeDeserialize()
        {
            IGraphController graphController = new GraphController(null);
            IStorage storage = new BinaryStorage();

            IVisualNode node1 = new RenderNode(graphController, 1);
            IVisualNode node2 = new RenderNode(graphController, 1);

            node1.Serialize(storage);
            storage.Seek(0, SeekOrigin.Begin);
            node2.Deserialize(storage);

            Assert.AreEqual(NodeType.Render, node2.VisualType);
            Assert.AreEqual(node1.NodeId, node2.NodeId);
            Assert.AreEqual(true, ((RenderNode)node2).Dirty);
            Assert.AreEqual(((RenderNode)node1).Text, ((RenderNode)node2).Text);
            Assert.AreEqual(((RenderNode)node1).Caption, ((RenderNode)node2).Caption);
            Assert.AreEqual(node1.X, node2.X);
            Assert.AreEqual(node1.Y, node2.Y);
            //Assert.AreEqual(1, node2.GetInputSlots().Length);
            //Assert.AreEqual(0, node2.GetOutputSlots().Length);
        }
Ejemplo n.º 6
0
        public static IVisualNode Create(IGraphController graphController, IStorage storage)
        {
            if (graphController == null || storage == null)
                throw new ArgumentNullException("graphcontroller, storage");

            storage.Seek(12, SeekOrigin.Current); //Skip NodeSignature
            NodeType type = (NodeType)storage.ReadInteger(FieldCode.NodeType);
            storage.Seek(-24, SeekOrigin.Current); //Shift cursor back to the start point of reading NodeSignature
            VisualNode node = null;
            switch (type)
            {
                case NodeType.CodeBlock:
                    node = new CodeBlockNode(graphController);
                    node.Deserialize(storage);
                    break;
                case NodeType.Condensed:
                    node = new CondensedNode(graphController);
                    node.Deserialize(storage);
                    break;
                case NodeType.Driver:
                    node = new DriverNode(graphController);
                    node.Deserialize(storage);
                    break;
                case NodeType.Function:
                    node = new FunctionNode(graphController);
                    node.Deserialize(storage);
                    break;
                case NodeType.Identifier:
                    node = new IdentifierNode(graphController);
                    node.Deserialize(storage);
                    break;
                case NodeType.Property:
                    node = new PropertyNode(graphController);
                    node.Deserialize(storage);
                    break;
                case NodeType.Render:
                    node = new RenderNode(graphController);
                    node.Deserialize(storage);
                    break;
                default:
                    throw new ArgumentException("Invalid 'nodeType'");
            }

            return node;
        }