Exemple #1
0
        /// <summary>
        /// This returns false if the object should be filtered out according to currentFilters value
        /// </summary>
        /// <param name="obj"> </param>
        private bool FilterPass(ManagementClass obj)
        {
            switch (currentFilters)
            {
            case (ClassFilters.ConcreteData):
            {
                if (!WmiHelper.IsAbstract(obj) &&
                    !WmiHelper.IsAssociation(obj))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            case (ClassFilters.ConcreteOrHavingConcreteSubclasses):
            {
                if (!WmiHelper.IsAbstract(obj) ||
                    WmiHelper.HasNonAbstractChildren(obj))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            case (ClassFilters.ExtrinsicEvents):
            {
                if (WmiHelper.IsEvent(obj))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            case (ClassFilters.All):
            {
                return(true);
            }

            default:
                break;
            }

            return(true);
        }
        private string FilterPass(ISWbemObject obj)
        {
            try
            {
                String strLabel = ((ISWbemObjectPath)(obj.Path_)).RelPath;

                //TreeNode child = new TreeNode(strLabel);
                //child.ImageIndex = (int)schema_icons.SCHEMA_CLASS;
                //child.SelectedImageIndex = (int)schema_icons.SCHEMA_CLASS;

                if (WmiHelper.IsAbstract(obj))
                {
                    if (currentFilters == ClassFilters.ConcreteData)
                    {
                        return(string.Empty);
                    }
                    if (!WmiHelper.IsEvent(obj) && (currentFilters == ClassFilters.ExtrinsicEvents))
                    {
                        return(string.Empty);
                    }
                    //child.ImageIndex = (int)schema_icons.SCHEMA_CLASS_ABSTRACT2;
                    //child.SelectedImageIndex = (int)schema_icons.SCHEMA_CLASS_ABSTRACT2;
                }

                if (WmiHelper.IsAssociation(obj))
                {
                    if (currentFilters != ClassFilters.All)
                    {
                        return(string.Empty);
                    }
                    else
                    {
                        if (!WmiHelper.IsAbstract(obj))
                        {
                            //child.ImageIndex = (int)schema_icons.SCHEMA_ASSOC;
                            //child.SelectedImageIndex = (int)schema_icons.SCHEMA_ASSOC;
                        }
                        //else
                        //{//covered before, in the "abstract" case}
                    }
                }

                if (WmiHelper.IsSystem(obj))
                {
                    if (currentFilters != ClassFilters.All)
                    {
                        return(string.Empty);
                    }
                    else
                    {
                        //child.ImageIndex = (int)schema_icons.SCHEMA_CLASS_ABSTRACT2;
                        //child.SelectedImageIndex = (int)schema_icons.SCHEMA_CLASS_ABSTRACT2;
                    }
                }

                if (WmiHelper.IsEvent(obj))
                {
                    if (currentFilters == ClassFilters.ConcreteData)
                    {
                        return(string.Empty);
                    }
                    else
                    {
                        //child.ImageIndex = (int)schema_icons.SCHEMA_CLASS_ABSTRACT2;
                        //child.SelectedImageIndex = (int)schema_icons.SCHEMA_CLASS_ABSTRACT2;
                    }
                }
                else
                {
                    if (currentFilters == ClassFilters.ExtrinsicEvents)
                    {
                        return(string.Empty);
                    }
                }


                return(strLabel);
            }
            catch (Exception e)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", e.Message, e.StackTrace));
                return(string.Empty);
            }
        }