Exemple #1
0
        public System.Collections.IEnumerable GetChildren(TreePath treePath)
        {
            if (treePath.IsEmpty())
                foreach (string str in Environment.GetLogicalDrives())
                {
                    RootItem item = new RootItem(str);
                    yield return item;
                }
            else
            {
                List<BaseItem> items = new List<BaseItem>();
                BaseItem parent = treePath.LastNode as BaseItem;
                if (parent != null)
                {
                    foreach (string str in Directory.GetDirectories(parent.ItemPath))
                        items.Add(new FolderItem(str, parent));
                    foreach (string str in Directory.GetFiles(parent.ItemPath))
                        items.Add(new FileItem(str, parent));

                    _itemsToRead.AddRange(items);
                    if (!_worker.IsBusy)
                        _worker.RunWorkerAsync();

                    foreach (BaseItem item in items)
                        yield return item;
                }
                else
                    yield break;
            }
        }
Exemple #2
0
 public override IEnumerable GetChildren(TreePath treePath)
 {
     List<TemplateTreeItem> dataItems = new List<TemplateTreeItem>();
     if (treePath.IsEmpty())
     {
         var data = _dataSource.GroupBy(i => Regex.Matches(i.Description, @"\b[\w]*\b").Cast<Match>().First().Value);
         dataItems.AddRange(data.Select(group => new TemplateTreeItem()
         {
             Description = group.Key, Id = Guid.NewGuid(), IsLeaf = !group.Any(), Tag = group
         }).OrderBy(o=>o.Description));
     }
     else
     {
         IGrouping<string, EquipmentTemplate> items = ((TemplateTreeItem)treePath.LastNode).Tag as IGrouping<string, EquipmentTemplate>;
         if (items==null)
             throw new Exception("Error in tree");
         dataItems.AddRange(items.Select(item => new TemplateTreeItem()
         {
             Description = item.Description,
             Id = item.ElementId,
             IsLeaf = true,
             Tag = item
         }).OrderBy(o => o.Description));
     }
     return dataItems;
 }
		public Node FindNode(TreePath path)
		{
			if (path.IsEmpty())
				return this.Root;

            return FindNode(this.Root, path, 0);
		}
 public override IEnumerable GetChildren(TreePath treePath)
 {
     if (treePath.IsEmpty())
     {
         yield return new PluginDetailsNode("Component Handler Factory", componentDescriptor.ComponentHandlerFactory.ToString());
         yield return new PluginDetailsNode("Component Properties", string.Empty);
         yield return new PluginDetailsNode("Component Type Name", componentDescriptor.ComponentTypeName.FullName);
         yield return new PluginDetailsNode("Disabled", componentDescriptor.IsDisabled.ToString());
         yield return new PluginDetailsNode("Traits Properties", string.Empty);
     }
     else
     {
         var node = (PluginDetailsNode) treePath.LastNode;
         if (node.Name == "Component Properties")
         {
             if (componentDescriptor.ComponentProperties != null)
                 foreach (var property in componentDescriptor.ComponentProperties)
                     yield return new PluginDetailsNode(property.Key, property.Value);
         }
         else if (node.Name == "Disabled" && componentDescriptor.IsDisabled)
         {
             yield return new PluginDetailsNode("Disabled Reason", componentDescriptor.DisabledReason);
         }
         else if (node.Name == "Traits Properties")
         {
             if (componentDescriptor.TraitsProperties != null)
                 foreach (var property in componentDescriptor.TraitsProperties)
                     yield return new PluginDetailsNode(property.Key, property.Value);
         }
     }
 }
Exemple #5
0
 public Node FindNode(TreePath path)
 {
     if (path.IsEmpty())
         return _root;
     else
         return FindNode(_root, path, 0);
 }
 public override IEnumerable GetChildren(TreePath treePath)
 {
     if (treePath.IsEmpty())
     {
         yield return root;
     }
     else if (treePath.LastNode == root)
     {                
         foreach (var pluginDescriptor in PluginDescriptors)
         {
             var pluginNode = new PluginNode(pluginDescriptor);
             root.Nodes.Add(pluginNode);
             foreach (var file in pluginDescriptor.FilePaths)
             {
                 var fullPath = Path.Combine(pluginDescriptor.BaseDirectory.FullName, file);
                 var exists = fileSystem.FileExists(fullPath);
                 pluginNode.Nodes.Add(new FileNode(file, exists));
             }
             yield return pluginNode;
         }
     }
     else if (treePath.LastNode is PluginNode)
     {
         var pluginNode = (PluginNode) treePath.LastNode;
         foreach (var child in pluginNode.Nodes)
         {
             yield return child;
         }
     }
 }
