示例#1
0
        // a GridEntry recreated its children
        protected virtual void OnRecreateChildren(object s, GridEntryRecreateChildrenEventArgs e) {
            GridEntry parent = (GridEntry) s;

            if (parent.Expanded) {
                                          
                GridEntry[] entries = new GridEntry[allGridEntries.Count];
                allGridEntries.CopyTo(entries, 0);
                
                // find the index of the gridEntry that fired the event in our main list.
                int parentIndex = -1;
                for (int i = 0; i < entries.Length; i++) {
                    if (entries[i] == parent) {
                        parentIndex = i;
                        break;
                    }
                }
                
                Debug.Assert(parentIndex != -1, "parent GridEntry not found in allGridEntries");
                
                // clear our existing handlers
                ClearGridEntryEvents(allGridEntries, parentIndex + 1, e.OldChildCount);
                
                // resize the array if it's changed
                if (e.OldChildCount != e.NewChildCount) {
                    int newArraySize = entries.Length + (e.NewChildCount - e.OldChildCount);
                    GridEntry[] newEntries = new GridEntry[newArraySize];
                    
                    // copy the existing entries up to the parent
                    Array.Copy(entries, 0, newEntries, 0, parentIndex + 1);
                    
                    // copy the entries after the spot we'll be putting the new ones
                    Array.Copy(entries, parentIndex + e.OldChildCount+1, newEntries, parentIndex + e.NewChildCount+1, entries.Length - (parentIndex + e.OldChildCount + 1));
                    
                    entries = newEntries;
                }
                
                // from that point, replace the children with tne new children.
                GridEntryCollection children = parent.Children;
                int childCount = children.Count;
                
                Debug.Assert(childCount == e.NewChildCount, "parent reports " + childCount + " new children, event reports " + e.NewChildCount);
                
                // replace the changed items
                for (int i = 0; i < childCount; i++) {
                    entries[parentIndex + i + 1] = children.GetEntry(i);
                }
                
                // reset the array, rehook the handlers.
                allGridEntries.Clear();
                allGridEntries.AddRange(entries);
                AddGridEntryEvents(allGridEntries, parentIndex + 1, childCount);            
                
            }

            if (e.OldChildCount != e.NewChildCount) {
                totalProps = CountPropsFromOutline(topLevelGridEntries);
                SetConstants();
            }
            Invalidate();
        }
示例#2
0
 /// <include file='doc\GridEntry.uex' path='docs/doc[@for="GridEntry.OnRecreateChildren"]/*' />
 /// <devdoc>
 /// Called when RecreateChildren is called.
 /// Default implmentation fired the event to any listeners, so be sure
 /// to call base.OnOutlineDoubleClick(e) if this is overrideen.
 /// </devdoc>
 protected virtual void OnRecreateChildren(GridEntryRecreateChildrenEventArgs e) {
     Delegate handler = GetEventHandler(EVENT_RECREATE_CHILDREN);
     if (handler != null) ((GridEntryRecreateChildrenEventHandler)handler)(this, e);
 }
 protected virtual void OnRecreateChildren(object s, GridEntryRecreateChildrenEventArgs e)
 {
     GridEntry entry = (GridEntry) s;
     if (entry.Expanded)
     {
         GridEntry[] dest = new GridEntry[this.allGridEntries.Count];
         this.allGridEntries.CopyTo(dest, 0);
         int num = -1;
         for (int i = 0; i < dest.Length; i++)
         {
             if (dest[i] == entry)
             {
                 num = i;
                 break;
             }
         }
         this.ClearGridEntryEvents(this.allGridEntries, num + 1, e.OldChildCount);
         if (e.OldChildCount != e.NewChildCount)
         {
             int num3 = dest.Length + (e.NewChildCount - e.OldChildCount);
             GridEntry[] destinationArray = new GridEntry[num3];
             Array.Copy(dest, 0, destinationArray, 0, num + 1);
             Array.Copy(dest, (int) ((num + e.OldChildCount) + 1), destinationArray, (int) ((num + e.NewChildCount) + 1), (int) (dest.Length - ((num + e.OldChildCount) + 1)));
             dest = destinationArray;
         }
         GridEntryCollection children = entry.Children;
         int count = children.Count;
         for (int j = 0; j < count; j++)
         {
             dest[(num + j) + 1] = children.GetEntry(j);
         }
         this.allGridEntries.Clear();
         this.allGridEntries.AddRange(dest);
         this.AddGridEntryEvents(this.allGridEntries, num + 1, count);
     }
     if (e.OldChildCount != e.NewChildCount)
     {
         this.totalProps = this.CountPropsFromOutline(this.topLevelGridEntries);
         this.SetConstants();
     }
     base.Invalidate();
 }