Ejemplo n.º 1
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.ToolStripItem.VisibleChanged"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data.</param>
        protected override void OnVisibleChanged(EventArgs e)
        {
            base.OnVisibleChanged(e);
            if ((Visible && ShowingAnimation == PopupAnimations.None) || (!Visible && HidingAnimation == PopupAnimations.None))
            {
                return;
            }
            NativeMethods.AnimationFlags flags = Visible ? NativeMethods.AnimationFlags.Roll : NativeMethods.AnimationFlags.Hide;
            PopupAnimations _flags             = Visible ? ShowingAnimation : HidingAnimation;

            if (_flags == PopupAnimations.SystemDefault)
            {
                if (SystemInformation.IsMenuAnimationEnabled)
                {
                    if (SystemInformation.IsMenuFadeEnabled)
                    {
                        _flags = PopupAnimations.Blend;
                    }
                    else
                    {
                        _flags = PopupAnimations.Slide | (Visible ? PopupAnimations.TopToBottom : PopupAnimations.BottomToTop);
                    }
                }
                else
                {
                    _flags = PopupAnimations.None;
                }
            }
            if ((_flags & (PopupAnimations.Blend | PopupAnimations.Center | PopupAnimations.Roll | PopupAnimations.Slide)) == PopupAnimations.None)
            {
                return;
            }
            if (resizableTop) // popup is “inverted”, so the animation must be
            {
                if ((_flags & PopupAnimations.BottomToTop) != PopupAnimations.None)
                {
                    _flags = (_flags & ~PopupAnimations.BottomToTop) | PopupAnimations.TopToBottom;
                }
                else if ((_flags & PopupAnimations.TopToBottom) != PopupAnimations.None)
                {
                    _flags = (_flags & ~PopupAnimations.TopToBottom) | PopupAnimations.BottomToTop;
                }
            }
            if (resizableLeft) // popup is “inverted”, so the animation must be
            {
                if ((_flags & PopupAnimations.RightToLeft) != PopupAnimations.None)
                {
                    _flags = (_flags & ~PopupAnimations.RightToLeft) | PopupAnimations.LeftToRight;
                }
                else if ((_flags & PopupAnimations.LeftToRight) != PopupAnimations.None)
                {
                    _flags = (_flags & ~PopupAnimations.LeftToRight) | PopupAnimations.RightToLeft;
                }
            }
            flags = flags | (NativeMethods.AnimationFlags.Mask & (NativeMethods.AnimationFlags)(int) _flags);
            NativeMethods.AnimateWindow(this, AnimationDuration, flags);
        }
Ejemplo n.º 2
0
 internal static void AnimateWindow(Control control, int time, NativeMethods.AnimationFlags flags)
 {
     try
     {
         System.Security.Permissions.SecurityPermission securityPermission = new System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode);
         securityPermission.Demand();
         NativeMethods.AnimateWindow(new System.Runtime.InteropServices.HandleRef(control, control.Handle), time, flags);
     }
     catch (System.Security.SecurityException)
     {
     }
 }