Exemple #7
0
        public override System.Collections.IEnumerable GetChildren(TreePath treePath)
        {
            List<DataRowNode> items = new List<DataRowNode>();

            if (treePath.IsEmpty() )
            {
                items.Add(m_root);
            }
            else
            {
                DataRowNode n = treePath.LastNode as DataRowNode;

                DataRow row = n.Row;
                int id = Convert.ToInt32(row[m_IDColumnName]);

                DataRow[] rows = m_table.Select("ParentID = " + id+" and "+m_IDColumnName+" <> "+id);
                foreach (DataRow r in rows)
                {
                    DataRowNode node = new DataRowNode(r,r["Name"].ToString());
                    node.Row = r;
                    //SampleApp.Properties.Resources.ResourceManager.
                    //node.Icon = new Bitmap(SampleApp.Properties.Resources.Records,new Size(15,15));
                    items.Add(node);
                }
            }
            return items;
        }
Exemple #8
0
        public override System.Collections.IEnumerable  GetChildren(Aga.Controls.Tree.TreePath treePath)
        {
            List <PiscesObject> items = new List <PiscesObject>();

            if (treePath.IsEmpty())
            {
                PiscesObject[] roots = db.GetRootObjects();

                foreach (PiscesObject o in roots)
                {
                    items.Add(o);
                }
            }
            else
            {
                PiscesObject   s        = treePath.LastNode as PiscesObject;
                PiscesObject[] children = db.GetChildren(s);

                foreach (PiscesObject si in children)
                {
                    items.Add(si);
                }
            }
            return(items);
        }
 public System.Collections.IEnumerable GetChildren(TreePath treePath)
 {
     if (treePath.IsEmpty())
     return _list;
        else
     return null;
 }
