private void Content_OnEndDrag(bool abort)
        {
            User32.SetCursor(DragControl.Cursor.Handle);

            if (abort)
            {
                return;
            }

            DockContent content = ((DockPane)DragControl).ActiveContent;

            if (DropTarget.DropTo is DockPane)
            {
                DockPane paneTo = DropTarget.DropTo as DockPane;

                if (DropTarget.Dock == DockStyle.Fill)
                {
                    bool samePane = (content.Pane == paneTo);
                    if (!samePane)
                    {
                        content.Pane = paneTo;
                    }

                    if (DropTarget.ContentIndex == -1 || !samePane)
                    {
                        paneTo.SetContentIndex(content, DropTarget.ContentIndex);
                    }
                    else
                    {
                        DockContentCollection contents = paneTo.Contents;
                        int oldIndex = contents.IndexOf(content);
                        int newIndex = DropTarget.ContentIndex;
                        if (oldIndex < newIndex)
                        {
                            newIndex += 1;
                            if (newIndex > contents.Count - 1)
                            {
                                newIndex = -1;
                            }
                        }
                        paneTo.SetContentIndex(content, newIndex);
                    }

                    content.Activate();
                }
                else
                {
                    DockPane           pane      = content.DockPanel.DockPaneFactory.CreateDockPane(content, paneTo.DockState, true);
                    IDockListContainer container = paneTo.DockListContainer;
                    if (DropTarget.Dock == DockStyle.Left)
                    {
                        pane.AddToDockList(container, paneTo, DockAlignment.Left, 0.5);
                    }
                    else if (DropTarget.Dock == DockStyle.Right)
                    {
                        pane.AddToDockList(container, paneTo, DockAlignment.Right, 0.5);
                    }
                    else if (DropTarget.Dock == DockStyle.Top)
                    {
                        pane.AddToDockList(container, paneTo, DockAlignment.Top, 0.5);
                    }
                    else if (DropTarget.Dock == DockStyle.Bottom)
                    {
                        pane.AddToDockList(container, paneTo, DockAlignment.Bottom, 0.5);
                    }

                    pane.DockState = paneTo.DockState;
                    pane.Activate();
                }
            }
            else if (DropTarget.DropTo is DockPanel)
            {
                DockPane  pane;
                DockPanel dockPanel = content.DockPanel;
                if (DropTarget.Dock == DockStyle.Top)
                {
                    pane = dockPanel.DockPaneFactory.CreateDockPane(content, DockState.DockTop, true);
                }
                else if (DropTarget.Dock == DockStyle.Bottom)
                {
                    pane = dockPanel.DockPaneFactory.CreateDockPane(content, DockState.DockBottom, true);
                }
                else if (DropTarget.Dock == DockStyle.Left)
                {
                    pane = dockPanel.DockPaneFactory.CreateDockPane(content, DockState.DockLeft, true);
                }
                else if (DropTarget.Dock == DockStyle.Right)
                {
                    pane = dockPanel.DockPaneFactory.CreateDockPane(content, DockState.DockRight, true);
                }
                else if (DropTarget.Dock == DockStyle.Fill)
                {
                    pane = dockPanel.DockPaneFactory.CreateDockPane(content, DockState.Document, true);
                }
                else
                {
                    return;
                }

                pane.Activate();
            }
            else if (IsDockStateValid(DockState.Float))
            {
                Point ptMouse = Control.MousePosition;

                Size  size = FloatWindow.DefaultWindowSize;
                Point location;
                if (content.DockState == DockState.Document)
                {
                    location = new Point(ptMouse.X + m_mouseOffset.X, ptMouse.Y + m_mouseOffset.Y);
                }
                else
                {
                    location = new Point(ptMouse.X + m_mouseOffset.X, ptMouse.Y + m_mouseOffset.Y - size.Height);
                }

                if (ptMouse.X > location.X + size.Width)
                {
                    location.X += ptMouse.X - (location.X + size.Width) + OutlineBorderWidth;
                }

                DockPane pane = content.DockPanel.DockPaneFactory.CreateDockPane(content, new Rectangle(location, size), true);
                pane.Activate();
            }
        }
        private void Pane_OnEndDrag(bool abort)
        {
            User32.SetCursor(DragControl.Cursor.Handle);

            if (abort)
            {
                return;
            }

            DockPane pane = (DockPane)DragControl;

            if (DropTarget.DropTo is DockPane)
            {
                DockPane paneTo = DropTarget.DropTo as DockPane;

                if (DropTarget.Dock == DockStyle.Fill)
                {
                    for (int i = pane.Contents.Count - 1; i >= 0; i--)
                    {
                        DockContent c = pane.Contents[i];
                        c.Pane = paneTo;
                        if (DropTarget.ContentIndex != -1)
                        {
                            paneTo.SetContentIndex(c, DropTarget.ContentIndex);
                        }
                        c.Activate();
                    }
                }
                else
                {
                    if (DropTarget.Dock == DockStyle.Left)
                    {
                        pane.AddToDockList(paneTo.DockListContainer, paneTo, DockAlignment.Left, 0.5);
                    }
                    else if (DropTarget.Dock == DockStyle.Right)
                    {
                        pane.AddToDockList(paneTo.DockListContainer, paneTo, DockAlignment.Right, 0.5);
                    }
                    else if (DropTarget.Dock == DockStyle.Top)
                    {
                        pane.AddToDockList(paneTo.DockListContainer, paneTo, DockAlignment.Top, 0.5);
                    }
                    else if (DropTarget.Dock == DockStyle.Bottom)
                    {
                        pane.AddToDockList(paneTo.DockListContainer, paneTo, DockAlignment.Bottom, 0.5);
                    }

                    pane.DockState = paneTo.DockState;
                    pane.Activate();
                }
            }
            else if (DropTarget.DropTo is DockPanel)
            {
                if (DropTarget.Dock == DockStyle.Top)
                {
                    pane.DockState = DockState.DockTop;
                }
                else if (DropTarget.Dock == DockStyle.Bottom)
                {
                    pane.DockState = DockState.DockBottom;
                }
                else if (DropTarget.Dock == DockStyle.Left)
                {
                    pane.DockState = DockState.DockLeft;
                }
                else if (DropTarget.Dock == DockStyle.Right)
                {
                    pane.DockState = DockState.DockRight;
                }
                else if (DropTarget.Dock == DockStyle.Fill)
                {
                    pane.DockState = DockState.Document;
                }

                pane.Activate();
            }
            else if (IsDockStateValid(DockState.Float))
            {
                Point ptMouse = Control.MousePosition;

                Point location = new Point(ptMouse.X + m_mouseOffset.X, ptMouse.Y + m_mouseOffset.Y);
                Size  size;
                bool  createFloatWindow = true;
                if (pane.FloatWindow == null)
                {
                    size = FloatWindow.DefaultWindowSize;
                }
                else if (pane.FloatWindow.DockList.Count == 1)
                {
                    size = pane.FloatWindow.Size;
                    createFloatWindow = false;
                }
                else
                {
                    size = FloatWindow.DefaultWindowSize;
                }

                if (ptMouse.X > location.X + size.Width)
                {
                    location.X += ptMouse.X - (location.X + size.Width) + OutlineBorderWidth;
                }

                if (createFloatWindow)
                {
                    pane.FloatWindow = pane.DockPanel.FloatWindowFactory.CreateFloatWindow(pane.DockPanel, pane, new Rectangle(location, size));
                }
                else
                {
                    pane.FloatWindow.Bounds = new Rectangle(location, size);
                }

                pane.DockState = DockState.Float;
                pane.Activate();
            }
        }
        private void FloatWindow_OnEndDrag(bool abort)
        {
            if (abort)
            {
                return;
            }

            FloatWindow floatWindow = (FloatWindow)DragControl;

            if (DropTarget.DropTo == null)
            {
                Rectangle rect = DragControl.Bounds;
                rect.X             = Control.MousePosition.X + m_mouseOffset.X;
                rect.Y             = Control.MousePosition.Y + m_mouseOffset.Y;
                DragControl.Bounds = rect;
            }
            else if (DropTarget.DropTo is DockPane)
            {
                DockPane paneTo = DropTarget.DropTo as DockPane;

                if (DropTarget.Dock == DockStyle.Fill)
                {
                    for (int i = floatWindow.DockList.Count - 1; i >= 0; i--)
                    {
                        DockPane pane = floatWindow.DockList[i];
                        for (int j = pane.Contents.Count - 1; j >= 0; j--)
                        {
                            DockContent c = pane.Contents[j];
                            c.Pane = paneTo;
                            if (DropTarget.ContentIndex != -1)
                            {
                                paneTo.SetContentIndex(c, DropTarget.ContentIndex);
                            }
                            c.Activate();
                        }
                    }
                }
                else
                {
                    DockAlignment alignment = DockAlignment.Left;
                    if (DropTarget.Dock == DockStyle.Left)
                    {
                        alignment = DockAlignment.Left;
                    }
                    else if (DropTarget.Dock == DockStyle.Right)
                    {
                        alignment = DockAlignment.Right;
                    }
                    else if (DropTarget.Dock == DockStyle.Top)
                    {
                        alignment = DockAlignment.Top;
                    }
                    else if (DropTarget.Dock == DockStyle.Bottom)
                    {
                        alignment = DockAlignment.Bottom;
                    }

                    MergeDockList(floatWindow.DisplayingList, paneTo.DockListContainer.DockList, paneTo, alignment, 0.5);
                }
            }
            else if (DropTarget.DropTo is DockPanel)
            {
                DockList dockListTo = null;

                if (DropTarget.Dock == DockStyle.Top)
                {
                    dockListTo = floatWindow.DockPanel.DockWindows[DockState.DockTop].DockList;
                }
                else if (DropTarget.Dock == DockStyle.Bottom)
                {
                    dockListTo = floatWindow.DockPanel.DockWindows[DockState.DockBottom].DockList;
                }
                else if (DropTarget.Dock == DockStyle.Left)
                {
                    dockListTo = floatWindow.DockPanel.DockWindows[DockState.DockLeft].DockList;
                }
                else if (DropTarget.Dock == DockStyle.Right)
                {
                    dockListTo = floatWindow.DockPanel.DockWindows[DockState.DockRight].DockList;
                }
                else if (DropTarget.Dock == DockStyle.Fill)
                {
                    dockListTo = floatWindow.DockPanel.DockWindows[DockState.Document].DockList;
                }

                DockPane prevPane = null;
                for (int i = dockListTo.Count - 1; i >= 0; i--)
                {
                    if (dockListTo[i] != floatWindow.DisplayingList[0])
                    {
                        prevPane = dockListTo[i];
                    }
                }
                MergeDockList(floatWindow.DisplayingList, dockListTo, prevPane, DockAlignment.Left, 0.5);
            }
        }
