Beispiel #1
0
        protected override UndoToken Redo(object parameter, bool creatingActionItem)
        {
            UndoToken token;
            var       viewModelNode = nodePath.GetNode();

            if (viewModelNode == null)
            {
                throw new InvalidOperationException("Unable to retrieve the node on which to apply the redo operation.");
            }

            var newValue = nodeCommand.Invoke(viewModelNode.Content.Value, viewModelNode.Content.Descriptor, parameter, out token);

            Refresh(viewModelNode, newValue);
            return(token);
        }
Beispiel #2
0
        /// <inheritdoc/>
        protected override void UndoAction()
        {
            var node = nodePath.GetNode();

            if (node == null)
            {
                throw new InvalidOperationException("Unable to retrieve the node to modify in this undo process.");
            }

            var  currentValue        = GetValue(node, index);
            bool setByObservableNode = false;

            var observableViewModel = service.ViewModelProvider != null?service.ViewModelProvider(identifier) : null;

            if (observableViewModel != null && !observableViewModel.MatchRootNode(nodePath.RootNode))
            {
                observableViewModel = null;
            }

            if (observableViewModel != null)
            {
                SingleObservableNode observableNode = observableViewModel.ResolveObservableModelNode(observableNodePath, nodePath.RootNode);
                if (observableNode != null)
                {
                    observableNode.Value = previousValue;
                    setByObservableNode  = true;
                }
            }

            if (!setByObservableNode)
            {
                SetValue(node, index, previousValue);
                // Update the view model nodes in case the graph of the object is modified by this value change
                modelContainer.UpdateReferences(node);
            }

            previousValue = currentValue;
        }