Exemple #1
0
        public override void Execute(object parameter)
        {
            ActionStack.BeginTransaction();
            Redo(parameter, true);
            var displayName = "Executing " + Name;

            var node = (CombinedObservableNode)service.ResolveObservableNode(identifier, ObservableNodePath);

            // TODO: this need to be verified but I suppose node is never null
            ActionStack.EndTransaction(displayName, x => new CombinedValueChangedActionItem(displayName, service, node.Path, identifier, x));
        }
        /// <inheritdoc/>
        protected override void UndoAction()
        {
            object pathIndex;
            var    node = NodePath.GetSourceNode(out pathIndex);

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

            var  currentValue        = node.GetValue(Index);
            bool setByObservableNode = false;

            var observableNode = service.ResolveObservableNode(identifier, ObservableNodePath) as SingleObservableNode;

            if (observableNode != null)
            {
                observableNode.Value = PreviousValue;
                setByObservableNode  = true;
            }

            if (!setByObservableNode)
            {
                node.SetValue(PreviousValue, Index);
            }

            PreviousValue = currentValue;
        }
        private void Refresh()
        {
            var combinedNode = serviceProvider.ResolveObservableNode(identifier, ObservableNodePath) as CombinedObservableNode;

            if (combinedNode != null)
            {
                combinedNode.Refresh();
                combinedNode.Owner.NotifyNodeChanged(combinedNode.Path);
            }
        }
Exemple #4
0
        /// <summary>
        /// Refreshes the <see cref="ObservableNode"/> corresponding to the given <see cref="IModelNode"/>, if an <see cref="ObservableViewModel"/>
        /// is available in the current.<see cref="IViewModelServiceProvider"/>.
        /// </summary>
        /// <param name="modelNode">The model node to use to fetch a corresponding <see cref="ObservableNode"/>.</param>
        /// <param name="index">The index at which the actual value to update is stored.</param>
        protected virtual void Refresh(IModelNode modelNode, object index)
        {
            if (modelNode == null)
            {
                throw new ArgumentNullException(nameof(modelNode));
            }

            var observableNode = Service.ResolveObservableNode(Identifier, ObservableNodePath) as ObservableModelNode;

            // No node matches this model node
            if (observableNode == null)
            {
                return;
            }

            var newValue = modelNode.GetValue(index);

            observableNode.ForceSetValue(newValue);
            observableNode.Owner.NotifyNodeChanged(observableNode.Path);
        }