Beispiel #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;
 }
 /// <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;
 }
 void ITree.SynchronizeState(ColumnItemEnumerator itemsToSynchronize, IBranch matchBranch, int matchRow, int matchColumn)
 {
     myParent.SynchronizeState(itemsToSynchronize, matchBranch, matchRow, matchColumn, true /* translateSingleColumnView */);
 }
        /// <summary>
        ///     Synchronize the state of the given items to the state of another branch.
        /// </summary>
        /// <param name="itemsToSynchronize">items whose state should be synchronized.</param>
        /// <param name="matchBranch">Branch to synchronize with</param>
        /// <param name="matchRow">Row in branch to synchronize with</param>
        /// <param name="matchColumn">Column in branch to synchronize with</param>
        /// <param name="translateSingleColumnView">True if this synchronize is coming from a single column view attached to the tree.</param>
        protected internal void SynchronizeState(
            ColumnItemEnumerator itemsToSynchronize, IBranch matchBranch, int matchRow, int matchColumn, bool translateSingleColumnView)
        {
            // UNDONE : check translateSingleColumnView before firing events because sync batching is not currently supported 
            // for the single column view.
            SynchronizeStateEventArgs e = null;
            if (!translateSingleColumnView && SynchronizationBeginning != null
                || SynchronizationEnding != null)
            {
                e = new SynchronizeStateEventArgs(this, itemsToSynchronize, matchBranch, matchRow, matchColumn);
            }

            if (!translateSingleColumnView
                && SynchronizationBeginning != null)
            {
                SynchronizationBeginning(this, e);
            }

            if (e == null
                || !e.Handled)
            {
                itemsToSynchronize.Reset();
                if (!translateSingleColumnView)
                {
                    while (itemsToSynchronize.MoveNext())
                    {
                        if (
                            !(itemsToSynchronize.Branch == matchBranch && itemsToSynchronize.RowInBranch == matchRow
                              && itemsToSynchronize.ColumnInBranch == matchColumn))
                        {
                            DoToggleState(itemsToSynchronize.RowInTree, itemsToSynchronize.ColumnInTree, matchBranch, matchRow, matchColumn);
                        }
                    }
                }
                else
                {
                    while (itemsToSynchronize.MoveNext())
                    {
                        if (
                            !(itemsToSynchronize.Branch == matchBranch && itemsToSynchronize.RowInBranch == matchRow
                              && itemsToSynchronize.ColumnInBranch == matchColumn))
                        {
                            DoToggleState(TranslateSingleColumnRow(itemsToSynchronize.RowInTree), 0, matchBranch, matchRow, matchColumn);
                        }
                    }
                }
            }

            if (!translateSingleColumnView
                && SynchronizationEnding != null)
            {
                SynchronizationEnding(this, e);
            }
        }