Пример #1
0
 /// <summary>
 /// Raise the <see cref="NodeInitialized"/> event.
 /// </summary>
 /// <param name="node">The node that has been modified.</param>
 internal void NotifyNodeInitialized(SingleObservableNode node)
 {
     foreach (var updater in propertyNodeUpdaters)
     {
         updater.UpdateNode(node);
     }
     NodeInitialized?.Invoke(this, new NodeInitializedEventArgs(node));
 }
 /// <summary>
 /// Raise the <see cref="NodeInitialized"/> event.
 /// </summary>
 /// <param name="node">The node that has been modified.</param>
 internal void NotifyNodeInitialized(SingleObservableNode node)
 {
     foreach (var updater in propertyNodeUpdaters)
     {
         updater.UpdateNode(node);
     }
     NodeInitialized?.Invoke(this, new NodeInitializedEventArgs(node));
 }
Пример #3
0
        /// <summary>
        /// Raise the <see cref="NodeInitialized"/> event.
        /// </summary>
        /// <param name="node">The node that has been modified.</param>
        internal void NotifyNodeInitialized(SingleObservableNode node)
        {
            var handler = NodeInitialized;

            if (handler != null)
            {
                handler(this, new NodeInitializedEventArgs(node));
            }
        }
            public void UpdateNode(SingleObservableNode node)
            {
                if (node.Name == nameof(Types.DependentPropertyContainer.Title))
                {
                    var instance = (Types.DependentPropertyContainer)node.Owner.RootNode.Value;
                    node.AddAssociatedData(TestDataKey, instance.Instance.Name);

                    var dependencyPath = GetDependencyPath(node.Owner);
                    node.AddDependency(dependencyPath, IsRecursive);

                    node.AddAssociatedData(UpdateCountKey, count++);
                }
            }
Пример #5
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;
        }
Пример #6
0
        /// <summary>
        /// Create an <see cref="ObservableModelNode{T}"/> that matches the given content type.
        /// </summary>
        /// <param name="ownerViewModel">The <see cref="ObservableViewModel"/> that owns the new <see cref="ObservableModelNode"/>.</param>
        /// <param name="baseName">The base name of this node. Can be null if <see cref="index"/> is not. If so a name will be automatically generated from the index.</param>
        /// <param name="isPrimitive">Indicate whether this node should be considered as a primitive node.</param>
        /// <param name="parentNode">The parent node of the new <see cref="ObservableModelNode"/>, or <c>null</c> if the node being created is the root node of the view model.</param>
        /// <param name="modelNode">The model node bound to the new <see cref="ObservableModelNode"/>.</param>
        /// <param name="contentType">The type of content contained by the new <see cref="ObservableModelNode"/>.</param>
        /// <param name="index">The index of this content in the model node, when this node represent an item of a collection. <c>null</c> must be passed otherwise</param>
        /// <returns>A new instance of <see cref="ObservableModelNode{T}"/> instanced with the given content type as generic argument.</returns>
        internal static ObservableModelNode Create(ObservableViewModel ownerViewModel, string baseName, bool isPrimitive, SingleObservableNode parentNode, IModelNode modelNode, Type contentType, object index)
        {
            var node = (ObservableModelNode)Activator.CreateInstance(typeof(ObservableModelNode <>).MakeGenericType(contentType), ownerViewModel, baseName, isPrimitive, parentNode, modelNode, index);

            return(node);
        }
Пример #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ObservableModelNode"/> class.
        /// </summary>
        /// <param name="ownerViewModel">The <see cref="ObservableViewModel"/> that owns the new <see cref="ObservableModelNode"/>.</param>
        /// <param name="baseName">The base name of this node. Can be null if <see cref="index"/> is not. If so a name will be automatically generated from the index.</param>
        /// <param name="isPrimitive">Indicate whether this node should be considered as a primitive node.</param>
        /// <param name="parentNode">The parent node of the new <see cref="ObservableModelNode"/>, or <c>null</c> if the node being created is the root node of the view model.</param>
        /// <param name="modelNode">The model node bound to the new <see cref="ObservableModelNode"/>.</param>
        /// <param name="index">The index of this content in the model node, when this node represent an item of a collection. <c>null</c> must be passed otherwise</param>
        protected ObservableModelNode(ObservableViewModel ownerViewModel, string baseName, bool isPrimitive, SingleObservableNode parentNode, IModelNode modelNode, object index = null)
            : base(ownerViewModel, baseName, parentNode, index)
        {
            if (modelNode == null)
            {
                throw new ArgumentNullException("modelNode");
            }
            if (baseName == null && index == null)
            {
                throw new ArgumentException("baseName and index can't be both null.");
            }

            this.isPrimitive = isPrimitive;
            sourceNode       = modelNode;
            // By default we will always combine items of list of primitive items.
            CombineMode = index != null && isPrimitive ? CombineMode.AlwaysCombine : CombineMode.CombineOnlyForAll;
            targetNode  = GetTargetNode(modelNode, index);
        }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NodeInitializedEventArgs"/>
 /// </summary>
 /// <param name="node">The node that has been initialized.</param>
 public NodeInitializedEventArgs(SingleObservableNode node)
 {
     Node = node;
 }
Пример #9
0
 /// <summary>
 /// Raise the <see cref="NodeInitialized"/> event.
 /// </summary>
 /// <param name="node">The node that has been modified.</param>
 internal void NotifyNodeInitialized(SingleObservableNode node)
 {
     NodeInitialized?.Invoke(this, new NodeInitializedEventArgs(node));
 }
Пример #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NodeInitializedEventArgs"/>
 /// </summary>
 /// <param name="node">The node that has been initialized.</param>
 public NodeInitializedEventArgs(SingleObservableNode node)
 {
     Node = node;
 }
 /// <summary>
 /// Raise the <see cref="NodeInitialized"/> event.
 /// </summary>
 /// <param name="node">The node that has been modified.</param>
 internal void NotifyNodeInitialized(SingleObservableNode node)
 {
     var handler = NodeInitialized;
     if (handler != null)
         handler(this, new NodeInitializedEventArgs(node));
 }
Пример #12
0
 /// <summary>
 /// Raise the <see cref="NodeInitialized"/> event.
 /// </summary>
 /// <param name="node">The node that has been modified.</param>
 internal void NotifyNodeInitialized(SingleObservableNode node)
 {
     NodeInitialized?.Invoke(this, new NodeInitializedEventArgs(node));
 }
Пример #13
0
 protected VirtualObservableNode(ObservableViewModel ownerViewModel, string name, SingleObservableNode parentNode, int?order, NodeCommandWrapperBase valueChangedCommand)
     : base(ownerViewModel, name, parentNode, null)
 {
     this.order          = order;
     Name                = name;
     ValueChangedCommand = valueChangedCommand;
 }