Пример #1
0
        protected void RemoveChild(ObservableNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            if (!Children.Contains(node))
            {
                throw new InvalidOperationException("The node is not in the children list of its parent.");
            }

            if (node.IsVisible)
            {
                --VisibleChildrenCount;
            }
            node.IsVisibleChanged -= ChildVisibilityChanged;

            if (initializingChildren == null)
            {
                NotifyPropertyChanging(node.Name);
            }

            node.Parent = null;
            if (initializingChildren == null)
            {
                children.Remove(node);
                NotifyPropertyChanged(node.Name);
            }
            else
            {
                initializingChildren.Remove(node);
            }
        }
Пример #2
0
        protected void AddChild(ObservableNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            if (node.Parent != null)
            {
                throw new InvalidOperationException("The node already have a parent.");
            }
            if (Children.Contains(node))
            {
                throw new InvalidOperationException("The node is already in the children list of its parent.");
            }
            if (initializingChildren == null)
            {
                NotifyPropertyChanging(node.Name);
            }
            node.Parent = this;

            if (initializingChildren == null)
            {
                children.Add(node);
                NotifyPropertyChanged(node.Name);
            }
            else
            {
                initializingChildren.Add(node);
            }
            if (node.IsVisible)
            {
                ++VisibleChildrenCount;
            }
            node.IsVisibleChanged += ChildVisibilityChanged;
        }
Пример #3
0
        protected void RemoveChild(ObservableNode node)
        {
            if (node == null) throw new ArgumentNullException(nameof(node));
            if (!Children.Contains(node)) throw new InvalidOperationException("The node is not in the children list of its parent.");

            if (node.IsVisible)
                --VisibleChildrenCount;
            node.IsVisibleChanged -= ChildVisibilityChanged;

            if (initializingChildren == null)
            {
                NotifyPropertyChanging(node.Name);
            }

            node.Parent = null;
            if (initializingChildren == null)
            {
                children.Remove(node);
                NotifyPropertyChanged(node.Name);
            }
            else
            {
                initializingChildren.Remove(node);
            }
        }
Пример #4
0
        protected void AddChild(ObservableNode node)
        {
            if (node == null) throw new ArgumentNullException(nameof(node));
            if (node.Parent != null) throw new InvalidOperationException("The node already have a parent.");
            if (Children.Contains(node)) throw new InvalidOperationException("The node is already in the children list of its parent.");
            if (initializingChildren == null)
            {
                NotifyPropertyChanging(node.Name);
            }
            node.Parent = this;

            if (initializingChildren == null)
            {
                children.Add(node);
                NotifyPropertyChanged(node.Name);
            }
            else
            {
                initializingChildren.Add(node);
            }
            if (node.IsVisible)
                ++VisibleChildrenCount;    
            node.IsVisibleChanged += ChildVisibilityChanged;
        }
 /// <summary>
 /// Initializes a new instance of the ObservableViewModelConsistencyException class.
 /// </summary>
 /// <param name="node">The node that is related to this error.</param>
 /// <param name="messageFormat">A composite format string that describes the error.</param>
 /// <param name="args">An object array that contains zero or more objects to format.</param>
 public ObservableViewModelConsistencyException(ObservableNode node, string messageFormat, params object[] args)
     : base(string.Format(messageFormat, args))
 {
     Node = node;
 }
Пример #6
0
 public ObservableNodeDynamicMetaObject(Expression parameter, ObservableNode observableNode)
     : base(parameter, BindingRestrictions.Empty, observableNode)
 {
     node = observableNode;
 }
Пример #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SingleObservableNode"/> class.
        /// </summary>
        /// <param name="ownerViewModel">The <see cref="ObservableViewModel"/> that owns the new <see cref="SingleObservableNode"/>.</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="parentNode">The parent node of the new <see cref="SingleObservableNode"/>, or <c>null</c> if the node being created is the root node of the view model.</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 SingleObservableNode(ObservableViewModel ownerViewModel, string baseName, ObservableNode parentNode, object index = null)
            : base(ownerViewModel, parentNode, index)
        {
            if (baseName == null && index == null)
            {
                throw new ArgumentException("baseName and index can't be both null.");
            }

            CombineMode = CombineMode.CombineOnlyForAll;
            SetName(baseName);
        }
        /// <summary>
        /// Initializes a new instance of the ObservableViewModelConsistencyException class.
        /// </summary>
        /// <param name="node">The node that is related to this error.</param>
        /// <param name="messageFormat">A composite format string that describes the error.</param>
        /// <param name="args">An object array that contains zero or more objects to format.</param>
        public ObservableViewModelConsistencyException(ObservableNode node, string messageFormat, params object[] args)
            : base(string.Format(messageFormat, args))
        {
            Node = node;

        }
 public ObservableNodeDynamicMetaObject(Expression parameter, ObservableNode observableNode)
     : base(parameter, BindingRestrictions.Empty, observableNode)
 {
     node = observableNode;
 }