Esempio n. 1
0
 /// <summary>
 ///     Create a new SynchronizeStateEventArgs.
 /// </summary>
 /// <param name="tree">Tree raising this event.  Necessary to allow clients that handle synchronization themeselves to raise events back to the tree.</param>
 /// <param name="itemsToSynchronize">Enumerator of items to be synchronized.</param>
 /// <param name="matchBranch">Branch whose state should be matched.</param>
 /// <param name="matchRow">Row whose state should be matched.</param>
 /// <param name="matchColumn">Column whose state should be matched.</param>
 public SynchronizeStateEventArgs(
     ITree tree, ColumnItemEnumerator itemsToSynchronize, IBranch matchBranch, int matchRow, int matchColumn)
 {
     Handled = false;
     myItemsToSynchronize = itemsToSynchronize;
     myMatchBranch = matchBranch;
     myMatchRow = matchRow;
     myMatchColumn = matchColumn;
     myTree = tree as VirtualTree;
 }
Esempio n. 2
0
 internal PositionManagerEventArgs(VirtualTree owningTree)
 {
     myMultiColumnTree = (null != (owningTree as IMultiColumnTree)) ? owningTree : null;
     myTable = new Hashtable();
 }
Esempio n. 3
0
        private static TREENODE CreateTreeNode(
            TREENODE startNode, IBranch branch, VirtualTree tree, bool allowMultiColumn, bool inSubItemColumn, bool multiColumnParent)
        {
            Debug.Assert(startNode == null || (startNode.Branch == null && startNode.GetType() == typeof(TREENODE_Complex)));
            BranchFeatures tf;
            TREENODE retVal;
            tf = branch.Features;
            var isDynamic = TREENODE.RequireDynamic(tf);
            var supportMultiColumn = tree.MultiColumnSupport;
            allowMultiColumn &= supportMultiColumn;
            var isMultiColumn = false;
            if (allowMultiColumn)
            {
                var mcTest = branch as IMultiColumnBranch;
                // Checking the column count allows a single wrapper class to
                // support either single or multicolumn branches
                isMultiColumn = mcTest != null && mcTest.ColumnCount > 1;
            }

            if (isDynamic)
            {
                if (TREENODE.RequireUpdatable(tf))
                {
                    retVal = isMultiColumn
                                 ? new TREENODE_Multi_Tracked_Updatable()
                                 : (supportMultiColumn
                                        ? (multiColumnParent
                                               ? (new TREENODE_Complex_Tracked_Updatable()) as TREENODE
                                               : new TREENODE_Single_Tracked_Updatable())
                                        : new TREENODE_Tracked_Updatable());
                }
                else
                {
                    retVal = isMultiColumn
                                 ? new TREENODE_Multi_Tracked()
                                 : (supportMultiColumn
                                        ? (multiColumnParent
                                               ? (new TREENODE_Complex_Tracked()) as TREENODE
                                               : new TREENODE_Single_Tracked())
                                        : new TREENODE_Tracked());
                }
            }
            else if (TREENODE.RequireUpdatable(tf))
            {
                retVal = isMultiColumn
                             ? new TREENODE_Multi_Updatable()
                             : (supportMultiColumn
                                    ? (multiColumnParent
                                           ? (new TREENODE_Complex_Updatable()) as TREENODE
                                           : new TREENODE_Single_Updatable())
                                    : new TREENODE_Updatable());
            }
            else
            {
                retVal = isMultiColumn
                             ? new TREENODE_Multi()
                             : (supportMultiColumn
                                    ? (multiColumnParent
                                           ? ((startNode == null) ? new TREENODE_Complex() : startNode)
                                           : new TREENODE_Single())
                                    : new TREENODE());
            }
            retVal.Branch = branch;
            retVal.SetFlags(tf);
            retVal.MultiColumn = isMultiColumn;
            retVal.AllowMultiColumnChildren = allowMultiColumn;
            retVal.InSubItemColumn = inSubItemColumn;
            if (retVal.CallUpdate)
            {
                retVal.UpdateCounter = branch.UpdateCounter;
            }
            branch.OnBranchModification += tree.OnBranchModification;

            if (startNode != null
                && startNode != retVal)
            {
                var subItem = startNode.FirstSubItem;
                retVal.FirstSubItem = subItem;
                retVal.ImmedSubItemGain = startNode.ImmedSubItemGain;
                retVal.FullSubItemGain = startNode.FullSubItemGain;
                while (subItem != null)
                {
                    subItem.RootNode.Parent = retVal;
                    subItem = subItem.NextSibling;
                }
                TREENODE tnPrev = null;
                var tnTest = startNode.Parent.FirstChild;
                while (tnTest != startNode)
                {
                    tnPrev = tnTest;
                    tnTest = tnTest.NextSibling;
                }
                if (tnPrev == null)
                {
                    startNode.Parent.FirstChild = retVal;
                    retVal.NextSibling = startNode.NextSibling;
                }
                else
                {
                    tnPrev.NextSibling = retVal;
                    retVal.NextSibling = startNode.NextSibling;
                }
            }

            return retVal;
        }
Esempio n. 4
0
 /// <summary>
 ///     Create a single column view on the parent tree
 /// </summary>
 /// <param name="parent">The parent tree object</param>
 public SingleColumnView(VirtualTree parent)
 {
     myParent = parent;
 }
