Esempio 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);
        }
Esempio n. 2
0
        protected override void OnVisibleChanged(EventArgs e)
        {
            base.OnVisibleChanged(e);
            int             AnimationDuration = this.Visible ? this.ShowingDuration : this.HidingDuration;
            PopupAnimations _flags            = this.Visible ? this.ShowingAnimation : this.HidingAnimation;

            PopupNativeMethods.AnimationFlags flags = this.Visible ? PopupNativeMethods.AnimationFlags.Roll : PopupNativeMethods.AnimationFlags.Hide;
            flags = flags | (PopupNativeMethods.AnimationFlags.Mask & (PopupNativeMethods.AnimationFlags)(int) _flags);
            PopupNativeMethods.AnimateWindow(this, AnimationDuration, flags);
        }
Esempio n. 3
0
File: Popup.cs Progetto: Kuzq/gitter
        public Popup(Control content)
        {
            Verify.Argument.IsNotNull(content, "content");

            _content = content;
            _popupAnimation = PopupAnimations.SystemDefault;
            _closeAnimation = PopupAnimations.None;
            _animationDuration = 100;
            _isChildPopupOpened = false;

            AutoSize = false;
            DoubleBuffered = true;
            ResizeRedraw = true;

            _host = new ToolStripControlHost(content)
            {
                Padding = Padding.Empty,
                Margin = Padding.Empty,
            };
            Padding = Padding.Empty;
            Margin = Padding.Empty;

            _minimumSize = content.MinimumSize;
            content.MinimumSize = content.Size;
            _maximumSize = content.MaximumSize;
            content.MaximumSize = content.Size;
            Size = content.Size;
            content.Location = Point.Empty;

            content.TabStop = true;
            TabStop = true;

            Items.Add(_host);

            content.Disposed += (sender, e) =>
                {
                    content = null;
                    Dispose(true);
                };
            content.RegionChanged += (sender, e) =>
                {
                    UpdateRegion();
                };
            content.Paint += (sender, e) =>
                {
                    PaintSizeGrip(e);
                };

            UpdateRegion();
        }
Esempio n. 4
0
        public Popup(Control content)
        {
            Verify.Argument.IsNotNull(content, nameof(content));

            Content             = content;
            _popupAnimation     = PopupAnimations.SystemDefault;
            _closeAnimation     = PopupAnimations.None;
            _animationDuration  = 100;
            _isChildPopupOpened = false;

            AutoSize       = false;
            DoubleBuffered = true;
            ResizeRedraw   = true;

            _host = new ToolStripControlHost(content)
            {
                Padding = Padding.Empty,
                Margin  = Padding.Empty,
            };
            Padding = Padding.Empty;
            Margin  = Padding.Empty;

            _minimumSize        = content.MinimumSize;
            content.MinimumSize = content.Size;
            _maximumSize        = content.MaximumSize;
            content.MaximumSize = content.Size;
            Size             = content.Size;
            content.Location = Point.Empty;

            content.TabStop = true;
            TabStop         = true;

            Items.Add(_host);

            content.Disposed += (sender, e) =>
            {
                content = null;
                Dispose(true);
            };
            content.RegionChanged += (sender, e) =>
            {
                UpdateRegion();
            };
            content.Paint += (sender, e) =>
            {
                PaintSizeGrip(e);
            };

            UpdateRegion();
        }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PopupControl.Popup"/> class.
 /// </summary>
 /// <param name="content">The content of the pop-up.</param>
 /// <remarks>
 /// Pop-up will be disposed immediately after disposion of the content control.
 /// </remarks>
 /// <exception cref="T:System.ArgumentNullException"><paramref name="content" /> is <code>null</code>.</exception>
 public Popup(Control content)
 {
     if (content == null)
     {
         throw new ArgumentNullException("content");
     }
     Content           = content;
     FocusOnOpen       = true;
     AcceptAlt         = true;
     ShowingAnimation  = PopupAnimations.SystemDefault;
     HidingAnimation   = PopupAnimations.None;
     AnimationDuration = 100;
     InitializeComponent();
     AutoSize       = false;
     DoubleBuffered = true;
     ResizeRedraw   = true;
     _host          = new ToolStripControlHost(content);
     Padding        = Margin = _host.Padding = _host.Margin = Padding.Empty;
     if (NativeMethods.IsRunningOnMono)
     {
         content.Margin = Padding.Empty;
     }
     MinimumSize         = content.MinimumSize;
     content.MinimumSize = content.Size;
     MaximumSize         = content.MaximumSize;
     content.MaximumSize = content.Size;
     Size = content.Size;
     if (NativeMethods.IsRunningOnMono)
     {
         _host.Size = content.Size;
     }
     TabStop          = content.TabStop = true;
     content.Location = Point.Empty;
     Items.Add(_host);
     content.Disposed += (sender, e) =>
     {
         content = null;
         Dispose(true);
     };
     content.RegionChanged += (sender, e) => UpdateRegion();
     content.Paint         += (sender, e) => PaintSizeGrip(e);
     UpdateRegion();
 }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PopupControl.Popup"/> class.
 /// </summary>
 /// <param name="content">The content of the pop-up.</param>
 /// <remarks>
 /// Pop-up will be disposed immediately after disposion of the content control.
 /// </remarks>
 /// <exception cref="T:System.ArgumentNullException"><paramref name="content" /> is <code>null</code>.</exception>
 public Popup(Control content)
 {
     if (content == null)
     {
         throw new ArgumentNullException("content");
     }
     this.content            = content;
     this.showingAnimation   = PopupAnimations.SystemDefault;
     this.hidingAnimation    = PopupAnimations.None;
     this.animationDuration  = 100;
     this.isChildPopupOpened = false;
     InitializeComponent();
     AutoSize            = false;
     DoubleBuffered      = true;
     ResizeRedraw        = true;
     host                = new ToolStripControlHost(content);
     Padding             = Margin = host.Padding = host.Margin = Padding.Empty;
     MinimumSize         = content.MinimumSize;
     content.MinimumSize = content.Size;
     MaximumSize         = content.MaximumSize;
     content.MaximumSize = content.Size;
     Size                = content.Size;
     TabStop             = content.TabStop = true;
     content.Location    = Point.Empty;
     Items.Add(host);
     content.Disposed += delegate(object sender, EventArgs e)
     {
         content = null;
         Dispose(true);
     };
     content.RegionChanged += delegate(object sender, EventArgs e)
     {
         UpdateRegion();
     };
     content.Paint += delegate(object sender, PaintEventArgs e)
     {
         PaintSizeGrip(e);
     };
     UpdateRegion();
 }
