예제 #1
0
 /// <summary>
 /// Unregisters a collection scope selected objects from the <see cref="SelectionService"/>.
 /// </summary>
 /// <param name="scope">The selection scope to unregister.</param>
 public void UnregisterSelectionScope([NotNull] SelectionScope scope)
 {
     if (scope == null)
     {
         throw new ArgumentNullException(nameof(scope));
     }
     foreach (var collection in scope.Collections)
     {
         collection.CollectionChanged -= CollectionChanged;
     }
     scopes.Remove(scope);
     // Update history to let it know about this collection
     foreach (var operation in stack.RetrieveAllTransactions().SelectMany(x => x.Operations).OfType <SelectionOperation>())
     {
         foreach (var collection in scope.Collections)
         {
             operation.UnregisterCollection(collection);
         }
     }
     // Also update the current state
     foreach (var collection in scope.Collections)
     {
         CurrentState.UnregisterCollection(collection);
     }
 }
예제 #2
0
        /// <summary>
        /// Registers a collection to this state, creating an empty snapshot for it.
        /// </summary>
        /// <param name="scope"></param>
        /// <param name="collection">The collection to register.</param>
        public void RegisterCollection([NotNull] SelectionScope scope, [NotNull] INotifyCollectionChanged collection)
        {
            if (scope == null)
            {
                throw new ArgumentNullException(nameof(scope));
            }
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }

            if (!states.ContainsKey(collection))
            {
                states.Add(collection, new State(new HashSet <AbsoluteId>(), scope.GetObjectToSelect));
            }
        }
예제 #3
0
        public SelectionScope RegisterSelectionScope([NotNull] Func <AbsoluteId, object> idToObject, [NotNull] Func <object, AbsoluteId?> objectToId, [NotNull] params INotifyCollectionChanged[] collections)
        {
            if (idToObject == null)
            {
                throw new ArgumentNullException(nameof(idToObject));
            }
            if (objectToId == null)
            {
                throw new ArgumentNullException(nameof(objectToId));
            }
            if (collections == null)
            {
                throw new ArgumentNullException(nameof(collections));
            }

            var scope = new SelectionScope(collections, idToObject, objectToId);

            foreach (var collection in scope.Collections)
            {
                collection.CollectionChanged += CollectionChanged;
            }
            scopes.Add(scope);
            // Update history to let it know about this collection
            foreach (var operation in stack.RetrieveAllTransactions().SelectMany(x => x.Operations).OfType <SelectionOperation>())
            {
                foreach (var collection in scope.Collections)
                {
                    operation.RegisterCollection(scope, collection);
                }
            }
            // Also update the current state
            foreach (var collection in scope.Collections)
            {
                CurrentState.RegisterCollection(scope, collection);
            }

            return(scope);
        }
예제 #4
0
 /// <summary>
 /// Registers a collection to the previous and next states of this operation.
 /// </summary>
 /// <param name="scope"></param>
 /// <param name="collection">The collection to register.</param>
 public void RegisterCollection([NotNull] SelectionScope scope, [NotNull] INotifyCollectionChanged collection)
 {
     previousState.RegisterCollection(scope, collection);
     nextState.RegisterCollection(scope, collection);
 }