public bool LoadProjectFile(string fileName)
        {
            if (!CloseAllTabs())
            {
                return(false);
            }

            _ProjectTree.Nodes.Clear();
            ProjectFileName = fileName;

            LoadProjectImageList();

            XmlTextReader reader = null;

            try
            {
                // disabling re-drawing of treeview till all nodes are added
                _ProjectTree.BeginUpdate();
                reader = new XmlTextReader(fileName);

                ProjectTreeNode parentNode = null;

                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        if (reader.Name == "node")
                        {
                            ProjectTreeNode newNode        = new ProjectTreeNode();
                            bool            isEmptyElement = reader.IsEmptyElement;

                            // loading node attributes.
                            int attributeCount = reader.AttributeCount;
                            if (attributeCount > 0)
                            {
                                for (int i = 0; i < attributeCount; i++)
                                {
                                    reader.MoveToAttribute(i);
                                    SetAttributeValue(newNode, reader.Name, reader.Value);
                                }
                            }

                            if (newNode.NodeType == ProjectTreeNode.NodeTypes.Invalid)
                            {
                                newNode.NodeType = ProjectTreeNode.DetermineNodeType(Path.GetExtension(newNode.Text));
                            }

                            // add new node to Parent Node or TreeView.
                            if (parentNode != null)
                            {
                                parentNode.Nodes.Add(newNode);
                            }
                            else
                            {
                                newNode.Text = Path.GetFileNameWithoutExtension(newNode.Text);
                                _ProjectTree.Nodes.Add(newNode);
                            }

                            // making current node 'ParentNode' if its not empty.
                            if (!isEmptyElement)
                            {
                                parentNode = newNode;
                            }
                        }
                    }
                    // moving up to in TreeView if end tag is encountered.
                    else if (reader.NodeType == XmlNodeType.EndElement)
                    {
                        if (reader.Name == "node")
                        {
                            parentNode = (ProjectTreeNode)parentNode.Parent;
                        }
                    }
                    else if (reader.NodeType == XmlNodeType.XmlDeclaration)
                    { //Ignore Xml Declaration.
                    }
                    else if (reader.NodeType == XmlNodeType.None)
                    {
                        return(false);
                    }
                    else if (reader.NodeType == XmlNodeType.Text)
                    {
                        parentNode.Nodes.Add(reader.Value);
                    }
                }
            }
            finally
            {
                // enabling redrawing of treeview after all nodes are added.
                _ProjectTree.EndUpdate();
                reader.Close();
            }

            if (_ProjectTree.Nodes.Count > 0)
            {
                _ProjectTree.Nodes[0].Expand();
            }

            return(true);
        }
        private void _ProjectTree_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            if (!IsProjectOpen())
            {
                return;
            }

            try
            {
                if (e.Label == null) //Determine if lable has changed.
                {
                    e.CancelEdit = true;
                    return;
                }

                if (e.Label == null || e.Label.Length == 0)
                {
                    e.CancelEdit = true;
                    MessageBox.Show("The object cannot be empty.");
                    return;
                }

                ProjectTreeNode node = (ProjectTreeNode)e.Node;
                if (!CloseAffectedProjectTabs((ProjectTreeNode)e.Node))
                {
                    e.CancelEdit = true;
                    return;
                }

                ProjectTreeNode projectNode = GetProjectNode();
                string          projectPath = Path.GetDirectoryName(ProjectFileName);
                string          oldLineage  = (projectPath + "\\" + node.FileLineage()).Replace("\\\\", "\\");
                //string nodeText = (e.Label == null || e.Label.Length == 0) ? e.Node.Text : e.Label;
                string nodeText = e.Label;

                if (!Path.HasExtension(nodeText))
                {
                    if (Path.HasExtension(e.Node.Text))
                    {
                        nodeText = nodeText + Path.GetExtension(e.Node.Text);
                    }
                }

                string newLineage = node.Parent == null ? null : (projectPath + "\\" + ((ProjectTreeNode)node.Parent).FileLineage() + "\\" + nodeText).Replace("\\\\", "\\");

                if (node.BasicNodeType == ProjectTreeNode.BasicNodeTypes.Folder)
                {
                    if (Directory.Exists(oldLineage))
                    {
                        Directory.Move(oldLineage, newLineage);
                    }
                    else
                    {
                        Directory.CreateDirectory(newLineage);
                    }
                }
                else if (node.BasicNodeType == ProjectTreeNode.BasicNodeTypes.File)
                {
                    if (System.IO.File.Exists(oldLineage))
                    {
                        System.IO.File.Move(oldLineage, newLineage);
                    }
                    node.NodeType = ProjectTreeNode.DetermineNodeType(nodeText);
                }

                e.CancelEdit = true; //Were going to change the text manually (below) cancel the automatic update.
                e.Node.Text  = nodeText;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                e.CancelEdit = true;
            }

            SaveProjectFile();
        }