示例#1
0
        /// <summary>
        /// Invokes the drag event and adjusts the size and location if a valid docking position was received.
        /// This method is only used by explicit drag windows (see flag).
        /// </summary>
        internal void MoveWindow()
        {
            dragTarget = SendDockEvent(false);

            if (dragTarget != null)
            {
                if (dragWindow == null)
                {
                    dragWindow      = new OverlayForm();
                    dragWindow.Size = dragTarget.Size;
                    dragWindow.Show();
                    this.BringToFront();
                }
                else
                {
                    dragWindow.Size = dragTarget.Size;
                }

                if (dragTarget.Parent != null)
                {
                    dragWindow.Location = dragTarget.RectangleToScreen(dragTarget.ClientRectangle).Location;
                }
                else
                {
                    dragWindow.Location = dragTarget.Location;
                }
            }
            else if (DockManager.FastMoveDraw)
            {
                if (dragWindow == null)
                {
                    dragWindow      = new OverlayForm();
                    dragWindow.Size = this.Size;
                    dragWindow.Show();
                }
                else
                {
                    dragWindow.Size = this.Size;
                }

                dragWindow.Location = this.Location;
            }
            else
            {
                CloseDragWindow();
            }
        }
        internal static void UpdateDockGuide(DockContainer target, DockEventArgs e)
        {
            if ((target == null) | noGuidePlease | (style != DockVisualStyle.VS2005) | fastMoveDraw)
            {
                HideDockGuide();
                return;
            }

            if (dockGuide == null)
            {
                dockGuide = new OverlayForm();
            }

            dockGuide.TargetHost = target;
            dockGuide.Size       = target.Size;

            if (!dockGuide.Visible)
            {
                dockGuide.Show();
            }

            if (target.Parent != null)
            {
                dockGuide.Location = target.RectangleToScreen(target.ClientRectangle).Location;
            }
            else
            {
                dockGuide.Location = target.Location;
            }

            dockGuide.BringToFront();

            // Make tests.
            DockStyle dstStyle = dockGuide.HitTest(e.Point);

            if (dstStyle != DockStyle.None)
            {
                e.Point = target.GetVirtualDragDest(dstStyle);
            }
            else
            {
                e.Handled = true;
            }

            e.ShowDockGuide = true;
        }
示例#3
0
 internal static void UpdateDockGuide(DockContainer target, DockEventArgs e)
 {
     if ((((target == null) | noGuidePlease) | (DockManager.style != DockVisualStyle.VS2005)) | fastMoveDraw)
     {
         HideDockGuide();
     }
     else
     {
         if (dockGuide == null)
         {
             dockGuide = new OverlayForm();
         }
         Size  size     = dockGuide.Size;
         Point location = dockGuide.Location;
         dockGuide.TargetHost = target;
         dockGuide.Size       = target.Size;
         if (!dockGuide.Visible)
         {
             dockGuide.Show();
         }
         if (target.Parent != null)
         {
             dockGuide.Location = target.RectangleToScreen(target.ClientRectangle).Location;
         }
         else
         {
             dockGuide.Location = target.Location;
         }
         if ((dockGuide.Location != location) || (dockGuide.Size != size))
         {
             dockGuide.Invalidate();
         }
         dockGuide.BringToFront();
         DockStyle style = dockGuide.HitTest(e.Point);
         if (style != DockStyle.None)
         {
             e.Point = target.GetVirtualDragDest(style);
         }
         else
         {
             e.Handled = true;
         }
         e.ShowDockGuide = true;
     }
 }
        /// <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();
                }
            }
        }