Esempio n. 5
0
            public void QueryReattachObjects(
                VirtualTree tree, TREENODE tnStartParent, int maxLevels, out int changeCount, out int subItemChangeCount)
            {
                // Return the ChangeCount wrt/tnParent
                NODEPOSITIONTRACKER_Dynamic nptPrev = null;
                var nptNext = this;
                NODEPOSITIONTRACKER_Dynamic nptCur;
                //TREENODE tnLastChildPrimary = null;
                TREENODE tnLastChildSecondary;
                int level;
                int attachIndex;
                int expansionCount;
                TrackingObjectAction action;
                TREENODE tnCurParent;
                TREENODE tnNextParent;
                changeCount = 0;
                subItemChangeCount = 0;
                while ((nptCur = nptNext) != null)
                {
                    // Grab the next up front
                    nptNext = (NODEPOSITIONTRACKER_Dynamic)nptCur.myNextSibling;

                    // Walk the parents to see where this goes
                    for (level = 0, tnCurParent = tnStartParent; level <= maxLevels; ++level)
                    {
                        if (tnCurParent.NoTracking)
                        {
                            // Move along, reattach failed
                            nptPrev = nptCur;
                            break;
                        }
                        else
                        {
                            var locateData = tnCurParent.Branch.LocateObject(nptCur.myTrackerObject, ObjectStyle.TrackingObject, 0);
                            attachIndex = locateData.Row;
                            action = (TrackingObjectAction)locateData.Options;
                            // Protect against inconsistent data from clients
                            if (attachIndex == -1)
                            {
                                action = TrackingObjectAction.NotTracked;
                            }
                            switch (action)
                            {
                                case TrackingObjectAction.ThisLevel:
                                    // Detach from the list of nodes to insert
                                    if (nptPrev != null)
                                    {
                                        nptPrev.myNextSibling = nptNext;
                                    }
                                    nptCur.myNextSibling = tnCurParent.FirstPositionTracker;
                                    tnCurParent.FirstPositionTracker = nptCur;
                                    nptCur.myParentNode = tnCurParent;

                                    // Easy to break out, just pretend we're at the last level and move on.
                                    level = maxLevels;
                                    break;
                                case TrackingObjectAction.NextLevel:
                                    tnLastChildSecondary = null;
                                    tnNextParent = FindIndexedNode(attachIndex, tnCurParent.FirstChild, ref tnLastChildSecondary);
                                    if (tnNextParent != null)
                                    {
                                        if (!tnNextParent.Expanded)
                                        {
                                            tnNextParent.Expanded = true;
                                            changeCount += tnNextParent.FullCount;
                                            subItemChangeCount += tnNextParent.ExpandedSubItemGain;
                                                // UNDONE_MC: Is ExpandedSubItemGain correct?
                                            tree.ChangeFullCountRecursive(
                                                tnCurParent, tnNextParent.FullCount, tnNextParent.ExpandedSubItemGain, tnStartParent);
                                        }
                                    }
                                    else
                                    {
                                        int subItemIncr;
                                        // UNDONE_MC: Need a column
                                        tnNextParent = tree.ExpandTreeNode(
                                            tnCurParent, null, attachIndex, COLUMN_ZERO, false, out expansionCount, out subItemIncr);
                                        changeCount += tnNextParent.FullCount;
                                        subItemChangeCount += subItemIncr;
                                        tree.ChangeFullCountRecursive(tnCurParent, tnNextParent.FullCount, subItemIncr, tnStartParent);
                                        InsertIndexedNode(tnCurParent, tnNextParent, ref tnLastChildSecondary);
                                    }
                                    tnCurParent = tnNextParent;
                                    break;
                                case TrackingObjectAction.NotTracked:
                                case TrackingObjectAction.NotTrackedReturnParent:
                                    // Break out
                                    nptPrev = nptCur;
                                    level = maxLevels;
                                    break;
                            }
                        }
                    }
                }
            }
Esempio n. 6
0
 public ColumnItemEnumeratorSingleColumnImpl(VirtualTree tree, int[] rowFilter, bool markExcludedFilterItems)
     :
         base(0, null, false, rowFilter, markExcludedFilterItems)
 {
     myTree = tree;
 }
Esempio n. 7
0
 public ColumnItemEnumeratorSingleColumnImpl(VirtualTree tree, int startRow, int endRow)
     :
         base(0, null, false, startRow, endRow, (tree as ITree).VisibleItemCount)
 {
     myTree = tree;
 }
Esempio n. 8
0
 public ColumnItemEnumeratorImpl(
     VirtualTree tree, int column, ColumnPermutation columnPermutation, bool returnBlankAnchors, int[] rowFilter,
     bool markExcludedFilterItems)
     :
         base(column, columnPermutation, returnBlankAnchors, rowFilter, markExcludedFilterItems)
 {
     myTree = tree;
 }
Esempio n. 9
0
 public ColumnItemEnumeratorImpl(
     VirtualTree tree, int column, ColumnPermutation columnPermutation, bool returnBlankAnchors, int startRow, int endRow)
     :
         base(column, columnPermutation, returnBlankAnchors, startRow, endRow, (tree as ITree).VisibleItemCount)
 {
     myTree = tree;
 }