/// <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 (UnsafeNativeMethods.IsRunningOnMono) { return; // in case of non-Windows } if ((Visible && ShowingAnimation == PopupAnimations.None) || (!Visible && HidingAnimation == PopupAnimations.None)) { return; } var flags = Visible ? Consts.AW_ROLL : Consts.AW_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 | (Consts.AW_MASK & (int)_flags); UnsafeNativeMethods.SetTopMost(this); UnsafeNativeMethods.AnimateWindow(this, AnimationDuration, flags); }