src/Misc/EFTools/DesignXmlCore/VirtualTreeGrid/Provider/VirtualTree.cs
/// <summary>
///     Used by IMultiColumnTree.UpdateCellStyle implementations in derived classes
/// </summary>
/// <param name="branch">Target branch</param>
/// <param name="row">Target row</param>
/// <param name="column">Target column</param>
/// <param name="makeComplex">Action to take</param>
Used by IMultiColumnTree.UpdateCellStyle implementations in derived classes
Used by IMultiColumnTree . UpdateCellStyle implementations in derived classes
protected void UpdateCellStyle(IBranch branch, int row, int column, bool makeComplex)
        {
            var tnNext = LocateTrackedNode(branch);
            Debug.Assert(tnNext != null); 
            var keyOffSubItemRoot = !makeComplex && row == -1 && column == 0;
            if (!keyOffSubItemRoot)
            {
                var mcBranch = (IMultiColumnBranch)branch;
                if (row < 0
                    || row > tnNext.ImmedCount)
                {
                    throw new ArgumentOutOfRangeException("row");
                }
                var columnStyle = mcBranch.ColumnStyles(column);
                if (0 == (columnStyle & SubItemCellStyles.Complex))
                {
                    throw new ArgumentException(VirtualTreeStrings.GetString(VirtualTreeStrings.ComplexColumnCellStyleException));
                }
            }
            var absColumn = column;
            TREENODE tnChild;
            TREENODE tnPrevChild;
            SUBITEMNODE sn;
            SUBITEMNODE snPrev;
            ExpansionOptions options;
            int itemIncr;
            int subItemIncr;
            TREENODE tnNewSubItem;
            TREENODE tnParent;
            while (tnNext != null)
            {
                tnParent = tnNext;
                if (keyOffSubItemRoot)
                {
                    if (!tnNext.ComplexSubItem)
                    {
                        tnNext = tnParent.NextNode;
                        continue;
                    }
                    tnPrevChild = null;
                    tnChild = tnNext.Parent;
                    column = tnChild.FirstSubItem.ColumnOfRootNode(tnNext);
                    sn = tnChild.SubItemAtColumn(column, out snPrev);
                    tnNext = tnChild.Parent;
                    row = tnChild.Index;
                }
                else
                {
                    tnChild = tnParent.GetChildNode(row, out tnPrevChild);
                    if (tnChild != null)
                    {
                        sn = tnChild.SubItemAtColumn(column, out snPrev);
                    }
                    else
                    {
                        sn = snPrev = null;
                    }
                }
                if ((sn == null) == makeComplex)
                {
                    if (makeComplex)
                    {
                        tnNewSubItem = ExpandTreeNode(
                            tnParent,
                            null,
                            row,
                            column,
                            ObjectStyle.SubItemRootBranch,
                            false,
                            out options,
                            out itemIncr,
                            out subItemIncr);
                        if (tnNewSubItem == null)
                        {
                            tnNext = tnParent.NextNode;
                            continue;
                        }
                        if (tnChild == null)
                        {
                            tnChild = new TREENODE_Complex();
                            tnChild.Index = row;
                            InsertIndexedNode(tnParent, tnChild, ref tnPrevChild);
                        }
                        tnNewSubItem.SubItemRoot = true;
                        if (0 == (options & ExpansionOptions.UseAsSubItemExpansion))
                        {
                            tnNewSubItem.ComplexSubItem = true;
                        }
                        tnNewSubItem.Index = VirtualTreeConstant.NullIndex;
                        tnNewSubItem.Parent = tnChild;
                        sn = new SUBITEMNODE();
                        sn.Column = column;
                        sn.RootNode = tnNewSubItem;
                        if (snPrev == null)
                        {
                            sn.NextSibling = tnChild.FirstSubItem;
                            tnChild.FirstSubItem = sn;
                        }
                        else
                        {
                            sn.NextSibling = snPrev.NextSibling;
                            snPrev.NextSibling = sn;
                        }
                    }
                    else
                    {
                        if (snPrev == null)
                        {
                            tnChild.FirstSubItem = sn.NextSibling;
                        }
                        else
                        {
                            snPrev.NextSibling = sn.NextSibling;
                        }
                        FreeRecursive(ref sn.RootNode);
                    }
                    subItemIncr = tnChild.AdjustSubItemGain();
                    if (subItemIncr != 0)
                    {
                        if (ItemCountChanged != null)
                        {
                            int dummySingleColumnAbsRow; 
                            var absRow = EnumAbsoluteIndices(row, ref tnNext, out dummySingleColumnAbsRow).Row;
                            if (absRow != VirtualTreeConstant.NullIndex)
                            {
                                SubItemColumnAdjustment[] subItemChanges;
                                var parentRowOffset = 0;
                                var affectedSubItemColumns = new AffectedSubItems(true);
                                var singleColumnSubItemAdjust = 0;
                                int rowIncr;
                                var adjustColumn = absColumn;
                                TrackCell(
                                    absRow, ref adjustColumn, ref parentRowOffset, ref affectedSubItemColumns, ref singleColumnSubItemAdjust);
                                Debug.Assert(adjustColumn == 0);
                                ChangeFullCountRecursive(
                                    tnChild, 0, subItemIncr, null, ref affectedSubItemColumns, out rowIncr, out subItemChanges);
                                DelayTurnOffRedraw();
                                ItemCountChanged(
                                    this,
                                    new ItemCountChangedEventArgs(
                                        this, absRow, absColumn, rowIncr, absRow - 1, tnChild.ImmedSubItemGain, subItemChanges, true));
                                tnNext = tnParent.NextNode;
                                continue;
                            }
                        }
                        ChangeFullCountRecursive(tnChild, 0, subItemIncr);
                    }
                    else
                    {
                    }
                }
                tnNext = tnParent.NextNode;
            }
            ClearPositionCache(); 
        }
