/// <summary>
 /// Update an IElementCommon from another IElementCommon with transformation
 /// </summary>
 /// <param name="element">Receiving element, Can be a prototype or an instance</param>
 /// <param name="prototype">Reference element, Can be a prototype or an instance</param>
 /// <param name="selectivetr"></param>
 public static void UpdateCommon(this IElementCommon element, IElementCommon prototype, ApplyTransformMode selectivetr)
 {
     UpdateCommon(element, prototype);
     if (element is NotuiElement elinst)
     {
         if (prototype is NotuiElement el)
         {
             el.TargetTransformation.UpdateFrom(elinst.TargetTransformation, selectivetr);
         }
     }
     element.DisplayTransformation.UpdateFrom(prototype.DisplayTransformation, selectivetr);
 }
        /// <summary>
        /// Update an IElementCommon from another IElementCommon without transformation
        /// </summary>
        /// <param name="element">Receiving element, Can be a prototype or an instance</param>
        /// <param name="prototype">Reference element, Can be a prototype or an instance</param>
        public static void UpdateCommon(this IElementCommon element, IElementCommon prototype)
        {
            var setvals = true;

            element.Id = prototype.Id;

            if (element is NotuiElement elinst)
            {
                if (prototype is ElementPrototype prot)
                {
                    elinst.Prototype = prot;
                    setvals          = prot.SetAttachedValues;

                    if (prot.SubContextOptions == null)
                    {
                        elinst.SubContext = null;
                    }
                    else
                    {
                        if (elinst.SubContext == null)
                        {
                            elinst.SubContext = new SubContext(elinst, prot.SubContextOptions);
                        }
                        else
                        {
                            elinst.SubContext.UpdateFrom(prot.SubContextOptions);
                        }
                    }
                }
                if (prototype is NotuiElement el)
                {
                    elinst.Prototype = el.Prototype;

                    if (el.SubContext == null)
                    {
                        elinst.SubContext = null;
                    }
                    else
                    {
                        if (elinst.SubContext == null)
                        {
                            elinst.SubContext = new SubContext(elinst, el.SubContext.Options);
                        }
                        else
                        {
                            elinst.SubContext.UpdateFrom(el.SubContext.Options);
                        }
                    }
                }
            }

            if (element is ElementPrototype elprot)
            {
                if (prototype is ElementPrototype prot)
                {
                    elprot.SubContextOptions = prot.SubContextOptions?.Copy();
                    elprot.SetAttachedValues = prot.SetAttachedValues;
                }
                if (prototype is NotuiElement el)
                {
                    elprot.SubContextOptions = el.SubContext.Options?.Copy();
                }
            }

            element.Name                     = prototype.Name;
            element.Active                   = prototype.Active;
            element.Transparent              = prototype.Transparent;
            element.FadeOutTime              = prototype.FadeOutTime;
            element.FadeOutDelay             = prototype.FadeOutDelay;
            element.FadeInTime               = prototype.FadeInTime;
            element.FadeInDelay              = prototype.FadeInDelay;
            element.TransformationFollowTime = prototype.TransformationFollowTime;
            element.Behaviors                = prototype.Behaviors;
            element.OnlyHitIfParentIsHit     = prototype.OnlyHitIfParentIsHit;

            if (setvals && prototype.Value != null)
            {
                if (element.Value == null)
                {
                    element.Value = new AttachedValues();
                }

                element.Value.UpdateFrom(prototype.Value);
            }
        }