Esempio n. 1
0
        protected void buildChildren(SortedTreeNode rootNode, DirectoryInfo rootInfo)
        {
            ZeusTemplate template;

            foreach (DirectoryInfo dirInfo in rootInfo.GetDirectories())
            {
                FolderTreeNode node = new FolderTreeNode(dirInfo.Name);
                rootNode.AddSorted(node);

                this.buildChildren(node, dirInfo);
            }

            foreach (FileInfo fileInfo in rootInfo.GetFiles())
            {
                if ((fileInfo.Extension == ".jgen") ||
                    (fileInfo.Extension == ".vbgen") ||
                    (fileInfo.Extension == ".csgen") ||
                    (fileInfo.Extension == ".zeus"))
                {
                    string filename = fileInfo.FullName;

                    try
                    {
                        template = new ZeusTemplate(filename);
                    }
                    catch
                    {
                        continue;
                    }

                    TemplateTreeNode node = new TemplateTreeNode(template, true);
                    rootNode.AddSorted(node);
                }
            }
        }
Esempio n. 2
0
        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();
        }
		protected void buildChildren(SortedTreeNode rootNode, DirectoryInfo rootInfo)
		{
			ZeusTemplate template;

			foreach (DirectoryInfo dirInfo in rootInfo.GetDirectories()) 
			{
				FolderTreeNode node = new FolderTreeNode(dirInfo.Name);
				rootNode.AddSorted(node);

				this.buildChildren(node, dirInfo);
			}

			foreach (FileInfo fileInfo in rootInfo.GetFiles()) 
			{
				if ( (fileInfo.Extension == ".jgen")
					|| (fileInfo.Extension == ".vbgen")
					|| (fileInfo.Extension == ".csgen")
					|| (fileInfo.Extension == ".zeus") ) 
				{
					string filename = fileInfo.FullName;

					try 
					{
						template = new ZeusTemplate(filename);
					}
					catch 
					{
						continue;
					}

					TemplateTreeNode node = new TemplateTreeNode(template, true);
					rootNode.AddSorted(node);

				}
			}
		}