public void AddNodeToGrid(NodeWrapper node)
        {
            NodeViewModel nodeToAdd = null;

            //Determine location to place node, bit of a hack
            MainWindow main = Application.Current.MainWindow as MainWindow;
            Point      p    = new Point(main.Width / 2, main.Height / 2);

            if (main.IsNodePopupVisible)
            {
                p = Mouse.GetPosition(main);
            }
            else
            {
                Random r         = new Random();
                int    increment = r.Next(-400, 400);
                p = new Point(p.X + increment, p.Y + increment);
            }


            if (node.TypeOfNode == NodeType.RootNode)
            {
                RootNode n = new RootNode();
                n.NodeName = node.NodeName;

                n.Margin  = new Thickness(p.X, p.Y, 0, 0);
                nodeToAdd = n;
            }

            if (node.TypeOfNode == NodeType.ConditionNode)
            {
                ConditionNode n = new ConditionNode();
                n.NodeName = node.NodeName;

                n.Margin  = new Thickness(p.X, p.Y, 0, 0);
                nodeToAdd = n;
            }


            if (node.TypeOfNode == NodeType.MethodNode)
            {
                DynamicNode n = new DynamicNode();
                n.NodeName = node.NodeName;

                foreach (var arg in node.Arguments)
                {
                    n.AddArgument(arg.ArgTypeString, arg.Name, false, 0, null);
                }

                n.Margin       = new Thickness(p.X, p.Y, 0, 0);
                n.CallingClass = node.CallingClass;
                nodeToAdd      = n;
            }

            if (node.TypeOfNode == NodeType.VariableNode)
            {
                VariableNode n = new VariableNode();
                n.NodeName = node.NodeName;
                n.Type     = node.BaseAssemblyType;

                n.Margin       = new Thickness(p.X, p.Y, 0, 0);
                n.CallingClass = node.CallingClass;
                nodeToAdd      = n;
            }

            if (nodeToAdd != null)
            {
                this.Nodes.Add(nodeToAdd);
                MainViewModel.Instance.LogStatus("Added node " + nodeToAdd.NodeName + " to grid");
            }
            else
            {
                MainViewModel.Instance.LogStatus("Couldn't add node " + node.NodeName + " to grid");
            }

            //Close the node view window
            MainWindow mainWindow = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault();

            mainWindow.HideNodeListCommand.Execute(null);
        }