Ejemplo n.º 1
0
        // From Container Base class
        /// <summary>
        /// Adds a child view to this view.
        /// </summary>
        /// <seealso cref="Container.Add" />
        /// <since_tizen> 4 </since_tizen>
        public override void Add(View child)
        {
            bool hasLayout = (layout != null);

            if (null == child)
            {
                Tizen.Log.Fatal("NUI", "Child is null");
                return;
            }

            Container oldParent = child.GetParent();

            if (oldParent != this)
            {
                // If child already has a parent then re-parent child
                if (oldParent != null)
                {
                    if (child.Layout != null)
                    {
                        child.Layout.SetReplaceFlag();
                    }
                    oldParent.Remove(child);
                }
                child.InternalParent = this;
                LayoutCount         += child.LayoutCount;

                Interop.Actor.Add(SwigCPtr, View.getCPtr(child));

                if (NDalicPINVOKE.SWIGPendingException.Pending)
                {
                    throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                }
                Children.Add(child);

                if (ChildAdded != null)
                {
                    ChildAddedEventArgs e = new ChildAddedEventArgs
                    {
                        Added = child
                    };
                    ChildAdded(this, e);
                }

                AddChildBindableObject(child);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Removes a child view from this View. If the view was not a child of this view, this is a no-op.
        /// </summary>
        /// <seealso cref="Container.Remove" />
        /// <since_tizen> 4 </since_tizen>
        public override void Remove(View child)
        {
            if (!child || child.GetParent() == null) // Early out if child null.
            {
                return;
            }

            bool hasLayout = (_layout != null);

            // If View has a layout then do a deferred child removal
            // Actual child removal is performed by the layouting system so
            // transitions can be completed.
            if (hasLayout)
            {
                (_layout as LayoutGroup)?.RemoveChildFromLayoutGroup(child);
            }

            RemoveChild(child);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Removes a child view from this View. If the view was not a child of this view, this is a no-op.
        /// </summary>
        /// <seealso cref="Container.Remove" />
        /// <since_tizen> 4 </since_tizen>
        /// <exception cref="InvalidOperationException">Thrown when deleting a view that is not a child of this view</exception>
        public override void Remove(View child)
        {
            if (child == null || child.GetParent() == null) // Early out if child null.
            {
                return;
            }

            if (child.Parent != this)
            {
                throw new System.InvalidOperationException("You have deleted a view that is not a child of this view.");
            }

            bool hasLayout = (layout != null);

            // If View has a layout then do a deferred child removal
            // Actual child removal is performed by the layouting system so
            // transitions can be completed.
            if (hasLayout)
            {
                (layout as LayoutGroup)?.RemoveChildFromLayoutGroup(child);
            }

            RemoveChild(child);
        }