コード例 #1
0
        private void Cleanup()
        {
            _maskGraphics.Stop();

            _component.RemoveEventListener(MoveEvent.MOVE, MoveHandler, EventPhase.Target);
            _component.RemoveEventListener(ResizeEvent.RESIZE, ResizeHandler, EventPhase.Target);

            if (null != _parent)
            {
                _parent.RemoveChild(_maskGraphics);
            }

            _maskGraphics = null;
        }
コード例 #2
0
        /// <summary>
        /// Shows the mask
        /// </summary>
        /// <param name="component"></param>
        public void Mask(DisplayListMember component)
        {
            _component = component;

#if DEBUG
            if (DebugMode)
            {
                Debug.Log("Masking component: " + component);
            }
#endif
            if (null != _maskGraphics)
            {
                return; // already masking this component
            }
            _parent = _component.Parent ?? (_component is Stage ? _component as Stage : null);

            if (null == _parent)
            {
                return; // we are not on the display list, so we have nothing to mask indeed
            }
            var imc = _component as InvalidationManagerClient;

            _maskGraphics = new T
            {
                IncludeInLayout = false,
                X     = _component.X,
                Y     = _component.Y,
                Width = null != imc?imc.GetExplicitOrMeasuredWidth() : _component.Width,
                            Height = null != imc?imc.GetExplicitOrMeasuredHeight() : _component.Height
                                         //Bounds = (Rectangle)_component.Bounds.Clone() // NOTE: BEWARE! This was the reference bug (without Clone())!!!!!!!!!
            };

            _parent.AddChild(_maskGraphics);
            //_maskGraphics.ValidateNow(); // commented out 20130331 and moved to LoadingMaskAnimator

            // critical!
            //_maskGraphics.Transform.Apply(); // TODO: remove
            //_maskGraphics.Parent.Transform.ValidateChild(_maskGraphics);
            _maskGraphics.InvalidateTransform();

            // subscribe to MOVE and RESIZE events of the component
            // we shall be levitating just over the component
            _component.AddEventListener(MoveEvent.MOVE, MoveHandler, EventPhase.Target);
            _component.AddEventListener(ResizeEvent.RESIZE, ResizeHandler, EventPhase.Target);

            _maskGraphics.Play();
        }
コード例 #3
0
        /// <summary>
        /// Hides the mask
        /// </summary>
        public void Unmask()
        {
            if (null == _maskGraphics)
            {
                return;
            }

            _maskGraphics.Stop();

            _component.RemoveEventListener(MoveEvent.MOVE, MoveHandler, EventPhase.Target);
            _component.RemoveEventListener(ResizeEvent.RESIZE, ResizeHandler, EventPhase.Target);

            if (null != _parent)
            {
                _parent.RemoveChild(_maskGraphics);
            }

            _maskGraphics.Dispose();
            _maskGraphics = null;
        }