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

            var observableViewModel = service.ViewModelProvider(identifier);

            if (observableViewModel != null && !commands.Any(x => observableViewModel.MatchCombinedRootNode(x.GetCommandRootNode())))
            {
                observableViewModel = null;
            }

            var node = observableViewModel != null?observableViewModel.ResolveObservableNode(ObservableNodePath) as CombinedObservableNode : null;

            // TODO: this need to be verified but I suppose node is never null
            actionStack.EndTransaction(displayName, x => new CombinedValueChangedActionItem(displayName, service, node != null ? node.Path : null, identifier, x));
        }
        private void Refresh()
        {
            var observableViewModel = serviceProvider.ViewModelProvider != null?serviceProvider.ViewModelProvider(identifier) : null;

            if (observableViewModel != null)
            {
                var combinedNode = observableViewModel.ResolveObservableNode(observableNodePath) as CombinedObservableNode;
                if (combinedNode != null)
                {
                    combinedNode.Refresh();
                    combinedNode.Owner.NotifyNodeChanged(combinedNode.Path);
                }
            }
        }
Exemple #3
0
        private void Refresh(IModelNode modelNode, object newValue)
        {
            var observableViewModel = service.ViewModelProvider(identifier);

            if (modelNode == null)
            {
                throw new ArgumentNullException("modelNode");
            }
            var observableNode = observableViewModel != null?observableViewModel.ResolveObservableModelNode(ObservableNodePath, nodePath.RootNode) : null;

            // If we have an observable node, we use it to set the new value so the UI can be notified at the same time.
            if (observableNode != null)
            {
                observableNode.Value = newValue;
                observableNode.Owner.NotifyNodeChanged(observableNode.Path);
            }
            else
            {
                modelNode.Content.Value = newValue;
                modelContainer.UpdateReferences(modelNode);
            }
        }
Exemple #4
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;
        }