src/Misc/EFTools/DesignXmlCore/VirtualTreeGrid/Provider/VirtualTree.cs
/// <summary>
///     Use to insert items without forcing a realign. InsertItems should be used
///     to adjust an existing branch: do not add a node with no children then immediately
///     call InsertItems repeatedly to add children. The branches VisibleItemCount is
///     assumed to be adjusted for the new items before a call to InsertItems. If the
///     items are inserted at the end of the visible portion of the branch, then
///     VisibleItemCount will be used to determine if the new items are hidden or visible.
/// </summary>
/// <param name="branch">The branch where items have been inserted.</param>
/// <param name="after">The index to insert after. Use -1 to insert at the beginning</param>
/// <param name="count">The number of items that have been inserted.</param>
Use to insert items without forcing a realign. InsertItems should be used
to adjust an existing branch: do not add a node with no children then immediately
call InsertItems repeatedly to add children. The branches VisibleItemCount is
assumed to be adjusted for the new items before a call to InsertItems. If the
items are inserted at the end of the visible portion of the branch, then
VisibleItemCount will be used to determine if the new items are hidden or visible.
Use to insert items without forcing a realign . InsertItems should be used to adjust an existing branch : do not add a node with no children then immediately call InsertItems repeatedly to add children . The branches VisibleItemCount is assumed to be adjusted for the new items before a call to InsertItems . If the items are inserted at the end of the visible portion of the branch then VisibleItemCount will be used to determine if the new items are hidden or visible .
protected void InsertItems(IBranch branch, int after, int count)
        {
            var tn = LocateTrackedNode(branch);
            Debug.Assert(tn != null); 
            if (after < 0)
            {
                after = -1;
            }
            if (after == -1
                ||
                after < tn.ImmedCount)
            {
                TREENODE tnChild;
                int singleColumnAbsIndex;
                while (tn != null)
                {
                    tnChild = tn.FirstChild;
                    while (tnChild != null)
                    {
                        if (after < tnChild.Index)
                        {
                            break;
                        }
                        tnChild = tnChild.NextSibling;
                    }
                    while (tnChild != null)
                    {
                        tnChild.Index += count;
                        tnChild = tnChild.NextSibling;
                    }
                    tn.ImmedCount += count;
                    ChangeFullCountRecursive(
                        tn, count, 0 );
                    if ((count != 0)
                        && ((ItemCountChanged != null)
                            || (GetStateFlag(TreeStateFlags.FireSingleColumnItemCountChanged) && 0 == COLUMN_ZERO)))
                    {
                        var coord = EnumAbsoluteIndices(after + 1, ref tn, out singleColumnAbsIndex);
                        if (coord.IsValid)
                        {
                            if (ItemCountChanged != null)
                            {
                                DelayTurnOffRedraw();
                                ItemCountChanged(
                                    this,
                                    new ItemCountChangedEventArgs(this, coord.Row - 1, coord.Column, count, coord.Row - 1, 0, null, false));
                            }
                            if (singleColumnAbsIndex != VirtualTreeConstant.NullIndex
                                && GetStateFlag(TreeStateFlags.FireSingleColumnItemCountChanged))
                            {
                                DelayTurnOffSingleColumnRedraw();
                                --singleColumnAbsIndex;
                                var singleTree = SingleColumnTree;
                                (singleTree as SingleColumnView).myItemCountChanged(
                                    singleTree,
                                    new ItemCountChangedEventArgs(
                                        singleTree, singleColumnAbsIndex, 0, count, singleColumnAbsIndex, 0, null, false));
                            }
                        }
                    }
                    else
                    {
                        tn = tn.NextNode;
                    }
                }
                ClearPositionCache(); 
            }
        }
protected void InsertItems ( IBranch branch , int after , int count ) { var tn = LocateTrackedNode ( branch ) ; Debug . Assert ( tn != null ) ; if ( after < 0 ) { after = - 1 ; } if ( after == - 1 || after < tn . ImmedCount ) { TREENODE tnChild ; int singleColumnAbsIndex ; while ( tn != null ) { tnChild = tn . FirstChild ; while ( tnChild != null ) { if ( after < tnChild . Index ) { break ; } tnChild = tnChild . NextSibling ; } while ( tnChild != null ) { tnChild . Index += count ; tnChild = tnChild . NextSibling ; } tn . ImmedCount += count ; ChangeFullCountRecursive ( tn , count , 0 ) ; if ( ( count != 0 ) && ( ( ItemCountChanged != null ) || ( GetStateFlag ( TreeStateFlags . FireSingleColumnItemCountChanged ) && 0 == COLUMN_ZERO ) ) ) { var coord = EnumAbsoluteIndices ( after + 1 , ref tn , out singleColumnAbsIndex ) ; if ( coord . IsValid ) { if ( ItemCountChanged != null ) { DelayTurnOffRedraw ( ) ; ItemCountChanged ( this , new ItemCountChangedEventArgs ( this , coord . Row - 1 , coord . Column , count , coord . Row - 1 , 0 , null , false ) ) ; } if ( singleColumnAbsIndex != VirtualTreeConstant . NullIndex && GetStateFlag ( TreeStateFlags . FireSingleColumnItemCountChanged ) ) { DelayTurnOffSingleColumnRedraw ( ) ; -- singleColumnAbsIndex ; var singleTree = SingleColumnTree ; ( singleTree as SingleColumnView ) . myItemCountChanged ( singleTree , new ItemCountChangedEventArgs ( singleTree , singleColumnAbsIndex , 0 , count , singleColumnAbsIndex , 0 , null , false ) ) ; } } } else { tn = tn . NextNode ; } } ClearPositionCache ( ) ; } }
Use to insert items without forcing a realign.
Use to insert items without forcing a realign .
//Expect LocateTrackedNode to throw otherwise /*UNDONE_MC, also need to expand initial complex sub items for newly inserted items*/ // UNDONE_MC: Fold the OnToggleExpansion, OnInsertItems, OnDeleteItems // into one event so we don't have to duplicate as much stuff for // multi column support. If we're adding the item to the first row // of a complex branch, then this is not sufficient information. // It only works with the control right now because the expansion // routines are not optimized for drawing. // UNDONE_NOW: //ItemsInserted(this, --absIndex, count); //Cached absolute information is toast.
branch
IBranch
The branch where items have been inserted.
The branch where items have been inserted .
after
int
The index to insert after. Use -1 to insert at the beginning
The index to insert after . Use - 1 to insert at the beginning
count
int
The number of items that have been inserted.
The number of items that have been inserted .