public void Insert(int index, SubItemColumnAdjustment value)
 {
     throw new NotSupportedException();
 }
 public void Remove(SubItemColumnAdjustment value)
 {
     throw new NotSupportedException();
 }
 /// <summary>
 ///     Find the index of the given value in this collection
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public int IndexOf(SubItemColumnAdjustment value)
 {
     return((myInner as IList).IndexOf(value));
 }
 /// <summary>
 ///     Test whether the collection contains this item.
 /// </summary>
 public bool Contains(SubItemColumnAdjustment value)
 {
     return((myInner as IList).Contains(value));
 }
Ejemplo n.º 5
0
        // An advanced version of this routine to deal with multi column scenarios
        private void ChangeFullCountRecursive(
            TREENODE tn, int itemIncr, int subItemIncr, TREENODE tnCeiling, ref AffectedSubItems affectedColumns, out int rowIncr,
            out SubItemColumnAdjustment[] subItemChanges)
        {
            Debug.Assert(tn != null, "");
            if (MultiColumnSupport)
            {
                var affectedColumnsCount = affectedColumns.Count;
                subItemChanges = (affectedColumnsCount == 0) ? null : new SubItemColumnAdjustment[affectedColumnsCount];
                rowIncr = 0;
                while (tn != tnCeiling)
                {
                    tn.FullCount += itemIncr;
                    tn.FullSubItemGain += subItemIncr;
                    if (tn.Expanded
                        || tn.SubItemRoot)
                    {
                        if (tn.SubItemRoot)
                        {
                            // A subitem root node always has a parent node in the owning branch
                            var subItemRoot = tn.Parent;
                            var totalIncr = itemIncr + subItemIncr;
                            Debug.Assert(subItemRoot != null);
                            itemIncr = 0;
                            // Recalculate, see if this has affected the parent total
                            subItemIncr = subItemRoot.AdjustSubItemGain();
                            if (affectedColumnsCount != 0)
                            {
                                --affectedColumnsCount;
                                // Figure out the trailing items, which is the number of rows wholly
                                // contained in the column that did not change.

                                // First, get the number of rows past the current change
                                var offset = affectedColumns.GetOffset(affectedColumnsCount);
                                var trailingItems = tn.TotalCount - offset - 1;
                                var itemsBelowAnchor = subItemRoot.ImmedSubItemGain - offset - subItemIncr;
                                if (!tn.ComplexSubItem)
                                {
                                    ++trailingItems;
                                }
                                if (totalIncr > 0)
                                {
                                    trailingItems -= totalIncr;
                                }

                                // Now, adjust by the number of rows that have moved into/out of being
                                // wholly contained by this column
                                if (subItemIncr > 0)
                                {
                                    trailingItems -= subItemIncr;
                                }
                                else
                                {
                                    trailingItems += subItemIncr;
                                }
                                if (trailingItems < 0)
                                {
                                    trailingItems = 0;
                                }

                                // UNDONE_MC: Need a global column for the first two parameters here
                                subItemChanges[affectedColumnsCount] = new SubItemColumnAdjustment(
                                    subItemRoot.FirstSubItem.ColumnOfRootNode(tn),
                                    subItemRoot.Parent.GetColumnCount(subItemRoot.Index) - 1,
                                    totalIncr,
                                    trailingItems,
                                    itemsBelowAnchor);
                            }
                            if (subItemIncr == 0)
                            {
                                break;
                            }
                            subItemRoot.FullSubItemGain += subItemIncr;
                            tn = subItemRoot;
                        }
                        tn = tn.Parent;
                        if (tn == null)
                        {
                            rowIncr = itemIncr + subItemIncr;
                            break;
                        }
                    }
                    else if (subItemIncr != 0)
                    {
                        tn = tn.Parent;
                        if (tn != null
                            &&
                            (tn.Expanded || tn.SubItemRoot))
                        {
                            itemIncr = 0;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            else
            {
                var tnNext = tn;
                do
                {
                    tn = tnNext;
                    if (tn == tnCeiling)
                    {
                        break;
                    }
                    tn.FullCount += itemIncr;
                }
                while (tn.Expanded
                       && ((tnNext = tn.Parent) != null));
                subItemChanges = null;
                rowIncr = (tn != null && tn.Expanded) ? itemIncr : 0;
            }
        }
 public void Add(SubItemColumnAdjustment adjustment)
 {
     throw new NotSupportedException();
 }
 public static bool Compare(SubItemColumnAdjustment operand1, SubItemColumnAdjustment operand2)
 {
     Debug.Assert(false); // There is no need to compare these
     return false;
 }
 public void Add(SubItemColumnAdjustment adjustment)
 {
     throw new NotSupportedException();
 }
 public void Insert(int index, SubItemColumnAdjustment value)
 {
     throw new NotSupportedException();
 }
 public void Remove(SubItemColumnAdjustment value)
 {
     throw new NotSupportedException();
 }
 /// <summary>
 ///     Test whether the collection contains this item.
 /// </summary>
 public bool Contains(SubItemColumnAdjustment value)
 {
     return (myInner as IList).Contains(value);
 }
 /// <summary>
 ///     Find the index of the given value in this collection
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public int IndexOf(SubItemColumnAdjustment value)
 {
     return (myInner as IList).IndexOf(value);
 }
 /// <summary>
 ///     Copy items into a separate array
 /// </summary>
 /// <param name="array">A pre-allocated array</param>
 /// <param name="index">The starting index to copy from</param>
 public void CopyTo(SubItemColumnAdjustment[] array, int index)
 {
     myInner.CopyTo(array, index);
 }
 public static bool Compare(SubItemColumnAdjustment operand1, SubItemColumnAdjustment operand2)
 {
     Debug.Assert(false); // There is no need to compare these
     return(false);
 }
Ejemplo n.º 15
0
        //Return size of expansion
        private void ToggleExpansion(
            int absRow, int column, out bool allowRecursion, out int singleColumnSubItemAdjust, out int itemExpansionCount,
            out int subItemExpansionCount, out int rowChange, out int blanksAboveChange, out SubItemColumnAdjustment[] subItemChanges)
        {
            TREENODE tnCur;
            TREENODE tnSubItemAnchor;
            TREENODE tnUnexpandedSubItemAnchor;
            TREENODE tn1;
            TREENODE tn2;
            SUBITEMNODE sn;
            SUBITEMNODE snPrev;
            itemExpansionCount = subItemExpansionCount = 0;
            rowChange = 0;
            singleColumnSubItemAdjust = 0;
            subItemChanges = null;
            allowRecursion = true; //Default to true, too many implementations are missing this, and most are actually recursive
            var localColumn = column;
            var parentRowOffset = 0;
            var affectedColumns = new AffectedSubItems(true);
            var pos = TrackCell(absRow, ref localColumn, ref parentRowOffset, ref affectedColumns, ref singleColumnSubItemAdjust);
            var tnRecurseOn = pos.ParentNode;
            var subItemExpansion = localColumn != 0;
            blanksAboveChange = 0;
            tnCur = pos.ParentNode.GetChildNode(pos.Index);
            tnSubItemAnchor = null;
            tnUnexpandedSubItemAnchor = null;
            snPrev = null;
            if (subItemExpansion)
            {
                Debug.Assert(pos.SubItemOffset == 0); // TrackIndex messed up
                tnSubItemAnchor = tnCur;
                if (tnCur != null)
                {
                    sn = tnCur.SubItemAtColumn(localColumn, out snPrev);
                    tnCur = (sn != null) ? sn.RootNode : null;
                }
            }
            else if (tnCur != null
                     && tnCur.Branch == null)
            {
                tnUnexpandedSubItemAnchor = tnCur;
                tnCur = null;
            }
            if (tnCur != null)
            {
                blanksAboveChange = tnCur.ImmedSubItemGain;
                if (tnCur.Expanded)
                {
                    itemExpansionCount = -tnCur.FullCount;
                    subItemExpansionCount = -tnCur.ExpandedSubItemGain;
                    switch (tnCur.CloseAction)
                    {
                        case BranchCollapseAction.CloseAndDiscard:
                            tn1 = pos.ParentNode.FirstChild;
                            Debug.Assert(tn1 != null, "");
                            tn2 = null;
                            while (tn1 != tnCur)
                            {
                                //ptnCur is a child of the parent node, should never miss it completely
                                Debug.Assert(tn1 != null, "");
                                tn2 = tn1;
                                tn1 = tn1.NextSibling;
                            }
                            if (tn2 != null)
                            {
                                tn2.NextSibling = tn1.NextSibling;
                            }
                            else
                            {
                                pos.ParentNode.FirstChild = tn1.NextSibling;
                            }
                            FreeRecursive(ref tnCur);
                            break;

                        case BranchCollapseAction.CloseChildren:
                            tn1 = tnCur.FirstChild;
                            while (tn1 != null)
                            {
                                tn2 = tn1.NextSibling;
                                FreeRecursive(ref tn1);
                                tn1 = tn2;
                            }
                            tn1 = tn2 = null;
                            tnCur.FirstChild = null;
                            tnCur.FullCount = tnCur.ImmedCount;
                            goto case BranchCollapseAction.Nothing;
                        case BranchCollapseAction.Nothing:
                            tnCur.Expanded = false;
                            break;
                        default:
                            Debug.Assert(false, "Bogus BranchCollapseAction");
                            break;
                    }
                }
                else
                {
                    tnCur.Expanded = true;
                    allowRecursion = tnCur.AllowRecursion;
                    itemExpansionCount = tnCur.FullCount;
                    subItemExpansionCount = tnCur.ExpandedSubItemGain;
                }
            }
            else
            {
                tnCur = ExpandTreeNode(
                    pos.ParentNode,
                    tnUnexpandedSubItemAnchor,
                    pos.Index,
                    localColumn,
                    !subItemExpansion,
                    out itemExpansionCount,
                    out subItemExpansionCount);

                // Make sure we don't crash if the branch returns null. If this happens,
                // the branch should stop returning true for IsExpandable and initiate
                // an DisplayDataChanged event to update the expansion bitmap.
                if (tnCur == null)
                {
                    allowRecursion = false;
                    return;
                }

                allowRecursion = tnCur.AllowRecursion;

                // We need to insert the node ourselves
                if (subItemExpansion)
                {
                    if (tnSubItemAnchor == null)
                    {
                        // TREENODE_Complex is the lowest common denominator
                        // that supports multi column expansion. This node may
                        // be upgraded later if an expansion is actually made
                        // on this item.
                        tnSubItemAnchor = new TREENODE_Complex();
                        tnSubItemAnchor.Index = pos.Index;
                        TREENODE tnDummy = null;
                        // UNDONE_MC: Might want to insert last so there are no lasting side effects in case of failure
                        InsertIndexedNode(pos.ParentNode, tnSubItemAnchor, ref tnDummy);
                    }
                    tnCur.SubItemRoot = true;
                    // UNDONE_MC: Should we store the column in the blank index field of the root
                    // instead of in the SUBITEMNODE? This would save calculating the column with
                    // SUBITEMNODE.ColumnOfRootNode when we need it.
                    tnCur.Index = VirtualTreeConstant.NullIndex;
                    tnCur.Parent = tnSubItemAnchor;
                    sn = new SUBITEMNODE();
                    sn.Column = localColumn;
                    sn.RootNode = tnCur;
                    if (snPrev == null)
                    {
                        sn.NextSibling = tnSubItemAnchor.FirstSubItem;
                        tnSubItemAnchor.FirstSubItem = sn;
                    }
                    else
                    {
                        sn.NextSibling = snPrev.NextSibling;
                        snPrev.NextSibling = sn;
                    }
                }
            }
            if ((itemExpansionCount + subItemExpansionCount) != 0)
            {
                if (subItemExpansion)
                {
                    // An item increment will be picked up by the first pass in
                    // ChangeFullCountRecursive and passed back up the chain. The
                    // value is calculated in the call to AdjustSubItemGain, which is
                    // why we do not call that function here. However, ChangeFullCountRecursive
                    // also adjusts the following two values, so we compensate here.
                    Debug.Assert(tnCur.FullCount == Math.Abs(itemExpansionCount));
                    Debug.Assert(tnCur.FullSubItemGain == Math.Abs(subItemExpansionCount));
                    tnCur.FullCount -= itemExpansionCount;
                    tnCur.FullSubItemGain -= subItemExpansionCount;
                    tnRecurseOn = tnCur;
                }
                ChangeFullCountRecursive(
                    tnRecurseOn,
                    itemExpansionCount,
                    subItemExpansionCount,
                    null,
                    ref affectedColumns,
                    out rowChange,
                    out subItemChanges);
            }
        }
Ejemplo n.º 16
0
 internal ItemCountChangedEventArgs(
     ITree tree, int anchorRow, int column, int change, int parentRow, int blanksAfterAnchor,
     SubItemColumnAdjustment[] subItemChanges, bool isToggle)
 {
     myTree = tree;
     myRow = anchorRow;
     myColumn = column;
     myChange = change;
     myParentRow = parentRow;
     myBlanksAfterAnchor = isToggle ? blanksAfterAnchor : -1;
     myColumnAdjustments = subItemChanges;
     myColumnAdjustmentsCollection = null;
 }
 internal SubItemColumnAdjustmentCollection(SubItemColumnAdjustment[] adjustments)
 {
     myInner = adjustments;
 }