src/Misc/EFTools/DesignXmlCore/VirtualTreeGrid/Provider/VirtualTree.cs
/// <summary>
///     The displayed data for the branch has changed, and
///     any views on this tree need to be notified.
/// </summary>
/// <param name="changeData">The DisplayDataChangedData structure</param>
The displayed data for the branch has changed, and
any views on this tree need to be notified.
The displayed data for the branch has changed and any views on this tree need to be notified .
protected void DisplayDataChanged(DisplayDataChangedData changeData)
        {
            var branch = changeData.Branch;
            var column = changeData.Column;
            var changes = changeData.Changes;
            if (column >= ColumnCount)
            {
                return;
            }
            var fireNormalEvent = OnDisplayDataChanged != null;
            var fireSingleColumnEvent = column == 0 && GetStateFlag(TreeStateFlags.FireSingleColumnOnDisplayDataChanged);
            if (!(fireNormalEvent || fireSingleColumnEvent))
            {
                return;
            }
            ITree singleTree = null;
            SingleColumnView singleView = null;
            if (fireSingleColumnEvent)
            {
                singleTree = SingleColumnTree;
                singleView = singleTree as SingleColumnView;
            }
            var tn = LocateTrackedNode(branch);
            Debug.Assert(tn != null); 
            var coordinate = new VirtualTreeCoordinate();
            int prevAbsIndex;
            int prevAbsIndexSingleColumn;
            int reportCount;
            int reportCountSingleColumn;
            int count;
            int startRow;
            int singleColumnSubItemAdjust;
            while (tn != null)
            {
                prevAbsIndex = prevAbsIndexSingleColumn = -2; 
                reportCount = reportCountSingleColumn = 0;
                if (changeData.StartRow == -1)
                {
                    startRow = 0;
                    count = tn.ImmedCount;
                }
                else
                {
                    startRow = changeData.StartRow;
                    count = changeData.Count;
                }
                while (count > 0)
                {
                    coordinate = FindAbsoluteIndex(tn, startRow, out singleColumnSubItemAdjust);
                    if (coordinate.IsValid)
                    {
                        if (fireNormalEvent)
                        {
                            if (((coordinate.Row - prevAbsIndex) == 1)
                                || (reportCount == 0))
                            {
                                ++reportCount; 
                            }
                            else
                            {
                                OnDisplayDataChanged(
                                    this,
                                    new DisplayDataChangedEventArgs(
                                        this, changes, prevAbsIndex - reportCount + 1, coordinate.Column + column, reportCount));
                                reportCount = 1;
                            }
                            prevAbsIndex = coordinate.Row;
                        }
                        if (fireSingleColumnEvent && coordinate.Column == 0)
                        {
                            if (((coordinate.Row - singleColumnSubItemAdjust - prevAbsIndexSingleColumn) == 1)
                                || (reportCountSingleColumn == 0))
                            {
                                ++reportCountSingleColumn; 
                            }
                            else
                            {
                                singleView.myOnDisplayDataChanged(
                                    singleTree,
                                    new DisplayDataChangedEventArgs(
                                        singleTree, changes, prevAbsIndexSingleColumn - reportCountSingleColumn + 1, 0,
                                        reportCountSingleColumn));
                                reportCountSingleColumn = 1;
                            }
                            prevAbsIndexSingleColumn = coordinate.Row - singleColumnSubItemAdjust;
                        }
                        ++startRow;
                        --count;
                    }
                    else
                    {
                        break;
                    }
                }
                if (reportCount != 0)
                {
                    OnDisplayDataChanged(
                        this,
                        new DisplayDataChangedEventArgs(
                            this, changes, prevAbsIndex - reportCount + 1, coordinate.Column + column, reportCount));
                }
                if (reportCountSingleColumn != 0)
                {
                    singleView.myOnDisplayDataChanged(
                        singleTree,
                        new DisplayDataChangedEventArgs(
                            singleTree, changes, prevAbsIndexSingleColumn - reportCountSingleColumn + 1, 0, reportCountSingleColumn));
                }
                tn = tn.NextNode;
            }
        }