Exemple #10
0
        public bool IsLeaf(TreePath treePath)
        {
            if (treePath.IsEmpty())
            {
                var relations = _dataService.GetRelations(null);
                return relations == null || !relations.Any();
            }

            if (treePath.LastNode is DbItem)
            {
                var item = treePath.LastNode as DbItem;
                var relations = _dataService.GetRelations(item.Id);
                return relations == null || !relations.Any();
            }
            else if (treePath.LastNode is DbRelation)
            {
                var relation = treePath.LastNode as DbRelation;
                if (relation.ToId != null)
                {
                    var item = _dataService.GetItem(relation.ToId.Value);
                    return item == null;
                }
            }

            return true;
        }
 public override IEnumerable GetChildren(TreePath treePath)
 {
     if (treePath.IsEmpty())
     {
         yield return new PluginDetailsNode("Assembly References", string.Empty);
         yield return new PluginDetailsNode("Base Directory", pluginDescriptor.BaseDirectory.FullName);
         yield return new PluginDetailsNode("Disabled", pluginDescriptor.IsDisabled.ToString());
         yield return new PluginDetailsNode("Plugin Dependencies", string.Empty);
         yield return
             new PluginDetailsNode("Plugin Handler Factory", pluginDescriptor.PluginHandlerFactory.ToString())
             ;
         yield return new PluginDetailsNode("Plugin Properties", string.Empty);
         yield return new PluginDetailsNode("Plugin Type Name", pluginDescriptor.PluginTypeName.FullName);
         yield return new PluginDetailsNode("Probing Paths", string.Empty);
         yield return new PluginDetailsNode("Traits Properties", string.Empty);
     }
     else
     {
         var node = (PluginDetailsNode) treePath.LastNode;
         if (node.Name == "Assembly References" && pluginDescriptor.AssemblyBindings != null)
         {
             foreach (var assemblyReference in pluginDescriptor.AssemblyBindings)
             {
                 string codeBase = assemblyReference.CodeBase != null ? 
                     assemblyReference.CodeBase.ToString() : "(unknown)";
                 yield return new PluginDetailsNode(assemblyReference.AssemblyName.ToString(), 
                     codeBase);
             }
         }
         else if (node.Name == "Disabled" && pluginDescriptor.IsDisabled)
         {
             yield return new PluginDetailsNode("Disabled Reason", pluginDescriptor.DisabledReason);
         }
         else
             switch (node.Name)
             {
                 case "Plugin Dependencies":
                     if (pluginDescriptor.PluginDependencies != null)
                         foreach (var pluginDependency in pluginDescriptor.PluginDependencies)
                             yield return new PluginDetailsNode(pluginDependency.PluginId, string.Empty);
                     break;
                 case "Plugin Properties":
                     if (pluginDescriptor.PluginProperties != null)
                         foreach (var pluginProperty in pluginDescriptor.PluginProperties)
                             yield return new PluginDetailsNode(pluginProperty.Key, pluginProperty.Value);
                     break;
                 case "Probing Paths":
                     if (pluginDescriptor.ProbingPaths != null)
                         foreach (var probingPath in pluginDescriptor.ProbingPaths)
                             yield return new PluginDetailsNode(probingPath, string.Empty);
                     break;
                 case "Traits Properties":
                     if (pluginDescriptor.TraitsProperties != null)
                         foreach (var traitsProperty in pluginDescriptor.TraitsProperties)
                             yield return new PluginDetailsNode(traitsProperty.Key, traitsProperty.Value);
                     break;
             }
     }
 }
        public override bool IsLeaf(TreePath treePath)
        {
            if (treePath.IsEmpty())
                return false;

            var node = (PluginDetailsNode)treePath.LastNode;
            return node.Name != "Disabled" || !serviceDescriptor.IsDisabled;
        }
        /// <summary>Grabs the children of the passed path</summary>
        /// <param name="treePath">Path to get the children of</param>
        /// <returns>IEnumerable collection with the child items</returns>
        public IEnumerable GetChildren(TreePath treePath)
        {
            List<BaseItem> items = new List<BaseItem>();
            if (treePath.IsEmpty())
            {
                if (_tree.Cache.ContainsKey("ROOT"))
                {
                    items = _tree.Cache["ROOT"];
                }
                else
                {
                    items = new List<BaseItem>();
                    _tree.Cache.Add("ROOT", items);
                }
            }
            else
            {
                ServerItem server = treePath.FirstNode as ServerItem;
                BaseItem database = treePath.FullPath.FirstOrDefault(i => (i as BaseItem).Type == ItemType.Database) as BaseItem;
                BaseItem parent = treePath.LastNode as BaseItem;
                if (parent != null && server != null)
                {
                    if (_tree.Cache.ContainsKey(parent.ItemPath))
                    {
                        items = _tree.Cache[parent.ItemPath];
                    }
                    else
                    {
                        //Populate the items based on the parent
                        switch (parent.Type)
                        {
                            case ItemType.Server:
                                items = GetDatabases(server);
                                break;
                            case ItemType.Database:
                                items = GetDatabaseChildren(parent);
                                break;
                            case ItemType.Folder:
                                if (database != null)
                                    items = GetFolderChildren(parent, server, database.Name);
                                break;
                            case ItemType.Table:
                            case ItemType.View:
                                items = GetTableViewChildren(parent);
                                break;
                            default:
                                break;
                        }

                        _tree.Cache.Add(parent.ItemPath, items);
                    }

                    parent.IsLoaded = true;
                }
            }

            return items;
        }
Exemple #14
0
 public IEnumerable GetChildren(TreePath treePath)
 {
     if (this.RootSection == null)
         return null;
     SectionEntry ed = treePath.IsEmpty() ? this.RootSection : ((SectionEntry)treePath.LastNode);
     List<Entry> ret = new List<Entry>(ed.Entries);
     ret.Add(null);//a null entry, which will be the button for adding new entries
     return ret;
 }
        public Node FindNode(TreePath path)
        {
            if (path.IsEmpty())
            {
                return(this.Root);
            }

            return(FindNode(this.Root, path, 0));
        }
Exemple #16
0
        public TreeNodeAdv FindNode(TreePath path, bool readChilds)
        {
            if (path.IsEmpty())
            {
                return(this.Root);
            }

            return(FindNode(this.Root, path, 0, readChilds));
        }
Exemple #17
0
 public TreeNodeAdv FindNode(TreePath path)
 {
     if (path.IsEmpty())
     {
         return(_root);
     }
     else
     {
         return(FindNode(_root, path, 0));
     }
 }
