コード例 #1
0
        /// <summary>
        /// Expands the base class function with auto-hide checks.
        /// </summary>
        /// <param name="e">A <see cref="MouseEventArgs"/> that contains the mouse data.</param>
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            Rectangle rc;
            Size      size;

            if (autoHideContainer != null)
            {
                if (autoHideContainer.fading)
                {
                    return;
                }
            }

            #region AutoHide Left
            foreach (DockContainer c in autoHideL)
            {
                foreach (DockPanel p in c.panList)
                {
                    rc = new Rectangle((int)p.TabRect.Left, (int)p.TabRect.Top, (int)p.TabRect.Width, (int)p.TabRect.Height);

                    if (RectangleToScreen(rc).Contains(MousePosition.X, MousePosition.Y))
                    {
                        c.ActivePanel = p;

                        if (c != autoHideContainer)
                        {
                            disableOnControlAdded  = true;
                            disableOnControlRemove = true;

                            this.Controls.Remove(autoHideContainer);
                            autoHideContainer = c;
                            size       = c.Size;
                            c.Dock     = DockStyle.None;
                            c.Location = new Point(dockOffsetL, dockOffsetT);
                            c.Size     = new Size(size.Width, this.Height - dockOffsetT - dockOffsetB);
                            c.Anchor   = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom;
                            this.Controls.Add(c);
                            c.FadeIn();

                            disableOnControlAdded  = false;
                            disableOnControlRemove = false;
                        }

                        return;
                    }
                }
            }
            #endregion

            #region AutoHide Right
            foreach (DockContainer c in autoHideR)
            {
                foreach (DockPanel p in c.panList)
                {
                    rc = new Rectangle((int)p.TabRect.Left, (int)p.TabRect.Top, (int)p.TabRect.Width, (int)p.TabRect.Height);

                    if (RectangleToScreen(rc).Contains(MousePosition.X, MousePosition.Y))
                    {
                        c.ActivePanel = p;

                        if (c != autoHideContainer)
                        {
                            this.Controls.Remove(autoHideContainer);
                            autoHideContainer = c;
                            size       = c.Size;
                            c.Dock     = DockStyle.None;
                            c.Location = new Point(this.Width - size.Width - dockOffsetR, dockOffsetT);
                            c.Size     = new Size(size.Width, this.Height - dockOffsetT - dockOffsetB);
                            c.Anchor   = AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
                            this.Controls.Add(c);
                            c.FadeIn();
                        }

                        return;
                    }
                }
            }
            #endregion

            #region AutoHide Top
            foreach (DockContainer c in autoHideT)
            {
                foreach (DockPanel p in c.panList)
                {
                    rc = new Rectangle((int)p.TabRect.Left, (int)p.TabRect.Top, (int)p.TabRect.Width, (int)p.TabRect.Height);

                    if (RectangleToScreen(rc).Contains(MousePosition.X, MousePosition.Y))
                    {
                        c.ActivePanel = p;

                        if (c != autoHideContainer)
                        {
                            this.Controls.Remove(autoHideContainer);
                            autoHideContainer = c;
                            size       = c.Size;
                            c.Dock     = DockStyle.None;
                            c.Location = new Point(dockOffsetL, dockOffsetT);
                            c.Size     = new Size(this.Width - dockOffsetL - dockOffsetR, size.Height);
                            c.Anchor   = AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Left;
                            this.Controls.Add(c);
                            c.FadeIn();
                        }

                        return;
                    }
                }
            }
            #endregion

            #region AutoHide Bottom
            foreach (DockContainer c in autoHideB)
            {
                foreach (DockPanel p in c.panList)
                {
                    rc = new Rectangle((int)p.TabRect.Left, (int)p.TabRect.Top, (int)p.TabRect.Width, (int)p.TabRect.Height);

                    if (RectangleToScreen(rc).Contains(MousePosition.X, MousePosition.Y))
                    {
                        c.ActivePanel = p;

                        if (c != autoHideContainer)
                        {
                            this.Controls.Remove(autoHideContainer);
                            autoHideContainer = c;
                            size       = c.Size;
                            c.Dock     = DockStyle.None;
                            c.Location = new Point(dockOffsetL, this.Height - size.Height - dockOffsetB);
                            c.Size     = new Size(this.Width - dockOffsetL - dockOffsetR, size.Height);
                            c.Anchor   = AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Left;
                            this.Controls.Add(c);
                            c.FadeIn();
                        }

                        return;
                    }
                }
            }
            #endregion

            if (autoHideContainer != null)
            {
                if (!autoHideContainer.RectangleToScreen(autoHideContainer.ClientRectangle).Contains(MousePosition.X, MousePosition.Y))
                {
                    autoHideContainer.FadeOut();
                }
            }
        }