protected override bool CreateChildren(bool diffOldChildren)
        {
            try
            {
                if (mergedPd.PropertyType.IsValueType || (Flags & GridEntry.FLAG_IMMUTABLE) != 0)
                {
                    return(base.CreateChildren(diffOldChildren));
                }

                ChildCollection.Clear();

                MultiPropertyDescriptorGridEntry[] mergedProps = MultiSelectRootGridEntry.PropertyMerger.GetMergedProperties(mergedPd.GetValues(objs), this, PropertySort, CurrentTab);

                Debug.WriteLineIf(CompModSwitches.DebugGridView.TraceVerbose && mergedProps is null, "PropertyGridView: MergedProps returned null!");

                if (mergedProps != null)
                {
                    ChildCollection.AddRange(mergedProps);
                }
                bool fExpandable = Children.Count > 0;
                if (!fExpandable)
                {
                    SetFlag(GridEntry.FL_EXPANDABLE_FAILED, true);
                }
                return(fExpandable);
            }
            catch
            {
                return(false);
            }
        }
예제 #2
0
        protected override bool CreateChildren(bool diffOldChildren)
        {
            try {
                object[] rgobjs = (object[])objValue;


                ChildCollection.Clear();

                MultiPropertyDescriptorGridEntry[] mergedProps = PropertyMerger.GetMergedProperties(rgobjs, this, this.PropertySort, CurrentTab);

                Debug.WriteLineIf(CompModSwitches.DebugGridView.TraceVerbose && mergedProps == null, "PropertyGridView: MergedProps returned null!");

                if (mergedProps != null)
                {
                    ChildCollection.AddRange(mergedProps);
                }
                bool fExpandable = this.Children.Count > 0;
                if (!fExpandable)
                {
                    //Debug.WriteLine("Object " + rgobjs[0].GetType().FullName + " is not expandable because it has no children");
                    SetFlag(GridEntry.FL_EXPANDABLE_FAILED, true);
                }
                CategorizePropEntries();
                return(fExpandable);
            }
            catch {
                return(false);
            }
        }
        protected override bool CreateChildren(bool diffOldChildren)
        {
            try {
                if (mergedPd.PropertyType.IsValueType || (Flags & GridEntry.FLAG_IMMUTABLE) != 0)
                {
                    return(base.CreateChildren(diffOldChildren));
                }

                ChildCollection.Clear();

                MultiPropertyDescriptorGridEntry[] mergedProps = MultiSelectRootGridEntry.PropertyMerger.GetMergedProperties(mergedPd.GetValues(objs), this, this.PropertySort, this.CurrentTab);

                Debug.Assert(mergedProps != null, "MergedProps returned null!");

                if (mergedProps != null)
                {
                    ChildCollection.AddRange(mergedProps);
                }
                bool fExpandable = this.Children.Count > 0;
                if (!fExpandable)
                {
                    SetFlag(GridEntry.FL_EXPANDABLE_FAILED, true);
                }
                return(fExpandable);
            }
            catch (Exception) {
                return(false);
            }
        }
        protected override bool CreateChildren(bool diffOldChildren = false)
        {
            try
            {
                if (_mergedDescriptor.PropertyType.IsValueType || EntryFlags.HasFlag(Flags.Immutable))
                {
                    return(base.CreateChildren(diffOldChildren));
                }

                ChildCollection.Clear();

                var mergedProperties = MultiSelectRootGridEntry.PropertyMerger.GetMergedProperties(
                    _mergedDescriptor.GetValues(_objects),
                    this,
                    _propertySort,
                    OwnerTab);

                Debug.WriteLineIf(
                    CompModSwitches.DebugGridView.TraceVerbose && mergedProperties is null,
                    "PropertyGridView: MergedProps returned null!");

                if (mergedProperties is not null)
                {
                    ChildCollection.AddRange(mergedProperties);
                }

                bool expandable = Children.Count > 0;
                if (!expandable)
                {
                    SetFlag(Flags.ExpandableFailed, true);
                }

                return(expandable);
            }
            catch (Exception e)
            {
                Debug.Fail(e.Message);
                return(false);
            }
        }
        internal void CategorizePropEntries()
        {
            if (Children.Count > 0)
            {
                GridEntry[] childEntries = new GridEntry[this.Children.Count];
                this.Children.CopyTo(childEntries, 0);

                if ((this.PropertySort & PropertySort.Categorized) != 0)
                {
                    // first, walk through all the entires and
                    // group them by their category by adding
                    // them to a hashtable of arraylists.
                    //
                    Hashtable bins = new Hashtable();
                    for (int i = 0; i < childEntries.Length; i++)
                    {
                        GridEntry pe = childEntries[i];
                        Debug.Assert(pe != null);
                        if (pe != null)
                        {
                            string    category = pe.PropertyCategory;
                            ArrayList bin      = (ArrayList)bins[category];
                            if (bin == null)
                            {
                                bin            = new ArrayList();
                                bins[category] = bin;
                            }
                            bin.Add(pe);
                        }
                    }

                    // now walk through the hashtable
                    // and create a categorygridentry for each
                    // category that holds all the properties
                    // of that category.
                    //
                    ArrayList             propList = new ArrayList();
                    IDictionaryEnumerator enumBins = (IDictionaryEnumerator)bins.GetEnumerator();
                    while (enumBins.MoveNext())
                    {
                        ArrayList bin = (ArrayList)enumBins.Value;
                        if (bin != null)
                        {
                            string category = (string)enumBins.Key;
                            if (bin.Count > 0)
                            {
                                GridEntry[] rgpes = new GridEntry[bin.Count];
                                bin.CopyTo(rgpes, 0);
                                try {
                                    propList.Add(new CategoryGridEntry(this.ownerGrid, this, category, rgpes));
                                }
                                catch {
                                }
                            }
                        }
                    }

                    childEntries = new GridEntry[propList.Count];
                    propList.CopyTo(childEntries, 0);
                    StringSorter.Sort(childEntries);

                    ChildCollection.Clear();
                    ChildCollection.AddRange(childEntries);
                }
            }
        }