Exemplo n.º 1
0
 //CTOR
 public ShapeNode(string name)
 {
     _transformNode = new TransformNode(name);
     _transformNode.SetShape(this);
     Name = _transformNode.Name + "Shape";
     _shapes.Add(this);
 }
Exemplo n.º 2
0
        public static void Group(TransformNode nodeA, TransformNode nodeB)
        {
            var groupNode = new TransformNode("Group");

            nodeA.SetParent(groupNode);
            nodeB.SetParent(groupNode);
        }
Exemplo n.º 3
0
        public override string Process(string[] args)
        {
            var output = string.Empty;

            if (args.Length == 3)
            {
                var child  = TransformNode.Find(args[1]) as TransformNode;
                var parent = TransformNode.Find(args[2]) as TransformNode;
                if (child != null && parent != null)
                {
                    if (child.FindNode(parent.Name) == null)
                    {
                        child.SetParent(parent);
                    }
                    else
                    {
                        output =
                            "Cannot set parent as a child to the specified child, because the child is already a child of the parent";
                    }
                }
                else
                {
                    output = "Parenting failed. Could not find one, or both nodes.";
                }
            }
            else
            {
                output = "you must specify two nodes";
            }

            return(output);
        }
Exemplo n.º 4
0
        public override string Process(string[] args)
        {
            string output = string.Empty;

            if (args.Length == 2)
            {
                var n = TransformNode.Find(args[1]) as TransformNode;
                if (n != null)
                {
                    Console.WriteLine(n);
                    n.ShowTree();
                }

                else
                {
                    output = "invalid node specified: " + args[1];
                }
            }

            else
            {
                Console.WriteLine("Scene");
                TransformNode.ShowAll();
            }


            return(output);
        }
Exemplo n.º 5
0
        public override string Process(string[] args)
        {
            var output = string.Empty;

            if (args.Length == 3)
            {
                var nOld = TransformNode.Find(args[1]);
                if (nOld != null)
                {
                    if (TransformNode.Find(args[2]) == null)
                    {
                        nOld.Name = args[2];
                    }
                    else
                    {
                        output = "target name already exists: " + args[2];
                    }
                }
                else
                {
                    output = "node not found";
                }
            }
            else
            {
                output = "an old name and new name must be specified";
            }

            return(output);
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            var a = new TransformNode("a");
            var b = new TransformNode("b");
            var c = new TransformNode("c");
            var d = new TransformNode("d");
            var e = new TransformNode("e");
            var f = new TransformNode("f");
            var g = new TransformNode("g");
            var h = new TransformNode("h");

            b.SetParent(a);
            c.SetParent(b);
            e.SetParent(d);
            f.SetParent(d);
            g.SetParent(d);
            h.SetParent(f);

            CommandManager.ProcessCommand("ls");

            while (!CommandManager.DoneRunning)
            {
                Console.Write(":");
                CommandManager.ProcessCommand(Console.ReadLine());
            }
        }
Exemplo n.º 7
0
        public override string Process(string[] args)
        {
            var output = string.Empty;

            if (args.Length == 2)
            {
                var n = TransformNode.Find(args[1]) as TransformNode;
                n?.RemoveNode();
                if (n == null)
                {
                    output = "node not found: " + args[1];
                }
            }
            else
            {
                output = "invalid delete command. enter a single node to delete";
            }


            return(output);
        }
Exemplo n.º 8
0
        //Methods
        public void SetParent(TransformNode parent)
        {
            //remove from old parent's children list
            if (_parent == null)
            {
                _rootNodes.Remove(this);
            }
            else
            {
                _parent._children.Remove(this);
            }

            //assign new parent
            _parent = parent;
            if (parent == null)
            {
                _rootNodes.Add(this);
            }
            else
            {
                _parent._children.Add(this);
            }
        }
Exemplo n.º 9
0
        public override string Process(string[] args)
        {
            var output = string.Empty;

            if (args.Length == 2)
            {
                var node = TransformNode.Find(args[1]) as TransformNode;
                if (node != null)
                {
                    node.SetParent(null);
                }
                else
                {
                    output = "Node not found: " + node;
                }
            }
            else
            {
                output = "you must specify a single node";
            }

            return(output);
        }
Exemplo n.º 10
0
        public override string Process(string[] args)
        {
            var output = string.Empty;

            if (args.Length == 3)
            {
                var n1 = TransformNode.Find(args[1]) as TransformNode;
                var n2 = TransformNode.Find(args[2]) as TransformNode;
                if (n1 != null && n2 != null)
                {
                    TransformNode.Group(n1, n2);
                }
                else
                {
                    output = "one or both nodes are not found";
                }
            }
            else if (args.Length == 2)
            {
                var n1 = TransformNode.Find(args[1]) as TransformNode;
                if (n1 != null)
                {
                    TransformNode.Group(n1);
                }
                else
                {
                    output = "the node specified is not valid";
                }
            }
            else
            {
                output = "you must specify 1, or 2 nodes in order to group";
            }

            return(output);
        }