Exemple #18
0
 public TreeNodeAdv FindNode(TreePath path, bool readChilds)
 {
     if (path.IsEmpty())
     {
         return(_root);
     }
     else
     {
         return(FindNode(_root, path, 0, readChilds));
     }
 }
 public System.Collections.IEnumerable GetChildren(TreePath treePath)
 {
     if (treePath.IsEmpty())
     {
         return(_list);
     }
     else
     {
         return(null);
     }
 }
 public IEnumerable GetChildren(TreePath treePath)
 {
     if (treePath.IsEmpty())
     {
         return(_list);
     }
     else
     {
         return(null);
     }
 }
        public IEnumerable GetChildren(TreePath treePath) {
            if (!controller.CanRetrieveData) {
                return null;
            }

            if(treePath.IsEmpty()) {
                var workitems = controller.GetWorkitems();
                return workitems != null ? WrapWorkitems(workitems) : new WorkitemDescriptor[0];
            }

            var descriptor = (WorkitemDescriptor) treePath.LastNode;
            return WrapWorkitems(descriptor.Workitem.Children);
        }
 public override IEnumerable GetChildren(TreePath treePath)
 {
     List<EquipmentTemplate> templates=new List<EquipmentTemplate>();
     if (treePath.IsEmpty())
     {
         templates = _cachedTemplates.Where(temp => temp.ParentElementTemplate == null).OrderBy(item => item.Description).ToList();
     }
     else
     {
         EquipmentTemplate parentTemplate = (EquipmentTemplate)treePath.LastNode;
         if (parentTemplate == null) return templates;
         templates = _cachedTemplates.Where(temp => temp.ParentElementId == parentTemplate.ElementId).OrderBy(item => item.Position).ToList();
     }
     return templates;
 }
 public override IEnumerable GetChildren(TreePath treePath)
 {
     if (treePath.IsEmpty())
     {
         yield return new PluginDetailsNode("Disabled", serviceDescriptor.IsDisabled.ToString());
         yield return new PluginDetailsNode("Service Type Name", serviceDescriptor.ServiceTypeName.FullName);
         yield return new PluginDetailsNode("Traits Handler Factory", serviceDescriptor.TraitsHandlerFactory.ToString());
     }
     else
     {
         var node = (PluginDetailsNode)treePath.LastNode;
         if (node.Name == "Disabled" && serviceDescriptor.IsDisabled)
             yield return new PluginDetailsNode("Disabled Reason", serviceDescriptor.DisabledReason);
     }
 }
Exemple #24
0
        public Node FindNode(TreePath path)
        {
            if (path == null)
            {
                return(null);
            }

            if (path.IsEmpty())
            {
                return(_root);
            }
            else
            {
                return(FindNode(_root, path, 0));
            }
        }
        /// <summary>
        /// Returns a node list of all child nodes of a given parent node
        /// </summary>
        /// <param name="treePath">The path of the parent node</param>
        /// <returns>The list of child nodes for the given parent path node</returns>
        public override System.Collections.IEnumerable GetChildren(TreePath treePath)
        {
            List<GrtTreeNode> items = null;
              NodeIdWrapper parentNodeId;
              bool settingTopNode = false;

              if (treePath.IsEmpty())
              {
            settingTopNode = true;
            parentNodeId = model.get_root();
              }
              else
              {
            GrtTreeNode parent = treePath.LastNode as GrtTreeNode;
            if (parent != null)
              parentNodeId = parent.NodeId;
            else
              parentNodeId = null;
              }

              if (parentNodeId != null)
              {
            int childCount = model.count_children(parentNodeId);

            items = new List<GrtTreeNode>();

            for (int i = 0; i < childCount; i++)
            {
              NodeIdWrapper nodeId = model.get_child(parentNodeId, i);
              GrtTreeNode node;
              string caption;

              model.get_field(nodeId, columns[0].index, out caption);

              if (disabledNames.Contains(caption))
            continue;

              node = new GrtTreeNode(caption, nodeId, null, this);
              if (settingTopNode)
            topNode = node;

              items.Add(node);
            }
              }
              return items;
        }
 public System.Collections.IEnumerable GetChildren(TreePath treePath)
 {
     List<BaseItem> items = null;
     if (treePath.IsEmpty())
     {
         if (_cache.ContainsKey("ROOT"))
             items = _cache["ROOT"];
         else
         {
             items = new List<BaseItem>();
             _cache.Add("ROOT", items);
             foreach (string str in Environment.GetLogicalDrives())
                 items.Add(new RootItem(str, this));
         }
     }
     else
     {
         BaseItem parent = treePath.LastNode as BaseItem;
         if (parent != null)
         {
             if (_cache.ContainsKey(parent.ItemPath))
                 items = _cache[parent.ItemPath];
             else
             {
                 items = new List<BaseItem>();
                 try
                 {
                     foreach (string str in Directory.GetDirectories(parent.ItemPath))
                         items.Add(new FolderItem(str, parent, this));
                     foreach (string str in Directory.GetFiles(parent.ItemPath))
                         items.Add(new FileItem(str, parent, this));
                 }
                 catch (IOException)
                 {
                     return null;
                 }
                 _cache.Add(parent.ItemPath, items);
                 _itemsToRead.AddRange(items);
                 if (!_worker.IsBusy)
                     _worker.RunWorkerAsync();
             }
         }
     }
     return items;
 }