Example #4
0
 /// <include file='CodeDoc\AutoHideTabCollection.xml' path='//CodeDoc/Class[@name="AutoHideTabCollection"]/Method[@name="IndexOf(DockContent)"]/*'/>>
 public int IndexOf(DockContent content)
 {
     return(DockPane.DisplayingContents.IndexOf(content));
 }
Example #5
0
 /// <include file='CodeDoc\AutoHideTabCollection.xml' path='//CodeDoc/Class[@name="AutoHideTabCollection"]/Method[@name="Contains(DockContent)"]/*'/>>
 public bool Contains(DockContent content)
 {
     return(IndexOf(content) != -1);
 }
Example #6
0
        private void DrawTab(Graphics g, AutoHideTabVS2003 tab)
        {
            Rectangle rectTab = GetTabRectangle(tab);

            if (rectTab.IsEmpty)
            {
                return;
            }

            DockState   dockState = tab.Content.DockState;
            DockContent content   = tab.Content;

            OnBeginDrawTab(tab);

            Brush brushTabBackGround = BrushTabBackground;
            Pen   penTabBorder       = PenTabBorder;
            Brush brushTabText       = BrushTabText;

            g.FillRectangle(brushTabBackGround, rectTab);

            g.DrawLine(penTabBorder, rectTab.Left, rectTab.Top, rectTab.Left, rectTab.Bottom);
            g.DrawLine(penTabBorder, rectTab.Right, rectTab.Top, rectTab.Right, rectTab.Bottom);
            if (dockState == DockState.DockTopAutoHide || dockState == DockState.DockRightAutoHide)
            {
                g.DrawLine(penTabBorder, rectTab.Left, rectTab.Bottom, rectTab.Right, rectTab.Bottom);
            }
            else
            {
                g.DrawLine(penTabBorder, rectTab.Left, rectTab.Top, rectTab.Right, rectTab.Top);
            }

            // Set no rotate for drawing icon and text
            Matrix matrixRotate = g.Transform;

            g.Transform = MatrixIdentity;

            // Draw the icon
            Rectangle rectImage = rectTab;

            rectImage.X += ImageGapLeft;
            rectImage.Y += ImageGapTop;
            int imageHeight = rectTab.Height - ImageGapTop - ImageGapBottom;
            int imageWidth  = ImageWidth;

            if (imageHeight > ImageHeight)
            {
                imageWidth = ImageWidth * (imageHeight / ImageHeight);
            }
            rectImage.Height = imageHeight;
            rectImage.Width  = imageWidth;
            rectImage        = GetTransformedRectangle(dockState, rectImage);
            g.DrawIcon(content.Icon, rectImage);

            // Draw the text
            if (content == content.Pane.ActiveContent)
            {
                Rectangle rectText = rectTab;
                rectText.X     += ImageGapLeft + imageWidth + ImageGapRight + TextGapLeft;
                rectText.Width -= ImageGapLeft + imageWidth + ImageGapRight + TextGapLeft;
                rectText        = GetTransformedRectangle(dockState, rectText);
                if (dockState == DockState.DockLeftAutoHide || dockState == DockState.DockRightAutoHide)
                {
                    g.DrawString(content.TabText, Font, brushTabText, rectText, StringFormatTabVertical);
                }
                else
                {
                    g.DrawString(content.TabText, Font, brushTabText, rectText, StringFormatTabHorizontal);
                }
            }

            // Set rotate back
            g.Transform = matrixRotate;

            OnEndDrawTab(tab);
        }
 /// <include file='CodeDoc\EventArgs.xml' path='//CodeDoc/Class[@name="DockContentEventArgs"]/Constructor[@name="(DockContent)"]/*'/>
 public DockContentEventArgs(DockContent content)
 {
     m_content = content;
 }