Ejemplo n.º 3
0
        protected override void OnVisibleChanged(System.EventArgs e)
        {
            base.OnVisibleChanged(e);
            if ((Visible & ShowingAnimation == PopupAnimation.None) | (Visible & HidingAnimation == PopupAnimation.None))
            {
                return;
            }
            NativeMethods.AnimationFlags flags = Visible ? NativeMethods.AnimationFlags.Roll : NativeMethods.AnimationFlags.Hide;
            PopupAnimation _flags = Visible ? ShowingAnimation : HidingAnimation;

            if ((_flags == PopupAnimation.SystemDefault))
            {
                if (SystemInformation.IsMenuAnimationEnabled)
                {
                    if (SystemInformation.IsMenuFadeEnabled)
                    {
                        _flags = PopupAnimation.Blend;
                    }
                    else
                    {
                        _flags = PopupAnimation.Slide | (Visible ? PopupAnimation.TopToBottom : PopupAnimation.BottomToTop);
                    }
                }
                else
                {
                    _flags = PopupAnimation.None;
                }
            }

            if ((_flags & (PopupAnimation.Blend | PopupAnimation.Center | PopupAnimation.Roll | PopupAnimation.Slide)) == PopupAnimation.None)
            {
                return;
            }

            if (_resizabletop)
            {
                if ((_flags & PopupAnimation.BottomToTop) != PopupAnimation.None)
                {
                    _flags = (_flags & ~PopupAnimation.BottomToTop) | PopupAnimation.TopToBottom;
                }
                else if ((_flags & PopupAnimation.TopToBottom) != PopupAnimation.None)
                {
                }
                else
                {
                    _flags = (_flags & ~PopupAnimation.TopToBottom) | PopupAnimation.BottomToTop;
                }
            }

            if (_resizableleft)
            {
                if ((_flags & PopupAnimation.RightToLeft) != PopupAnimation.None)
                {
                    _flags = (_flags & ~PopupAnimation.RightToLeft) | PopupAnimation.LeftToRight;
                }
                else if ((_flags & PopupAnimation.LeftToRight) != PopupAnimation.None)
                {
                    _flags = (_flags & ~PopupAnimation.LeftToRight) | PopupAnimation.RightToLeft;
                }
                else
                {
                }
            }

            flags = flags | (NativeMethods.AnimationFlags.Mask & (NativeMethods.AnimationFlags)Convert.ToInt32(_flags));
            NativeMethods.SetTopMost(this);
            NativeMethods.AnimateWindow(this, AnimationDuration, flags);
        }
Ejemplo n.º 4
0
 private static extern int AnimateWindow(System.Runtime.InteropServices.HandleRef windowHandle, int time, NativeMethods.AnimationFlags flags);
Ejemplo n.º 5
0
        protected override void OnVisibleChanged(System.EventArgs e)
        {
            base.OnVisibleChanged(e);
            if (NativeMethods.IsRunningOnMono)
            {
                return;
            }
            if ((base.Visible && this.ShowingAnimation == PopupAnimations.None) || (!base.Visible && this.HidingAnimation == PopupAnimations.None))
            {
                return;
            }
            NativeMethods.AnimationFlags animationFlags = base.Visible ? NativeMethods.AnimationFlags.Roll : NativeMethods.AnimationFlags.Hide;
            PopupAnimations popupAnimations             = base.Visible ? this.ShowingAnimation : this.HidingAnimation;

            if (popupAnimations == PopupAnimations.SystemDefault)
            {
                if (SystemInformation.IsMenuAnimationEnabled)
                {
                    if (SystemInformation.IsMenuFadeEnabled)
                    {
                        popupAnimations = PopupAnimations.Blend;
                    }
                    else
                    {
                        popupAnimations = (PopupAnimations.Slide | (base.Visible ? PopupAnimations.TopToBottom : PopupAnimations.BottomToTop));
                    }
                }
                else
                {
                    popupAnimations = PopupAnimations.None;
                }
            }
            if ((popupAnimations & (PopupAnimations.Center | PopupAnimations.Slide | PopupAnimations.Blend | PopupAnimations.Roll)) == PopupAnimations.None)
            {
                return;
            }
            if (this._resizableTop)
            {
                if ((popupAnimations & PopupAnimations.BottomToTop) != PopupAnimations.None)
                {
                    popupAnimations = ((popupAnimations & ~PopupAnimations.BottomToTop) | PopupAnimations.TopToBottom);
                }
                else
                {
                    if ((popupAnimations & PopupAnimations.TopToBottom) != PopupAnimations.None)
                    {
                        popupAnimations = ((popupAnimations & ~PopupAnimations.TopToBottom) | PopupAnimations.BottomToTop);
                    }
                }
            }
            if (this._resizableLeft)
            {
                if ((popupAnimations & PopupAnimations.RightToLeft) != PopupAnimations.None)
                {
                    popupAnimations = ((popupAnimations & ~PopupAnimations.RightToLeft) | PopupAnimations.LeftToRight);
                }
                else
                {
                    if ((popupAnimations & PopupAnimations.LeftToRight) != PopupAnimations.None)
                    {
                        popupAnimations = ((popupAnimations & ~PopupAnimations.LeftToRight) | PopupAnimations.RightToLeft);
                    }
                }
            }
            animationFlags |= (NativeMethods.AnimationFlags)((PopupAnimations)1048575 & popupAnimations);
            NativeMethods.SetTopMost(this);
            NativeMethods.AnimateWindow(this, this.AnimationDuration, animationFlags);
        }