//=====================================================================

        /// <summary>
        /// This loads the tree view with code snippet file entries from the project
        /// </summary>
        private List<EntityReference> LoadCodeSnippetInfo()
        {
            EntityReference snippetFileEntity = null;
            XPathDocument snippets;
            XPathNavigator navSnippets;
            CodeReference cr;

            if(codeSnippets != null)
                return codeSnippets;

            codeSnippets = new List<EntityReference>();

            foreach(var snippetFile in currentProject.ContentFiles(BuildAction.CodeSnippets).OrderBy(f => f.LinkPath))
                try
                {
                    if(File.Exists(snippetFile.FullPath))
                    {
                        snippetFileEntity = new EntityReference
                        {
                            EntityType = EntityType.File,
                            Id = snippetFile.FullPath,
                            Label = Path.GetFileName(snippetFile.FullPath),
                            ToolTip = snippetFile.FullPath
                        };

                        codeSnippets.Add(snippetFileEntity);

                        snippets = new XPathDocument(snippetFile.FullPath);
                        navSnippets = snippets.CreateNavigator();

                        foreach(XPathNavigator nav in navSnippets.Select("examples/item/@id"))
                        {
                            cr = new CodeReference(nav.Value);

                            snippetFileEntity.SubEntities.Add(new EntityReference
                            {
                                EntityType = EntityType.CodeSnippet,
                                Id = cr.Id,
                                Label = cr.Id,
                                ToolTip = cr.Id,
                                Tag = cr
                            });
                        }
                    }

                    snippetFileEntity = null;
                }
                catch(Exception ex)
                {
                    if(snippetFileEntity == null)
                        codeSnippets.Add(new EntityReference
                        {
                            EntityType = EntityType.File,
                            Label = "Unable to load file '" + snippetFile.FullPath +
                                "'.  Reason: " + ex.Message,
                            ToolTip = "Error"
                        });
                    else
                        codeSnippets.Add(new EntityReference
                        {
                            EntityType = EntityType.File,
                            Label = "Unable to load file: " + ex.Message,
                            ToolTip = "Error"
                        });
                }

            if(codeSnippets.Count != 0)
            {
                codeSnippets[0].IsSelected = true;

                if(codeSnippets[0].SubEntities.Count != 0)
                    codeSnippets[0].IsExpanded = true;
            }

            return codeSnippets;
        }
        //=====================================================================
        private void LoadCodeSnippetInfo()
        {
            TreeNode rootNode = null, node;
            XPathDocument snippets;
            XPathNavigator navSnippets;
            CodeReference cr;

            tvEntities.ImageList = ilImages;
            tvEntities.Nodes.Clear();

            if(codeSnippetFiles == null)
                codeSnippetFiles = new FileItemCollection(currentProject,
                    BuildAction.CodeSnippets);

            foreach(FileItem snippetFile in codeSnippetFiles)
                try
                {
                    if(File.Exists(snippetFile.FullPath))
                    {
                        rootNode = tvEntities.Nodes.Add(Path.GetFileName(
                            snippetFile.FullPath));
                        rootNode.ImageIndex = rootNode.SelectedImageIndex =
                            (int)EntityType.CodeEntities;

                        snippets = new XPathDocument(snippetFile.FullPath);
                        navSnippets = snippets.CreateNavigator();

                        foreach(XPathNavigator nav in navSnippets.Select(
                            "examples/item/@id"))
                        {
                            cr = new CodeReference(nav.Value);
                            node = rootNode.Nodes.Add(cr.Id);
                            node.Name = cr.Id;
                            node.Tag = cr;
                            node.ImageIndex = node.SelectedImageIndex =
                                (int)EntityType.CodeSnippets;
                        }
                    }

                    rootNode = null;
                }
                catch(Exception ex)
                {
                    if(rootNode == null)
                        tvEntities.Nodes.Add("Unable to load file '" +
                            snippetFile.FullPath + "'.  Reason: " + ex.Message);
                    else
                        rootNode.Nodes.Add("Unable to load file: " + ex.Message);
                }

            txtFindName.Enabled = true;
            tvEntities.Enabled = true;
            tvEntities.ExpandAll();
        }