Exemplo n.º 1
0
        public virtual void BeginUpdate()
        {
            IUpdateHandler handler = (IUpdateHandler)FindParent(typeof(IUpdateHandler));

            if (handler != null)
            {
                handler.BeginUpdate();
            }
        }
Exemplo n.º 2
0
 /// <summary> Called to remove a child node. </summary>
 /// <param name="value"> The node to be removed. </param>
 /// <param name="index"> The nodes index. </param>
 /// <remarks> Unlinks a node from it's owner. </remarks>
 protected override void Removed(Node value, int index)
 {
     try
     {
         try
         {
             if (_node.Active)
             {
                 IUpdateHandler handler = (IUpdateHandler)_node.FindParent(typeof(IUpdateHandler));
                 if (handler != null)
                 {
                     handler.BeginUpdate();
                 }
                 else
                 {
                     handler = null;
                 }
                 try
                 {
                     try
                     {
                         value.BeforeDeactivate();
                     }
                     finally
                     {
                         value.DeactivateAll();
                     }
                 }
                 finally
                 {
                     if (handler != null)
                     {
                         handler.EndUpdate(false);
                     }
                 }
             }
         }
         finally
         {
             value._owner = null;
         }
     }
     finally
     {
         _node.RemoveChild(value);
         _node.ChildrenChanged();
         base.Removed(value, index);
     }
 }
Exemplo n.º 3
0
        /// <summary> Called to add a node to the children. </summary>
        /// <param name="value"> The node to be added. </param>
        /// <param name="index"> The index of the node. </param>
        /// <remarks> Also links the node to it's owner. </remarks>
        protected override void Adding(Node value, int index)
        {
            value.Owner = null;
            if (value.Active)
            {
                throw new ClientException(ClientException.Codes.CannotAddActiveChild);
            }

            base.Adding(value, index);

            _node.AddChild(value);
            try
            {
                value._owner = _node;
                try
                {
                    if (_node.Active)
                    {
                        IUpdateHandler handler = (IUpdateHandler)_node.FindParent(typeof(IUpdateHandler));
                        if (handler != null)
                        {
                            handler.BeginUpdate();
                        }
                        else
                        {
                            handler = null;
                        }
                        try
                        {
                            value.ActivateAll();
                            try
                            {
                                value.AfterActivate();
                                _node.ChildrenChanged();
                            }
                            catch
                            {
                                value.DeactivateAll();
                                throw;
                            }
                        }
                        finally
                        {
                            if (handler != null)
                            {
                                handler.EndUpdate(true);
                            }
                        }
                    }
                }
                catch
                {
                    value._owner = null;
                    throw;
                }
            }
            catch
            {
                _node.RemoveChild(value);
                throw;
            }
        }