Esempio n. 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PopupControl.Popup"/> class.
 /// </summary>
 /// <param name="content">The content of the pop-up.</param>
 /// <remarks>
 /// Pop-up will be disposed immediately after disposion of the content control.
 /// </remarks>
 /// <exception cref="T:System.ArgumentNullException"><paramref name="content" /> is <code>null</code>.</exception>
 public Popup(Control content)
 {
     if (content == null)
     {
         throw new ArgumentNullException("content");
     }
     this.content = content;
     this.showingAnimation = PopupAnimations.SystemDefault;
     this.hidingAnimation = PopupAnimations.None;
     this.animationDuration = 100;
     this.isChildPopupOpened = false;
     InitializeComponent();
     AutoSize = false;
     DoubleBuffered = true;
     ResizeRedraw = true;
     host = new ToolStripControlHost(content);
     Padding = Margin = host.Padding = host.Margin = Padding.Empty;
     MinimumSize = content.MinimumSize;
     content.MinimumSize = content.Size;
     MaximumSize = content.MaximumSize;
     content.MaximumSize = content.Size;
     Size = content.Size;
     TabStop = content.TabStop = true;
     content.Location = Point.Empty;
     Items.Add(host);
     content.Disposed += delegate(object sender, EventArgs e)
     {
         content = null;
         Dispose(true);
     };
     content.RegionChanged += delegate(object sender, EventArgs e)
     {
         UpdateRegion();
     };
     content.Paint += delegate(object sender, PaintEventArgs e)
     {
         PaintSizeGrip(e);
     };
     UpdateRegion();
 }
Esempio n. 8
0
        public Popup(Control content)
        {
            var popup = this;

            if (content == null)
            {
                throw new ArgumentNullException("content");
            }
            this.content            = content;
            this.showingAnimation   = PopupAnimations.SystemDefault;
            this.hidingAnimation    = PopupAnimations.None;
            this.animationDuration  = 100;
            this.isChildPopupOpened = false;
            this.InitializeComponent();
            this.AutoSize       = false;
            this.DoubleBuffered = true;
            this.ResizeRedraw   = true;
            this.host           = new ToolStripControlHost(content);
            this.Padding        = this.Margin = this.host.Padding = this.host.Margin = Padding.Empty;
            this.MinimumSize    = content.MinimumSize;
            content.MinimumSize = content.Size;
            this.MaximumSize    = content.MaximumSize;
            content.MaximumSize = content.Size;
            this.Size           = content.Size;
            this.TabStop        = content.TabStop = true;
            content.Location    = Point.Empty;
            this.Items.Add((ToolStripItem)this.host);
            content.Disposed += (EventHandler)((sender, e) =>
            {
                content = (Control)null;
                popup.Dispose(true);
            });
            content.RegionChanged += (EventHandler)((sender, e) => this.UpdateRegion());
            content.Paint         += (PaintEventHandler)((sender, e) => this.PaintSizeGrip(e));
            this.UpdateRegion();
        }
Esempio n. 9
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 (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);
        }
Esempio n. 10
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);
        }