Example #1
0
 internal void UpdateReferences()
 {
     if (modelContainer != null && modelNode != null)
     {
         modelContainer.UpdateReferences(modelNode);
     }
 }
Example #2
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);
            }
        }
Example #3
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;
        }