示例#1
0
        /// <summary>
        /// Removes a control
        /// </summary>
        /// <param name="control"></param>
        public void RemoveControl(GUIControl control)
        {
            GUIControlCollection collection = (control.Parent != null ? control.Parent.Controls : Controls);

            if (collection.Contains(control, true))
            {
                // Now cycle through the active sceneView's animations and remove
                // all animations for this control.
                int cnt = Animations.Count;
                for (int i = cnt - 1; i >= 0; i--)
                {
                    GUIAnimation animation = Animations[i];
                    if (animation.GetAnimationChannel(control) != null)
                    {
                        animation.RemoveAnimationChannel(control);
                    }
                }

                control.Parent = null;
                collection.Remove(control, true);
            }

            if (control.GetType() == typeof(GUIMask))
            {
                //remove any reference to this mask from other controls
                foreach (GUIControl thisControl in Controls)
                {
                    if (thisControl.Mask == control.ID)
                    {
                        thisControl.Mask = -1;
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// Adds a control as the child of another.
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="control"></param>
        /// <param name="atIndex"></param>
        public void AddControl(GUIControl parent, GUIControl control, int atIndex)
        {
            GUIControlCollection collection = (parent != null ? parent.Controls : this.Controls);

            if (!collection.Contains(control, true))
            {
                // We need create a keyframe for this control on the "OnActivate" channel
                GUIAnimation onActivate = Animations["OnActivate"];
                if (onActivate != null)
                {
                    onActivate.CreateKeyFrame(control, 0);
                }

                control.Parent = (parent != null) ? parent : this;

                if (atIndex >= 0)
                {
                    collection.Insert(atIndex, control);
                }
                else
                {
                    collection.Add(control);
                }
            }
        }