Esempio n. 1
0
        /// <summary>
        /// Handler for child position changed events.
        /// </summary>
        private void ChildPositionChangedHdl(UIObject sender, RCIntVector prevPos, RCIntVector currPos)
        {
            UISensitiveObject sensitiveSender = sender as UISensitiveObject;

            if (sensitiveSender != null)
            {
                /// Invalidate the cached values of the sender.
                sensitiveSender.InvalidateSensitivePosition();
                sensitiveSender.InvalidateSensitiveClipRect();
                sensitiveSender.InvalidateSensitiveCloakRect();
                sensitiveSender.InvalidateSensitiveRangeRect();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Detaches the given sensitive child of this UISensitiveObject.
        /// </summary>
        /// <param name="whichChild">The UISensitiveObject you want to detach.</param>
        public void DetachSensitive(UISensitiveObject whichChild)
        {
            if (UIRoot.Instance.GraphicsPlatform.RenderLoop.IsRendering)
            {
                throw new InvalidOperationException("Rendering is in progress!");
            }
            if (whichChild.Parent != this)
            {
                throw new UIException("The object is already detached by UIObject.Detach!");
            }
            if (whichChild == null)
            {
                throw new ArgumentNullException("whichChild");
            }

            if (!this.sensitiveChildrenSet.Contains(whichChild))
            {
                return;
            }

            /// Raise the UISensitiveObject.ObjectDetaching event of the sensitive-root.
            if (this.SensitiveRoot.ObjectDetaching != null)
            {
                this.SensitiveRoot.ObjectDetaching(whichChild);
            }

            /// Detach
            //this.Detach(whichChild);
            this.sensitiveChildrenSet.Remove(whichChild);
            this.sensitiveChildren.Remove(whichChild);
            whichChild.sensitiveParent = null;

            /// Unbscribe from the PositionChanged, ClipRectChanged, CloakRectChanged and RangeRectChanged
            /// events of whichChild
            whichChild.PositionChanged  -= this.ChildPositionChangedHdl;
            whichChild.ClipRectChanged  -= this.ChildClipRectChangedHdl;
            whichChild.CloakRectChanged -= this.ChildCloakRectChangedHdl;
            whichChild.RangeRectChanged -= this.ChildRangeRectChangedHdl;

            /// Unsubscribe from the Z-order events of whichChild
            whichChild.BroughtForward -= this.BroughtForwardHdl;
            whichChild.BroughtToTop   -= this.BroughtToTopHdl;
            whichChild.SentBackward   -= this.SentBackwardHdl;
            whichChild.SentToBottom   -= this.SentToBottomHdl;

            /// Invalidate the cached values in the detached UISensitiveObject
            whichChild.InvalidateSensitivePosition();
            whichChild.InvalidateSensitiveClipRect();
            whichChild.InvalidateSensitiveCloakRect();
            whichChild.InvalidateSensitiveRangeRect();
        }
Esempio n. 3
0
        /// <summary>
        /// Attaches the given UISensitiveObject to this UISensitiveObject as a sensitive child.
        /// </summary>
        /// <param name="otherObj">The UISensitiveObject you want to attach as a sensitive child.</param>
        public void AttachSensitive(UISensitiveObject otherObj)
        {
            if (UIRoot.Instance.GraphicsPlatform.RenderLoop.IsRendering)
            {
                throw new InvalidOperationException("Rendering is in progress!");
            }
            if (otherObj == null)
            {
                throw new ArgumentNullException("otherObj");
            }
            if (otherObj == this)
            {
                throw new UIException("Unable to attach a UISensitiveObject to itself as a sensitive child!");
            }
            if (otherObj.Parent != this)
            {
                throw new UIException("The object must be attached first by UIObject.Attach!");
            }
            if (otherObj.sensitiveParent != null)
            {
                throw new UIException("The given UISensitiveObject must be detached from it's sensitive parent first!");
            }

            /// Attach
            //this.Attach(otherObj);
            this.sensitiveChildrenSet.Add(otherObj);
            this.sensitiveChildren.Insert(0, otherObj);
            otherObj.sensitiveParent = this;

            /// Check the tree property
            if (this.CheckTreeProperty())
            {
                /// Subscribe for the Z-order events of otherObj
                otherObj.BroughtForward += this.BroughtForwardHdl;
                otherObj.BroughtToTop   += this.BroughtToTopHdl;
                otherObj.SentBackward   += this.SentBackwardHdl;
                otherObj.SentToBottom   += this.SentToBottomHdl;

                /// Subscribe for the PositionChanged, ClipRectChanged, CloakRectChanged and RangeRectChanged
                /// events of otherObj
                otherObj.PositionChanged  += this.ChildPositionChangedHdl;
                otherObj.ClipRectChanged  += this.ChildClipRectChangedHdl;
                otherObj.CloakRectChanged += this.ChildCloakRectChangedHdl;
                otherObj.RangeRectChanged += this.ChildRangeRectChangedHdl;

                /// Invalidate the cached values in the attached UISensitiveObject
                otherObj.InvalidateSensitivePosition();
                otherObj.InvalidateSensitiveClipRect();
                otherObj.InvalidateSensitiveCloakRect();
                otherObj.InvalidateSensitiveRangeRect();

                /// Raise the UISensitiveObject.ObjectAttached event of the sensitive-root.
                if (this.SensitiveRoot.ObjectAttached != null)
                {
                    this.SensitiveRoot.ObjectAttached(otherObj);
                }
            }
            else
            {
                /// Tree property violation --> rollback and throw an exception.
                this.sensitiveChildren.RemoveAt(0);
                this.sensitiveChildrenSet.Remove(otherObj);
                otherObj.sensitiveParent = null;
                throw new UIException("Violating tree property!");
            }
        }