Ejemplo n.º 1
0
        /// <summary>
        /// Forces removal of this drawable from its parent, followed by immediate synchronous disposal.
        /// </summary>
        /// <remarks>
        /// This is intended as a temporary solution for the fact that there is no way to easily dispose
        /// a component in a way that is guaranteed to be synchronously run on the update thread.
        ///
        /// Eventually components will have a better method for unloading.
        /// </remarks>
        /// <param name="drawable">The <see cref="Drawable"/> to be disposed.</param>
        public static void RemoveAndDisposeImmediately(this Drawable drawable)
        {
            ThreadSafety.EnsureUpdateThread();

            drawable.Parent?.RemoveInternal(drawable);
            drawable.Dispose();
        }
Ejemplo n.º 2
0
        public virtual bool Remove(Drawable p, bool dispose = true)
        {
            if (p == null)
            {
                return(false);
            }

            bool result = children.Remove(p);

            p.Parent = null;

            if (dispose && p.IsDisposable)
            {
                p.Dispose();
            }
            else
            {
                p.Invalidate();
            }

            return(result);
        }
Ejemplo n.º 3
0
        protected bool Remove(Drawable p, bool dispose = true)
        {
            if (p == null)
            {
                return(false);
            }

            bool result = internalChildren.Remove(p);

            Invalidate();
            p.Parent = null;

            if (dispose && p.IsDisposable)
            {
                p.Dispose();
            }
            else
            {
                p.Invalidate();
            }

            return(result);
        }