private void AddChildrenToTreeViewItem(ProjectBrowserItem source, TreeViewItem target)
 {
     foreach (ProjectBrowserItem child in source.Items)
     {
         var newChild = new TreeViewItem();
         newChild.Header     = child.Header;
         newChild.Tag        = child.Tag;
         newChild.IsExpanded = true;
         AddChildrenToTreeViewItem(child, newChild);
         target.Items.Add(newChild);
     }
 }
        public ProjectBrowserContent(ICctsRepository repo)
        {
            var map = new Hashtable();

            rootItem        = new ProjectBrowserItem();
            rootItem.Header = "Current Project";
            foreach (var bLib in repo.GetBLibraries())
            {
                var item = new ProjectBrowserItem();
                item.Header = bLib.Name + " <bLibrary>";
                item.Tag    = bLib;
                rootItem.Items.Add(item);
                map.Add(bLib, item);
            }
            foreach (var lib in repo.GetAllLibraries())
            {
                if (lib is IBdtLibrary)
                {
                    var temp = new ProjectBrowserItem();
                    var libr = (IBdtLibrary)lib;
                    temp.Header = libr.Name + " <BDTLibrary>";
                    temp.Tag    = libr;
                    ((ProjectBrowserItem)map[libr.BLibrary]).Items.Add(temp);
                }
                if (lib is IBieLibrary)
                {
                    var temp = new ProjectBrowserItem();
                    var libr = (IBieLibrary)lib;
                    temp.Header = libr.Name + " <BIELibrary>";
                    temp.Tag    = libr;
                    ((ProjectBrowserItem)map[libr.BLibrary]).Items.Add(temp);
                }
                if (lib is ICcLibrary)
                {
                    var temp = new ProjectBrowserItem();
                    var libr = (ICcLibrary)lib;
                    temp.Header = libr.Name + " <CCibrary>";
                    temp.Tag    = libr;
                    ((ProjectBrowserItem)map[libr.BLibrary]).Items.Add(temp);
                }
                if (lib is ICdtLibrary)
                {
                    var temp = new ProjectBrowserItem();
                    var libr = (ICdtLibrary)lib;
                    temp.Header = libr.Name + " <CDTLibrary>";
                    temp.Tag    = libr;
                    ((ProjectBrowserItem)map[libr.BLibrary]).Items.Add(temp);
                }
                if (lib is IDocLibrary)
                {
                    var temp = new ProjectBrowserItem();
                    var libr = (IDocLibrary)lib;
                    temp.Header = libr.Name + " <DOCLibrary>";
                    temp.Tag    = libr;
                    ((ProjectBrowserItem)map[libr.BLibrary]).Items.Add(temp);
                }
                if (lib is IEnumLibrary)
                {
                    var temp = new ProjectBrowserItem();
                    var libr = (IEnumLibrary)lib;
                    temp.Header = libr.Name + " <ENUMLibrary>";
                    temp.Tag    = libr;
                    ((ProjectBrowserItem)map[libr.BLibrary]).Items.Add(temp);
                }
                if (lib is IPrimLibrary)
                {
                    var temp = new ProjectBrowserItem();
                    var libr = (IPrimLibrary)lib;
                    temp.Header = libr.Name + " <PRIMLibrary>";
                    temp.Tag    = libr;
                    ((ProjectBrowserItem)map[libr.BLibrary]).Items.Add(temp);
                }
            }
        }