protected void UpdateCellStyle ( IBranch branch , int row , int column , bool makeComplex ) { var tnNext = LocateTrackedNode ( branch ) ; Debug . Assert ( tnNext != null ) ; var keyOffSubItemRoot = ! makeComplex && row == - 1 && column == 0 ; if ( ! keyOffSubItemRoot ) { var mcBranch = ( IMultiColumnBranch ) branch ; if ( row < 0 || row > tnNext . ImmedCount ) { throw new ArgumentOutOfRangeException ( " " ) ; } var columnStyle = mcBranch . ColumnStyles ( column ) ; if ( 0 == ( columnStyle & SubItemCellStyles . Complex ) ) { throw new ArgumentException ( VirtualTreeStrings . GetString ( VirtualTreeStrings . ComplexColumnCellStyleException ) ) ; } } var absColumn = column ; TREENODE tnChild ; TREENODE tnPrevChild ; SUBITEMNODE sn ; SUBITEMNODE snPrev ; ExpansionOptions options ; int itemIncr ; int subItemIncr ; TREENODE tnNewSubItem ; TREENODE tnParent ; while ( tnNext != null ) { tnParent = tnNext ; if ( keyOffSubItemRoot ) { if ( ! tnNext . ComplexSubItem ) { tnNext = tnParent . NextNode ; continue ; } tnPrevChild = null ; tnChild = tnNext . Parent ; column = tnChild . FirstSubItem . ColumnOfRootNode ( tnNext ) ; sn = tnChild . SubItemAtColumn ( column , out snPrev ) ; tnNext = tnChild . Parent ; row = tnChild . Index ; } else { tnChild = tnParent . GetChildNode ( row , out tnPrevChild ) ; if ( tnChild != null ) { sn = tnChild . SubItemAtColumn ( column , out snPrev ) ; } else { sn = snPrev = null ; } } if ( ( sn == null ) == makeComplex ) { if ( makeComplex ) { tnNewSubItem = ExpandTreeNode ( tnParent , null , row , column , ObjectStyle . SubItemRootBranch , false , out options , out itemIncr , out subItemIncr ) ; if ( tnNewSubItem == null ) { tnNext = tnParent . NextNode ; continue ; } if ( tnChild == null ) { tnChild = new TREENODE_Complex ( ) ; tnChild . Index = row ; InsertIndexedNode ( tnParent , tnChild , ref tnPrevChild ) ; } tnNewSubItem . SubItemRoot = true ; if ( 0 == ( options & ExpansionOptions . UseAsSubItemExpansion ) ) { tnNewSubItem . ComplexSubItem = true ; } tnNewSubItem . Index = VirtualTreeConstant . NullIndex ; tnNewSubItem . Parent = tnChild ; sn = new SUBITEMNODE ( ) ; sn . Column = column ; sn . RootNode = tnNewSubItem ; if ( snPrev == null ) { sn . NextSibling = tnChild . FirstSubItem ; tnChild . FirstSubItem = sn ; } else { sn . NextSibling = snPrev . NextSibling ; snPrev . NextSibling = sn ; } } else { if ( snPrev == null ) { tnChild . FirstSubItem = sn . NextSibling ; } else { snPrev . NextSibling = sn . NextSibling ; } FreeRecursive ( ref sn . RootNode ) ; } subItemIncr = tnChild . AdjustSubItemGain ( ) ; if ( subItemIncr != 0 ) { if ( ItemCountChanged != null ) { int dummySingleColumnAbsRow ; var absRow = EnumAbsoluteIndices ( row , ref tnNext , out dummySingleColumnAbsRow ) . Row ; if ( absRow != VirtualTreeConstant . NullIndex ) { SubItemColumnAdjustment [ ] subItemChanges ; var parentRowOffset = 0 ; var affectedSubItemColumns = new AffectedSubItems ( true ) ; var singleColumnSubItemAdjust = 0 ; int rowIncr ; var adjustColumn = absColumn ; TrackCell ( absRow , ref adjustColumn , ref parentRowOffset , ref affectedSubItemColumns , ref singleColumnSubItemAdjust ) ; Debug . Assert ( adjustColumn == 0 ) ; ChangeFullCountRecursive ( tnChild , 0 , subItemIncr , null , ref affectedSubItemColumns , out rowIncr , out subItemChanges ) ; DelayTurnOffRedraw ( ) ; ItemCountChanged ( this , new ItemCountChangedEventArgs ( this , absRow , absColumn , rowIncr , absRow - 1 , tnChild . ImmedSubItemGain , subItemChanges , true ) ) ; tnNext = tnParent . NextNode ; continue ; } } ChangeFullCountRecursive ( tnChild , 0 , subItemIncr ) ; } else { } } tnNext = tnParent . NextNode ; } ClearPositionCache ( ) ; }
Used by IMultiColumnTree.UpdateCellStyle implementations in derived classes
Used by IMultiColumnTree . UpdateCellStyle implementations in derived classes
//Expect LocateTrackedNode to throw otherwise // Do an exception-inducing cast here. The branch must be a multi-column // UNDONE_MC: This is a branch-relative column value, which may not be the absolute // column in the grid. Need a good way of either calculating or storing the absolute // column for a given branch. The unused Index property on a SubItemRoot node is a good // candidate slot for this data, which would minimize recursion required to calculate this. // UNDONE_MC: This is not correct for the nested complex scenario. Calculate // an accurate absolute column for each branch usage. // Set up all of the variables to be just like the keying off // the parent branch. // We either need a subitem node and a move to not being complex, or not subitem // node and a move to complex. This condition satisfies both so we can combine some processing. // See comments in ExpandInitialComplexSubItems // Delete the expansion // This action does not affect the single column view // We need to track all of this for expanded nodes to get the correct information for the event. // TrackCell is currently broken for all values after absRow, but it will work down // to the row we are curently expanding. We need this call to get the affectedSubItemColumns. // This should pick up the new list now in this cell, so the column will always be zero // UNDONE: Nothing changed from a global structure perspective, // the cell contents may have. Defer to DisplayDataChanged at this point //Cached absolute information is toast.
branch
IBranch
None
row
int
None
column
int
None
makeComplex
bool
Action to take
Action to take