Exemplo n.º 1
0
        private void _buildChildren(SortedTreeNode rootNode, DirectoryInfo rootInfo)
        {
            ZeusTemplateHeader template;

            foreach (DirectoryInfo dirInfo in rootInfo.GetDirectories())
            {
                if (dirInfo.Attributes != (FileAttributes.System | dirInfo.Attributes))
                {
                    FolderTreeNode node = new FolderTreeNode(dirInfo.Name);
                    rootNode.AddSorted(node);

                    this._buildChildren(node, dirInfo);
                }
            }

            foreach (FileInfo fileInfo in rootInfo.GetFiles())
            {
                if (IsTemplateFile(fileInfo))
                {
                    string filename = fileInfo.FullName;

                    try
                    {
                        template = ZeusTemplateParser.LoadTemplateHeader(filename);
                        IdPathHash.Add(template.UniqueID.ToUpper(), template.FilePath + template.FileName);
                    }
                    catch
                    {
                        continue;
                    }

                    TemplateTreeNode node = new TemplateTreeNode(template, true);
                    rootNode.AddSorted(node);
                }
            }
        }
Exemplo n.º 2
0
        // 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);
            }
        }
Exemplo n.º 3
0
        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);
            }
        }
		private void _buildChildren(SortedTreeNode rootNode, DirectoryInfo rootInfo)
		{
			ZeusTemplateHeader template;

			foreach (DirectoryInfo dirInfo in rootInfo.GetDirectories()) 
			{
				if (dirInfo.Attributes != (FileAttributes.System | dirInfo.Attributes)) 
				{
					FolderTreeNode node = new FolderTreeNode(dirInfo.Name);
					rootNode.AddSorted(node);

					this._buildChildren(node, dirInfo);
				}
			}

			foreach (FileInfo fileInfo in rootInfo.GetFiles()) 
			{
				if (IsTemplateFile(fileInfo)) 
				{
					string filename = fileInfo.FullName;

					try 
					{
						template = ZeusTemplateParser.LoadTemplateHeader(filename);
						IdPathHash.Add(template.UniqueID.ToUpper(), template.FilePath + template.FileName);
					}
					catch 
					{
						continue;
					}

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

				}
			}
		}