protected void DisplayDataChanged ( DisplayDataChangedData changeData ) { var branch = changeData . Branch ; var column = changeData . Column ; var changes = changeData . Changes ; if ( column >= ColumnCount ) { return ; } var fireNormalEvent = OnDisplayDataChanged != null ; var fireSingleColumnEvent = column == 0 && GetStateFlag ( TreeStateFlags . FireSingleColumnOnDisplayDataChanged ) ; if ( ! ( fireNormalEvent || fireSingleColumnEvent ) ) { return ; } ITree singleTree = null ; SingleColumnView singleView = null ; if ( fireSingleColumnEvent ) { singleTree = SingleColumnTree ; singleView = singleTree as SingleColumnView ; } var tn = LocateTrackedNode ( branch ) ; Debug . Assert ( tn != null ) ; var coordinate = new VirtualTreeCoordinate ( ) ; int prevAbsIndex ; int prevAbsIndexSingleColumn ; int reportCount ; int reportCountSingleColumn ; int count ; int startRow ; int singleColumnSubItemAdjust ; while ( tn != null ) { prevAbsIndex = prevAbsIndexSingleColumn = - 2 ; reportCount = reportCountSingleColumn = 0 ; if ( changeData . StartRow == - 1 ) { startRow = 0 ; count = tn . ImmedCount ; } else { startRow = changeData . StartRow ; count = changeData . Count ; } while ( count > 0 ) { coordinate = FindAbsoluteIndex ( tn , startRow , out singleColumnSubItemAdjust ) ; if ( coordinate . IsValid ) { if ( fireNormalEvent ) { if ( ( ( coordinate . Row - prevAbsIndex ) == 1 ) || ( reportCount == 0 ) ) { ++ reportCount ; } else { OnDisplayDataChanged ( this , new DisplayDataChangedEventArgs ( this , changes , prevAbsIndex - reportCount + 1 , coordinate . Column + column , reportCount ) ) ; reportCount = 1 ; } prevAbsIndex = coordinate . Row ; } if ( fireSingleColumnEvent && coordinate . Column == 0 ) { if ( ( ( coordinate . Row - singleColumnSubItemAdjust - prevAbsIndexSingleColumn ) == 1 ) || ( reportCountSingleColumn == 0 ) ) { ++ reportCountSingleColumn ; } else { singleView . myOnDisplayDataChanged ( singleTree , new DisplayDataChangedEventArgs ( singleTree , changes , prevAbsIndexSingleColumn - reportCountSingleColumn + 1 , 0 , reportCountSingleColumn ) ) ; reportCountSingleColumn = 1 ; } prevAbsIndexSingleColumn = coordinate . Row - singleColumnSubItemAdjust ; } ++ startRow ; -- count ; } else { break ; } } if ( reportCount != 0 ) { OnDisplayDataChanged ( this , new DisplayDataChangedEventArgs ( this , changes , prevAbsIndex - reportCount + 1 , coordinate . Column + column , reportCount ) ) ; } if ( reportCountSingleColumn != 0 ) { singleView . myOnDisplayDataChanged ( singleTree , new DisplayDataChangedEventArgs ( singleTree , changes , prevAbsIndexSingleColumn - reportCountSingleColumn + 1 , 0 , reportCountSingleColumn ) ) ; } tn = tn . NextNode ; } }
The displayed data for the branch has changed, and
any views on this tree need to be notified.
The displayed data for the branch has changed and any views on this tree need to be notified .
//Expect LocateTrackedNode to throw otherwise //UNDONE: Does firing the event after we get the next node adversely affect the //performance of the node tracking algorithm. // Set to -2 so that first diff check is never 1 //Wait to fire the event until we find something discontiguous //Wait to fire the event until we find something discontiguous
changeData
DisplayDataChangedData
The DisplayDataChangedData structure
The DisplayDataChangedData structure