private void LoadTemplates() { this.treeViewTemplates.Nodes.Clear(); DefaultSettings settings = new DefaultSettings(); string defaultTemplatePath = settings.DefaultTemplateDirectory; string exePath = Directory.GetCurrentDirectory(); if (!Directory.Exists(defaultTemplatePath)) { defaultTemplatePath = exePath; } ArrayList templates = new ArrayList(); DirectoryInfo rootInfo = new DirectoryInfo(defaultTemplatePath); buildChildren(rootInfo, templates); RootTreeNode rootNode = new RootTreeNode("Zeus Templates by Namespace"); this.treeViewTemplates.Nodes.Add(rootNode); foreach (ZeusTemplate template in templates) { if (template.NamespacePathString.Trim() == string.Empty) { rootNode.AddSorted(new TemplateTreeNode(template)); } else { SortedTreeNode parentNode = rootNode; foreach (string ns in template.NamespacePath) { bool isFound = false; foreach (SortedTreeNode tmpNode in parentNode.Nodes) { if (tmpNode.Text == ns) { parentNode = tmpNode; isFound = true; break; } } if (!isFound) { FolderTreeNode ftn = new FolderTreeNode(ns); parentNode.AddSorted(ftn); parentNode = ftn; } } parentNode.AddSorted(new TemplateTreeNode(template)); } } rootNode.Expand(); }
private void LoadTemplatesByFile() { this.treeViewTemplates.Nodes.Clear(); DefaultSettings settings = new DefaultSettings(); string defaultTemplatePath = settings.DefaultTemplateDirectory; string exePath = Directory.GetCurrentDirectory(); if (!Directory.Exists(defaultTemplatePath)) { defaultTemplatePath = exePath; } ArrayList templates = new ArrayList(); DirectoryInfo rootInfo = new DirectoryInfo(defaultTemplatePath); RootTreeNode rootNode = new RootTreeNode("Zeus Templates by File"); this.treeViewTemplates.Nodes.Add(rootNode); buildChildren(rootNode, rootInfo); rootNode.Expand(); }