Ejemplo n.º 1
0
        private void Refresh(bool fullRefresh, int rowStart, int rowEnd) {
            Debug.WriteLineIf(CompModSwitches.DebugGridView.TraceVerbose,  "PropertyGridView:Refresh");
            Debug.WriteLineIf(GridViewDebugPaint.TraceVerbose,  "Refresh called for rows " + rowStart.ToString(CultureInfo.InvariantCulture) + " through " + rowEnd.ToString(CultureInfo.InvariantCulture));
            SetFlag(FlagNeedsRefresh, true);
            GridEntry gridEntry = null;

            // VSWhidbey 361345 -- there are cases here where the grid could get be disposed.
            // so just bail.
            if (this.IsDisposed) {
                return;
            }

            bool pageInGridEntry = true;
            
            if (rowStart == -1) {
                rowStart = 0;
            }
            
            if (fullRefresh || this.ownerGrid.HavePropEntriesChanged()) {
                if (HasEntries && !GetInPropertySet() && !Commit()) {
                    OnEscape(this);
                }
                
                int oldLength = totalProps;
                object oldObject = topLevelGridEntries == null || topLevelGridEntries.Count == 0 ? null : ((GridEntry)topLevelGridEntries[0]).GetValueOwner();
                
                // walk up to the main IPE and refresh it.
                if (fullRefresh) {
                    this.ownerGrid.RefreshProperties(true);
                }
                
                if (oldLength > 0 && !GetFlag(FlagNoDefault)) {
                     positionData = CaptureGridPositionData();
                     CommonEditorHide(true);
                }

                UpdateHelpAttributes(selectedGridEntry, null);
                selectedGridEntry = null;
                SetFlag(FlagIsNewSelection, true);
                topLevelGridEntries = this.ownerGrid.GetPropEntries();
                
                
                ClearGridEntryEvents(allGridEntries, 0, -1);
                allGridEntries = null;
                RecalculateProps();
                
                int newLength = totalProps;
                if (newLength > 0) {
                    if (newLength < oldLength) {
                        SetScrollbarLength();
                        SetScrollOffset(0);
                    }
                   
                    SetConstants();

                    if (positionData != null) {
                        gridEntry = positionData.Restore(this);

                        // Upon restoring the grid entry position, we don't
                        // want to page it in
                        //
                        object newObject = topLevelGridEntries == null || topLevelGridEntries.Count == 0 ? null : ((GridEntry)topLevelGridEntries[0]).GetValueOwner();
                        pageInGridEntry = (gridEntry == null) || oldLength != newLength || newObject != oldObject;
                    }
                   
                    if (gridEntry == null) {
                        gridEntry = this.ownerGrid.GetDefaultGridEntry();
                        SetFlag(FlagNoDefault, gridEntry == null && totalProps > 0);
                    }

                    InvalidateRows(rowStart, rowEnd);
                    if (gridEntry == null) {
                        selectedRow = 0;
                        selectedGridEntry = GetGridEntryFromRow(selectedRow);
                    }
                }
                else if (oldLength == 0) {
                    return;
                }
                else {
                    SetConstants();
                }


                // Release the old positionData which contains reference to previous selected objects.
                positionData = null;
                lastClickedEntry = null;
            }

            if (!HasEntries) {
                CommonEditorHide(selectedRow != -1);
                this.ownerGrid.SetStatusBox(null, null);
                SetScrollOffset(0);
                selectedRow = -1;
                Invalidate();
                return;
            }
            // in case we added or removed properties
            
            ownerGrid.ClearValueCaches();

            InvalidateRows(rowStart, rowEnd);

            if (gridEntry != null) {
                SelectGridEntry(gridEntry, pageInGridEntry);
            }
        }
 private void Refresh(bool fullRefresh, int rowStart, int rowEnd)
 {
     this.SetFlag(1, true);
     GridEntry gridEntry = null;
     if (!base.IsDisposed)
     {
         bool fPageIn = true;
         if (rowStart == -1)
         {
             rowStart = 0;
         }
         if (fullRefresh || this.ownerGrid.HavePropEntriesChanged())
         {
             if ((this.HasEntries && !this.GetInPropertySet()) && !this.Commit())
             {
                 this.OnEscape(this);
             }
             int totalProps = this.totalProps;
             object obj2 = ((this.topLevelGridEntries == null) || (this.topLevelGridEntries.Count == 0)) ? null : ((GridEntry) this.topLevelGridEntries[0]).GetValueOwner();
             if (fullRefresh)
             {
                 this.ownerGrid.RefreshProperties(true);
             }
             if ((totalProps > 0) && !this.GetFlag(0x200))
             {
                 this.positionData = this.CaptureGridPositionData();
                 this.CommonEditorHide(true);
             }
             this.UpdateHelpAttributes(this.selectedGridEntry, null);
             this.selectedGridEntry = null;
             this.SetFlag(2, true);
             this.topLevelGridEntries = this.ownerGrid.GetPropEntries();
             this.ClearGridEntryEvents(this.allGridEntries, 0, -1);
             this.allGridEntries = null;
             this.RecalculateProps();
             int num2 = this.totalProps;
             if (num2 > 0)
             {
                 if (num2 < totalProps)
                 {
                     this.SetScrollbarLength();
                     this.SetScrollOffset(0);
                 }
                 this.SetConstants();
                 if (this.positionData != null)
                 {
                     gridEntry = this.positionData.Restore(this);
                     object obj3 = ((this.topLevelGridEntries == null) || (this.topLevelGridEntries.Count == 0)) ? null : ((GridEntry) this.topLevelGridEntries[0]).GetValueOwner();
                     fPageIn = ((gridEntry == null) || (totalProps != num2)) || (obj3 != obj2);
                 }
                 if (gridEntry == null)
                 {
                     gridEntry = this.ownerGrid.GetDefaultGridEntry();
                     this.SetFlag(0x200, (gridEntry == null) && (this.totalProps > 0));
                 }
                 this.InvalidateRows(rowStart, rowEnd);
                 if (gridEntry == null)
                 {
                     this.selectedRow = 0;
                     this.selectedGridEntry = this.GetGridEntryFromRow(this.selectedRow);
                 }
             }
             else
             {
                 if (totalProps == 0)
                 {
                     return;
                 }
                 this.SetConstants();
             }
             this.positionData = null;
             this.lastClickedEntry = null;
         }
         if (!this.HasEntries)
         {
             this.CommonEditorHide(this.selectedRow != -1);
             this.ownerGrid.SetStatusBox(null, null);
             this.SetScrollOffset(0);
             this.selectedRow = -1;
             base.Invalidate();
         }
         else
         {
             this.ownerGrid.ClearValueCaches();
             this.InvalidateRows(rowStart, rowEnd);
             if (gridEntry != null)
             {
                 this.SelectGridEntry(gridEntry, fPageIn);
             }
         }
     }
 }