Exemple #27
0
 public override IEnumerable GetChildren(TreePath treePath)
 {
     if (Settings.Default.AreasViewAsList)
     {
             return _cachedAreas.OrderBy(area => area.Description).ToList();
     }
     else
     {
         if (treePath.IsEmpty())
         {
             return _cachedAreas.Where(area => area.ParentArea == null).OrderBy(area => area.Description).ToList();
         }
         else
         {
             Area item = treePath.LastNode as Area;
             return _cachedAreas.Where(area => area.ParentArea == item).OrderBy(area => area.Description).ToList();
         }
     }
 }
        public System.Collections.IEnumerable GetChildren(TreePath treePath)
        {
            if (string.IsNullOrEmpty(this.basePath) && treePath.IsEmpty())
            {
                foreach (string str in Environment.GetLogicalDrives())
                {
                    LogicalDriveItem item = new LogicalDriveItem(str);
                    yield return item;
                }
            }
            else
            {
                List<BaseItem> items = new List<BaseItem>();
                BaseItem parent = treePath.LastNode as BaseItem;
                string path = parent != null ? parent.ItemPath : this.basePath;
                if (!string.IsNullOrEmpty(path) && Directory.Exists(path))
                {
                    try
                    {
                        IEnumerable<string> dirQuery = Directory.GetDirectories(path);
                        IEnumerable<string> fileQuery = Directory.GetFiles(path);
                        if (this.filter != null)
                        {
                            dirQuery = dirQuery.Where(s => this.filter(s));
                            fileQuery = fileQuery.Where(s => this.filter(s));
                        }
                        foreach (string str in dirQuery) items.Add(new FolderItem(str, parent));
                        foreach (string str in fileQuery) items.Add(new FileItem(str, parent));
                    }
                    catch (UnauthorizedAccessException) {}

                    this.itemsToRead.AddRange(items);
                    if (!this.itemLoader.IsBusy) this.itemLoader.RunWorkerAsync();

                    foreach (BaseItem item in items)
                        yield return item;
                }
                else
                    yield break;
            }
        }
Exemple #29
0
        public IEnumerable GetChildren(TreePath treePath)
        {
            if (treePath.IsEmpty())
            {
                return _dataService.GetRelations(null);
            }

            if (treePath.LastNode is DbItem)
            {
                var item = treePath.LastNode as DbItem;
                return _dataService.GetRelations(item.Id);
            }
            else if (treePath.LastNode is DbRelation)
            {
                var relation = treePath.LastNode as DbRelation;
                if (relation.ToId != null)
                    return new[] { _dataService.GetItem(relation.ToId.Value) };
            }

            return null;
        }
 public override IEnumerable GetChildren(TreePath treePath)
 {
     if (treePath.IsEmpty())
     {
         foreach (var plugin in registry.Plugins)
             yield return new PluginNode(plugin.PluginId);
     }
     else if (treePath.LastNode is PluginNode)
     {
         var pluginNode = (PluginNode)treePath.LastNode;
         foreach (var service in registry.Services)
             if (service.Plugin.PluginId == pluginNode.Text)
                 yield return new ServiceNode(service.ServiceId);
     }
     else if (treePath.LastNode is ServiceNode)
     {
         var serviceNode = (ServiceNode)treePath.LastNode;
         foreach (var component in registry.Components)
             if (component.Service.ServiceId == serviceNode.Text)
                 yield return new ComponentNode(component.ComponentId);
     }
 }
