IsNew() private static method

private static IsNew ( string folder ) : bool
folder string
return bool
Beispiel #1
0
        public static void FindExamples(DirectoryInfo root, int level, int maxLevel, List <ExampleGroup> examples)
        {
            DirectoryInfo[] folders = root.GetDirectories();
            folders = SortFolders(root, folders);

            foreach (DirectoryInfo folder in folders)
            {
                if ((folder.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden ||
                    excludeList.Contains(folder.Name) || folder.Name.StartsWith("_"))
                {
                    continue;
                }

                if (level < maxLevel)
                {
                    if (level == 1)
                    {
                        examples.Add(new ExampleGroup {
                            id = folder.Name, title = folder.Name
                        });
                    }

                    UIHelpers.FindExamples(folder, level + 1, maxLevel, examples);
                }
                else
                {
                    string imgUrl = UIHelpers.ApplicationRoot + "/resources/images/noimage.gif";
                    string descr  = "No description";
                    string name   = folder.Name.Replace("_", " ");

                    if (UIHelpers.IsNew(folder.FullName))
                    {
                        name += "<span>&nbsp;</span>";
                    }

                    if (File.Exists(folder.FullName + "\\config.xml"))
                    {
                        ExampleConfig cfg = new ExampleConfig(folder.FullName + "\\config.xml", false);
                        descr = cfg.Description;
                    }

                    if (File.Exists(folder.FullName + "\\thumbnail.png"))
                    {
                        imgUrl = PhysicalToVirtual(folder.FullName + "\\thumbnail.png");
                    }
                    else if (File.Exists(folder.FullName + "\\thumbnail.gif"))
                    {
                        imgUrl = PhysicalToVirtual(folder.FullName + "\\thumbnail.gif");
                    }

                    string url = PhysicalToVirtual(folder.FullName + "/");

                    ExampleGroup group = examples[examples.Count - 1];
                    group.samples.Add(new { id = "e" + Math.Abs(url.ToLower().GetHashCode()), name, url, imgUrl, descr, sub = folder.Parent.Name.Replace("_", " ") });
                }
            }
        }
Beispiel #2
0
        public static NodeCollection BuildFirstLevel()
        {
            string        path = HttpContext.Current.Server.MapPath("~/Examples/");
            DirectoryInfo root = new DirectoryInfo(path);

            DirectoryInfo[] folders = root.GetDirectories();
            folders = UIHelpers.SortFolders(root, folders);

            NodeCollection nodes = new NodeCollection(false);

            foreach (DirectoryInfo folder in folders)
            {
                if ((folder.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden ||
                    excludeList.Contains(folder.Name) || folder.Name.StartsWith("_"))
                {
                    continue;
                }

                ExampleConfig cfg = new ExampleConfig(folder.FullName + "\\config.xml", false);

                string iconCls = string.IsNullOrEmpty(cfg.IconCls) ? "" : cfg.IconCls;
                Node   node    = new Node();

                node.Text = folder.Name.Replace("_", " ");

                if (UIHelpers.IsNew(folder.FullName))
                {
                    node.CustomAttributes.Add(new ConfigItem("isNew", "true", ParameterMode.Raw));
                }

                node.IconCls = iconCls;

                string url = UIHelpers.PhysicalToVirtual(folder.FullName + "/");
                node.NodeID = "e" + Math.Abs(url.ToLower().GetHashCode());

                nodes.Add(node);
            }

            return(nodes);
        }
Beispiel #3
0
        private static NodeCollection BuildTreeLevel(DirectoryInfo root, int level, int maxLevel, XmlElement siteMap)
        {
            DirectoryInfo[] folders = root.GetDirectories();

            folders = SortFolders(root, folders);

            NodeCollection nodes = new NodeCollection(false);

            foreach (DirectoryInfo folder in folders)
            {
                if ((folder.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden ||
                    excludeList.Contains(folder.Name) || folder.Name.StartsWith("_"))
                {
                    continue;
                }

#if !PREEXTENSIONS
                if (level == 1 && (folder.Name == "Gantt" || folder.Name == "Scheduler"))
                {
                    continue;
                }
#endif

                ExampleConfig cfg = new ExampleConfig(folder.FullName + "\\config.xml", false);

                string     iconCls  = string.IsNullOrEmpty(cfg.IconCls) ? "" : cfg.IconCls;
                Node       node     = new Node();
                XmlElement siteNode = null;

                string folderName = folder.Name.Replace("_", " ");

                if (level < maxLevel)
                {
                    node.Text = folderName;

                    if (UIHelpers.IsNew(folder.FullName))
                    {
                        node.CustomAttributes.Add(new ConfigItem("isNew", "true", ParameterMode.Raw));
                    }

                    node.IconCls = iconCls;
                    node.NodeID  = BaseControl.GenerateID();
                    //node.SingleClickExpand = true;

                    if (siteMap != null)
                    {
                        siteNode = siteMap.OwnerDocument.CreateElement("siteMapNode");
                        siteNode.SetAttribute("title", folderName);
                        siteMap.AppendChild(siteNode);
                    }

                    node.Children.AddRange(UIHelpers.BuildTreeLevel(folder, level + 1, maxLevel, siteNode));
                }
                else
                {
                    node.Text = folderName;

                    if (UIHelpers.IsNew(folder.FullName))
                    {
                        node.CustomAttributes.Add(new ConfigItem("isNew", "true", ParameterMode.Raw));
                    }

                    node.IconCls = iconCls;
                    string url = PhysicalToVirtual(folder.FullName + "/");
                    node.NodeID = "e" + Math.Abs(url.ToLower().GetHashCode());
                    //node.Href = Regex.Replace(url, "^/Examples","");
                    node.CustomAttributes.Add(new ConfigItem("url", Regex.Replace(url, "^/Examples", "")));

                    node.Leaf = true;

                    if (siteMap != null)
                    {
                        siteNode = siteMap.OwnerDocument.CreateElement("siteMapNode");
                        siteNode.SetAttribute("title", folderName);
                        siteNode.SetAttribute("description", string.IsNullOrEmpty(cfg.Description) ? "No description" : cfg.Description);
                        siteNode.SetAttribute("url", "~" + UIHelpers.PhysicalToVirtual(folder.FullName + "/"));
                        siteMap.AppendChild(siteNode);
                    }
                }

                node.CustomAttributes.Add(new { tags = cfg.Tags.Select(item => item.ToLower()) });

                nodes.Add(node);
            }

            return(nodes);
        }