public void LoadTemplatesByFile() { if (_tree != null) { this._tree.Nodes.Clear(); IdPathHash.Clear(); if (_fsRootNode == null) { DefaultSettings settings = DefaultSettings.Instance; defaultTemplatePath = settings.DefaultTemplateDirectory; string exePath = Directory.GetCurrentDirectory(); if (!Directory.Exists(defaultTemplatePath)) { defaultTemplatePath = exePath; } // ArrayList templates = new ArrayList(); DirectoryInfo rootInfo = new DirectoryInfo(defaultTemplatePath); _fsRootNode = new RootTreeNode("Zeus Templates by File"); #if RUN_AS_NON_ADMIN SortedTreeNode item = new RootTreeNode("System"); _fsRootNode.Nodes.Add(item); _buildChildren(item, rootInfo); item.Expand(); string userTemplates = settings.UserTemplateDirectory; if ((userTemplates != null) && (userTemplates != defaultTemplatePath)) { rootInfo = new DirectoryInfo(userTemplates); item = new RootTreeNode("User:" + Environment.UserName); _fsRootNode.Nodes.Add(item); _buildChildren(item, rootInfo); item.Expand(); } #else _buildChildren(_fsRootNode, rootInfo); #endif _fsRootNode.Expand(); } this._tree.Nodes.Add(_fsRootNode); } }
// for "Zeus Templates by Namespace" public void LoadTemplates() { if (_tree != null) { this._tree.Nodes.Clear(); IdPathHash.Clear(); if (_nsRootNode == null) { DefaultSettings settings = DefaultSettings.Instance; string exePath = Directory.GetCurrentDirectory(); try { defaultTemplatePath = settings.DefaultTemplateDirectory; if (!Directory.Exists(defaultTemplatePath)) { defaultTemplatePath = exePath; } } catch { defaultTemplatePath = exePath; } ArrayList templates = new ArrayList(); DirectoryInfo rootInfo = new DirectoryInfo(defaultTemplatePath); _buildChildren(rootInfo, templates); #if RUN_AS_NON_ADMIN string userTemplates = settings.UserTemplateDirectory; if ((userTemplates != null) && (userTemplates != defaultTemplatePath)) { rootInfo = new DirectoryInfo(userTemplates); _buildChildren(rootInfo, templates); } #endif _nsRootNode = new RootTreeNode("Zeus Templates by Namespace"); string[] nsarray; foreach (ZeusTemplateHeader template in templates) { if (template.Namespace.Trim() == string.Empty) { _nsRootNode.AddSorted(new TemplateTreeNode(template)); } else { SortedTreeNode parentNode = _nsRootNode; nsarray = template.Namespace.Split('.'); foreach (string ns in nsarray) { 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)); } } _nsRootNode.Expand(); } this._tree.Nodes.Add(_nsRootNode); } }
public void LoadTemplatesFromWeb() { if (_tree != null) { IdPathHash.Clear(); this._tree.Nodes.Clear(); if (_wuRootNode == null) { DefaultSettings settings = DefaultSettings.Instance; defaultTemplatePath = settings.DefaultTemplateDirectory; string exePath = Directory.GetCurrentDirectory(); if (!Directory.Exists(defaultTemplatePath)) { defaultTemplatePath = exePath; } //ArrayList templates = new ArrayList(); DirectoryInfo rootInfo = new DirectoryInfo(defaultTemplatePath); ArrayList templates = templates = TemplateWebUpdateHelper.GetTempates(rootInfo); _wuRootNode = new RootTreeNode("Online Template Library"); foreach (string[] template in templates) { IdPathHash.Add(template[1].ToUpper(), template[0]); string fullns = template[4]; if (fullns.Trim() == string.Empty) { _wuRootNode.AddSorted(new TemplateTreeNode(template[0], template[1], template[2] + " (" + template[5] + ")", string.Empty, template[3], template[4], template[6])); } else { SortedTreeNode parentNode = _wuRootNode; string[] x = fullns.Split('.'); foreach (string ns in x) { 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[0], template[1], template[2] + " [" + template[5] + "]", string.Empty, template[3], template[4], template[6])); } } _wuRootNode.Expand(); } this._tree.Nodes.Add(_wuRootNode); } }
// for "Zeus Templates by Namespace" public void LoadTemplates() { if (_tree != null) { this._tree.Nodes.Clear(); IdPathHash.Clear(); if (_nsRootNode == null) { DefaultSettings settings = DefaultSettings.Instance; string exePath = Directory.GetCurrentDirectory(); try { defaultTemplatePath = settings.DefaultTemplateDirectory; if (!Directory.Exists(defaultTemplatePath)) { defaultTemplatePath = exePath; } } catch { defaultTemplatePath = exePath; } ArrayList templates = new ArrayList(); DirectoryInfo rootInfo = new DirectoryInfo(defaultTemplatePath); _buildChildren(rootInfo, templates); #if RUN_AS_NON_ADMIN string userTemplates = settings.UserTemplateDirectory; if ((userTemplates != null) && (userTemplates != defaultTemplatePath)) { rootInfo = new DirectoryInfo(userTemplates); _buildChildren(rootInfo, templates); } #endif _nsRootNode = new RootTreeNode("Zeus Templates by Namespace"); string[] nsarray; foreach (ZeusTemplateHeader template in templates) { if (template.Namespace.Trim() == string.Empty) { _nsRootNode.AddSorted(new TemplateTreeNode(template)); } else { SortedTreeNode parentNode = _nsRootNode; nsarray = template.Namespace.Split('.'); foreach (string ns in nsarray) { 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)); } } _nsRootNode.Expand(); } this._tree.Nodes.Add(_nsRootNode); } }
public void LoadTemplatesByFile() { if (_tree != null) { this._tree.Nodes.Clear(); IdPathHash.Clear(); if (_fsRootNode == null) { DefaultSettings settings = DefaultSettings.Instance; defaultTemplatePath = settings.DefaultTemplateDirectory; string exePath = Directory.GetCurrentDirectory(); if (!Directory.Exists(defaultTemplatePath)) { defaultTemplatePath = exePath; } // ArrayList templates = new ArrayList(); DirectoryInfo rootInfo = new DirectoryInfo(defaultTemplatePath); _fsRootNode = new RootTreeNode("Zeus Templates by File"); #if RUN_AS_NON_ADMIN SortedTreeNode item = new RootTreeNode("System"); _fsRootNode.Nodes.Add(item); _buildChildren(item, rootInfo); item.Expand(); string userTemplates = settings.UserTemplateDirectory; if ((userTemplates != null) && (userTemplates != defaultTemplatePath)) { rootInfo = new DirectoryInfo(userTemplates); item = new RootTreeNode("User:" + Environment.UserName); _fsRootNode.Nodes.Add(item); _buildChildren(item, rootInfo); item.Expand(); } #else _buildChildren(_fsRootNode, rootInfo); #endif _fsRootNode.Expand(); } this._tree.Nodes.Add(_fsRootNode); } }
public void LoadTemplatesFromWeb() { if (_tree != null) { IdPathHash.Clear(); this._tree.Nodes.Clear(); if (_wuRootNode == null) { DefaultSettings settings = DefaultSettings.Instance; defaultTemplatePath = settings.DefaultTemplateDirectory; string exePath = Directory.GetCurrentDirectory(); if (!Directory.Exists(defaultTemplatePath)) { defaultTemplatePath = exePath; } //ArrayList templates = new ArrayList(); DirectoryInfo rootInfo = new DirectoryInfo(defaultTemplatePath); ArrayList templates = templates = TemplateWebUpdateHelper.GetTempates(rootInfo); _wuRootNode = new RootTreeNode("Online Template Library"); foreach (string[] template in templates) { IdPathHash.Add(template[1].ToUpper(), template[0]); string fullns = template[4]; if (fullns.Trim() == string.Empty) { _wuRootNode.AddSorted(new TemplateTreeNode(template[0], template[1], template[2] + " (" + template[5] + ")", string.Empty, template[3], template[4], template[6])); } else { SortedTreeNode parentNode = _wuRootNode; string[] x = fullns.Split('.'); foreach (string ns in x) { 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[0], template[1], template[2] + " [" + template[5] + "]", string.Empty, template[3], template[4], template[6])); } } _wuRootNode.Expand(); } this._tree.Nodes.Add(_wuRootNode); } }