Exemple #31
0
 public override IEnumerable GetChildren(TreePath treePath)
 {
     List<AreaTreeItem> dataItems = new List<AreaTreeItem>();
     if (treePath.IsEmpty())
     {
         dataItems = _cachedAreas
             .Select(
                 item =>
                     new AreaTreeItem
                     {
                         Id = item.AreaId,
                         Description = item.Description,
                         IsLeaf = item.Equipments.Count(equipment => equipment.EquipmentPorts.Count() != 0) == 0,
                         Tag = item,
                         Icon = Resources.category.ToBitmap()
                     })
             .OrderBy(item => item.Description)
             .ToList();
     }
     else
     {
         Area parentArea = ((AreaTreeItem) treePath.LastNode).Tag as Area;
         if (parentArea != null)
             dataItems = parentArea.Equipments
                 .Where(equipment => equipment.EquipmentPorts.Any())
                 .Select(
                     item =>
                         new AreaTreeItem
                         {
                             Id = item.EquipmentId,
                             Description = string.Format("{0} {1}", item.Description, item.NetworkDescription != string.Empty ? "["+item.NetworkDescription+"]" : ""),
                             IsLeaf = true,
                             Tag = item,
                             Icon = Resources.hard.ToBitmap()
                         })
                 .OrderBy(item => item.Description).ToList();
     }
     return dataItems;
 }
Exemple #32
0
 public override IEnumerable GetChildren(TreePath treePath)
 {
     List<AreaTreeItem> dataItems = new List<AreaTreeItem>();
     List<AreaTreeItem> equipmentItems = null;
     Area parentArea = null;
     if (!treePath.IsEmpty())
     {
         parentArea = ((AreaTreeItem) treePath.LastNode).Tag as Area;
         if (parentArea != null)
             equipmentItems = parentArea.Equipments
                 .Where(equipment => equipment.EquipmentPorts.Any())
                 .Select(
                     item =>
                         new AreaTreeItem
                         {
                             Id = item.EquipmentId,
                             Description = string.Format("{0} {1}", item.Description, item.NetworkDescription != string.Empty ? "[" + item.NetworkDescription + "]" : ""),
                             IsLeaf = true,
                             Tag = item,
                             Icon = Resources.hard.ToBitmap()
                         })
                 .OrderBy(item => item.Description).ToList();
     }
     if (equipmentItems != null)
         dataItems.AddRange(equipmentItems);
     List<AreaTreeItem> areaItems = _cachedAreas
         .Where(area => area.ParentArea == parentArea)
         .Select(item =>
         {
             bool isLeaf = item.Equipments.Count == 0 && item.ChildAreas.Count == 0;
             return new AreaTreeItem {Id = item.AreaId, Description = item.Description, IsLeaf = isLeaf, Tag = item, Icon = Resources.category.ToBitmap()};
         })
         .OrderBy(item => item.Description).ToList();
     dataItems.AddRange(areaItems);
     return dataItems;
 }
Exemple #33
0
 public IEnumerable GetChildren(TreePath treePath)
 {
     if (treePath.IsEmpty())
     {
         foreach (string libName in _items.Keys.OrderBy(n => n))
         {
             LibraryNode item = new LibraryNode(libName);
             yield return item;
         }
     }
     else
     {
         LibraryNode parent = treePath.LastNode as LibraryNode;
         if (parent != null && _items.ContainsKey(parent.Name))
         {
             foreach (string name in _items[parent.Name].OrderBy(n => n))
             {
                 yield return new ItemNode(name, _resMgr.GetResource(parent.Name + "::" + name));
             }
         }
         else
             yield break;
     }
 }
        public bool IsLeaf(TreePath treePath)
        {
            // When we're sorting the whole tree is a flat list, so there are no children.
            if (this.GetSortColumn() != "")
                return true;

            if (treePath.IsEmpty())
                return false;
            else
                return (treePath.LastNode as ProcessNode).Children.Count == 0;
        }
        public System.Collections.IEnumerable GetChildren(TreePath treePath)
        {
            if (this.GetSortColumn() != "")
            {
                List<ProcessNode> nodes = new List<ProcessNode>();
                string sortC = this.GetSortColumn();
                SortOrder sortO = this.GetSortOrder();

                nodes.AddRange(_processes.Values);

                nodes.Sort(new Comparison<ProcessNode>(delegate(ProcessNode n1, ProcessNode n2)
                    {
                        // We have a problem here - the GdiHandlesNumber and UserHandlesNumber 
                        // properties are dynamically retrieved, so if n1 == n2 we may end up 
                        // getting different values for the same process due to the timing.
                        // If we do, then Array.Sort will throw an exception.
                        //
                        // The temporary HACK used here is to return 0 whenever n1 == n2.
                        if (n1 == n2)
                            return 0;

                        switch (sortC)
                        {
                            case "name":
                                return ModifySort(string.Compare(n1.Name, n2.Name), sortO);
                            case "pid":
                                return ModifySort(n1.Pid.CompareTo(n2.Pid), sortO);
                            case "pvt. memory":
                                return ModifySort(n1.ProcessItem.Process.VirtualMemoryCounters.PrivatePageCount.CompareTo(
                                    n2.ProcessItem.Process.VirtualMemoryCounters.PrivatePageCount), sortO);
                            case "working set":
                                return ModifySort(n1.ProcessItem.Process.VirtualMemoryCounters.WorkingSetSize.CompareTo(
                                    n2.ProcessItem.Process.VirtualMemoryCounters.WorkingSetSize), sortO);
                            case "peak working set":
                                return ModifySort(n1.ProcessItem.Process.VirtualMemoryCounters.PeakWorkingSetSize.CompareTo(
                                    n2.ProcessItem.Process.VirtualMemoryCounters.PeakWorkingSetSize), sortO);
                            case "private ws":
                                return ModifySort(n1.PrivateWorkingSetNumber.CompareTo(n2.PrivateWorkingSetNumber), sortO);
                            case "shared ws":
                                return ModifySort(n1.SharedWorkingSetNumber.CompareTo(n2.SharedWorkingSetNumber), sortO);
                            case "shareable ws":
                                return ModifySort(n1.ShareableWorkingSetNumber.CompareTo(n2.ShareableWorkingSetNumber), sortO);
                            case "virtual size":
                                return ModifySort(n1.ProcessItem.Process.VirtualMemoryCounters.VirtualSize.CompareTo(
                                    n2.ProcessItem.Process.VirtualMemoryCounters.VirtualSize), sortO);
                            case "peak virtual size":
                                return ModifySort(n1.ProcessItem.Process.VirtualMemoryCounters.PeakVirtualSize.CompareTo(
                                    n2.ProcessItem.Process.VirtualMemoryCounters.PeakVirtualSize), sortO);
                            case "pagefile usage":
                                return ModifySort(n1.ProcessItem.Process.VirtualMemoryCounters.PagefileUsage.CompareTo(
                                    n2.ProcessItem.Process.VirtualMemoryCounters.PagefileUsage), sortO);
                            case "peak pagefile usage":
                                return ModifySort(n1.ProcessItem.Process.VirtualMemoryCounters.PeakPagefileUsage.CompareTo(
                                    n2.ProcessItem.Process.VirtualMemoryCounters.PeakPagefileUsage), sortO);
                            case "page faults":
                                return ModifySort(n1.ProcessItem.Process.VirtualMemoryCounters.PageFaultCount.CompareTo(
                                    n2.ProcessItem.Process.VirtualMemoryCounters.PageFaultCount), sortO);
                            case "cpu":
                                return ModifySort(n1.ProcessItem.CpuUsage.CompareTo(n2.ProcessItem.CpuUsage), sortO);
                            case "username":
                                return ModifySort(string.Compare(n1.Username, n2.Username), sortO);
                            case "session id":
                                return ModifySort(n1.ProcessItem.SessionId.CompareTo(n2.ProcessItem.SessionId), sortO);
                            case "priority class":
                            case "base priority":
                                return ModifySort(n1.ProcessItem.Process.BasePriority.CompareTo(
                                    n2.ProcessItem.Process.BasePriority), sortO);
                            case "description":
                                return ModifySort(string.Compare(n1.Description, n2.Description), sortO);
                            case "company":
                                return ModifySort(string.Compare(n1.Company, n2.Company), sortO);
                            case "file name":
                                return ModifySort(string.Compare(n1.FileName, n2.FileName), sortO);
                            case "command line":
                                return ModifySort(string.Compare(n1.CommandLine, n2.CommandLine), sortO);
                            case "threads":
                                return ModifySort(n1.ProcessItem.Process.NumberOfThreads.CompareTo(
                                    n2.ProcessItem.Process.NumberOfThreads), sortO);
                            case "handles":
                                return ModifySort(n1.ProcessItem.Process.HandleCount.CompareTo(
                                    n2.ProcessItem.Process.HandleCount), sortO);
                            case "gdi handles":
                                return ModifySort(n1.GdiHandlesNumber.CompareTo(n2.GdiHandlesNumber), sortO);
                            case "user handles":
                                return ModifySort(n1.UserHandlesNumber.CompareTo(n2.UserHandlesNumber), sortO);
                            case "i/o total":
                                return ModifySort(n1.IoTotalNumber.CompareTo(n2.IoTotalNumber), sortO);
                            case "i/o ro":
                                return ModifySort(n1.IoReadOtherNumber.CompareTo(n2.IoReadOtherNumber), sortO);
                            case "i/o w":
                                return ModifySort(n1.IoWriteNumber.CompareTo(n2.IoWriteNumber), sortO);
                            case "integrity":
                                return ModifySort(n1.IntegrityLevel.CompareTo(n2.IntegrityLevel), sortO);
                            case "i/o priority":
                                return ModifySort(n1.IoPriority.CompareTo(n2.IoPriority), sortO);
                            case "page priority":
                                return ModifySort(n1.PagePriority.CompareTo(n2.PagePriority), sortO);
                            case "start time":
                                return ModifySort(n1.ProcessItem.CreateTime.CompareTo(n2.ProcessItem.CreateTime), sortO);
                            case "start time (relative)":
                                // Invert the order - bigger dates are actually smaller if we use the relative time span.
                                return -ModifySort(n1.ProcessItem.CreateTime.CompareTo(n2.ProcessItem.CreateTime), sortO);
                            case "total cpu time":
                                return ModifySort((n1.ProcessItem.Process.KernelTime + n1.ProcessItem.Process.UserTime).
                                    CompareTo(n2.ProcessItem.Process.KernelTime + n2.ProcessItem.Process.UserTime), sortO);
                            case "kernel cpu time":
                                return ModifySort(n1.ProcessItem.Process.KernelTime.CompareTo(
                                    n2.ProcessItem.Process.KernelTime), sortO);
                            case "user cpu time":
                                return ModifySort(n1.ProcessItem.Process.UserTime.CompareTo(
                                    n2.ProcessItem.Process.UserTime), sortO);
                            case "verification status":
                                return ModifySort(string.Compare(n1.VerificationStatus, n2.VerificationStatus), sortO);
                            case "verified signer":
                                return ModifySort(string.Compare(n1.VerifiedSigner, n2.VerifiedSigner), sortO);
                            default:
                                return 0;
                        }
                    }));

                return nodes;
            }

            if (treePath.IsEmpty())
                return _roots;
            else
                return (treePath.LastNode as ProcessNode).Children;
        }
Exemple #36
0
 public TreeNodeAdv FindNode(TreePath path, bool readChilds)
 {
     if (path.IsEmpty())
     return _root;
        else
     return FindNode(_root, path, 0, readChilds);
 }
        public bool IsLeaf(TreePath treePath)
        {
            if (this.GetSortColumn() != "")
                return true;

            if (treePath.IsEmpty())
                return false;
            else
                return (treePath.LastNode as ProcessNode).Children.Count == 0;
        }
        public override IEnumerable GetChildren(TreePath treePath)
        {
            if (treePath.IsEmpty())
            {
                yield return projectRoot;
            }
            else if (treePath.LastNode == projectRoot)
            {
                foreach (var n in projectRoot.Nodes)
                    yield return n;
            }
            else if (treePath.LastNode is FilesNode)
            {
                foreach (var file in testProject.TestPackage.Files)
                    yield return new FileNode(file.FullName);
            }
            else if (treePath.LastNode is ReportsNode && !string.IsNullOrEmpty(fileName))
            {
                var reportDirectory = Path.Combine(Path.GetDirectoryName(fileName), "Reports");

                if (!fileSystem.DirectoryExists(reportDirectory))
                    yield break;
             
                var regex = new Regex("{.}");
                var searchPattern = regex.Replace(testProject.ReportNameFormat, "*") + "*.xml";
                foreach (var file in fileSystem.GetFilesInDirectory(reportDirectory, searchPattern, 
                    SearchOption.TopDirectoryOnly))
                {
                    yield return new ReportNode(file);
                }
            }
        }