public override MDIWindow findWindowAtPosition(float mouseX, float mouseY)
        {
            MDIWindow retVal = null;

            retVal = findWindowPositionImpl(mouseX, mouseY, documentArea);
            if (retVal != null)
            {
                return(retVal);
            }
            retVal = findWindowPositionImpl(mouseX, mouseY, left);
            if (retVal != null)
            {
                return(retVal);
            }
            retVal = findWindowPositionImpl(mouseX, mouseY, right);
            if (retVal != null)
            {
                return(retVal);
            }
            retVal = findWindowPositionImpl(mouseX, mouseY, top);
            if (retVal != null)
            {
                return(retVal);
            }
            retVal = findWindowPositionImpl(mouseX, mouseY, bottom);
            if (retVal != null)
            {
                return(retVal);
            }
            return(null);
        }
        /// <summary>
        /// Helper method to add a child before or after a given element.
        /// </summary>
        /// <param name="child">The child window to add.</param>
        /// <param name="previous">The window to add child relative to.</param>
        /// <param name="after">True to add child after previous. False to add child before previous.</param>
        internal override void insertChild(MDIWindow child, MDIWindow previous, bool after)
        {
            int index = children.IndexOf(previous);

            if (index == -1)
            {
                throw new MDIException("Attempted to add a MDIWindow with a previous window that does not exist in this collection.");
            }
            setChildProperties(child);
            separatorWidgetManager.createSeparator();
            if (after)
            {
                //Increment index and make sure it isnt the end of the list
                if (++index == children.Count)
                {
                    children.Add(child);
                }
                else
                {
                    children.Insert(index, child);
                }
            }
            else
            {
                children.Insert(index, child);
            }
            totalScale += child.Scale;
        }
        public void removeChild(MDIWindow child)
        {
            switch (child.CurrentDockLocation)
            {
            case DockLocation.Left:
                left.removeChild(child);
                break;

            case DockLocation.Right:
                right.removeChild(child);
                break;

            case DockLocation.Top:
                top.removeChild(child);
                break;

            case DockLocation.Bottom:
                bottom.removeChild(child);
                break;

            case DockLocation.Center:
                documentArea.removeChild(child);
                break;

            case DockLocation.Floating:
                floating.removeChild(child);
                break;
            }
        }
        private bool processFloating(MDIWindow source, float mouseX, float mouseY)
        {
            if ((source.AllowedDockLocations & DockLocation.Left) != 0)
            {
                MDIWindow window = left.findWindowAtPosition(mouseX, mouseY);
                if (window != null)
                {
                    dragTargetContainer = null;
                    dragTargetWindow    = window;
                    findWindowLanding(source, dragTargetWindow, mouseX, mouseY);
                    return(true);
                }
            }

            if ((source.AllowedDockLocations & DockLocation.Right) != 0)
            {
                MDIWindow window = right.findWindowAtPosition(mouseX, mouseY);
                if (window != null)
                {
                    dragTargetContainer = null;
                    dragTargetWindow    = window;
                    findWindowLanding(source, dragTargetWindow, mouseX, mouseY);
                    return(true);
                }
            }

            if ((source.AllowedDockLocations & DockLocation.Top) != 0)
            {
                MDIWindow window = top.findWindowAtPosition(mouseX, mouseY);
                if (window != null)
                {
                    dragTargetContainer = null;
                    dragTargetWindow    = window;
                    findWindowLanding(source, dragTargetWindow, mouseX, mouseY);
                    return(true);
                }
            }

            if ((source.AllowedDockLocations & DockLocation.Bottom) != 0)
            {
                MDIWindow window = bottom.findWindowAtPosition(mouseX, mouseY);
                if (window != null)
                {
                    dragTargetContainer = null;
                    dragTargetWindow    = window;
                    findWindowLanding(source, dragTargetWindow, mouseX, mouseY);
                    return(true);
                }
            }

            if ((source.AllowedDockLocations & DockLocation.Floating) != 0)
            {
                windowTargetWidget.Visible = false;
                dragTargetContainer        = floating;
                dragTargetWindow           = null;
                return(true);
            }
            return(false);
        }
 /// <summary>
 /// Add a child in a simple way by just appending it to the end of the child list.
 /// </summary>
 /// <param name="child">The child to add.</param>
 public override void addChild(MDIWindow child)
 {
     setChildProperties(child);
     separatorWidgetManager.createSeparator();
     children.Add(child);
     totalScale += child.Scale;
     invalidate();
 }
Esempio n. 6
0
 /// <summary>
 /// Helper function to intialize windows that are added to the MDILayoutManager.
 /// </summary>
 /// <param name="window">The window to initialize.</param>
 private void setWindowProperties(MDIWindow window)
 {
     if (windows.Count == 0)
     {
         ActiveWindow = window;
     }
     window._setMDILayoutManager(this);
     windows.Add(window);
 }
Esempio n. 7
0
 public override void addChild(MDIWindow window)
 {
     window.SuppressLayout      = true;
     window.CurrentDockLocation = DockLocation.Floating;
     window._setParent(this);
     window._ParentContainer = this;
     window.SuppressLayout   = false;
     windows.Add(window);
 }
Esempio n. 8
0
 /// <summary>
 /// Show a window relative to another window.
 /// </summary>
 /// <param name="window">The window to show.</param>
 /// <param name="previous">The window to show window relative to.</param>
 /// <param name="alignment">The alignemnt of window to previous.</param>
 public void showWindow(MDIWindow window, MDIWindow previous, WindowAlignment alignment)
 {
     if (previous == null)
     {
         throw new MDIException("Previous window cannot be null.");
     }
     setWindowProperties(window);
     previous._ParentContainer.addChild(window, previous, alignment);
     invalidate();
 }
Esempio n. 9
0
        public override void removeChild(MDIWindow window)
        {
            int index = windows.IndexOf(window);

            if (index != -1)
            {
                windows.RemoveAt(index);
                window._setParent(null);
                window._ParentContainer = null;
            }
        }
 private bool processCenter(MDIWindow source, float mouseX, float mouseY)
 {
     dragTargetContainer = null;
     if ((source.AllowedDockLocations & DockLocation.Center) == 0)
     {
         dragTargetWindow = null;
         return(false);
     }
     dragTargetWindow = documentArea.findWindowAtPosition(mouseX, mouseY);
     findWindowLanding(source, dragTargetWindow, mouseX, mouseY);
     return(true);
 }
        //All dialogs on a given level have the same alignment and can have the dialog found before it as the parent with "right" or "bottom" alignment
        //A dialog on a child level will have the opposite alignment of its parent (that is why it is a child)

        //so you need a function store level details, which takes the alignment to the parent and the parent dialog
        //assign the first dialog to have the parent and parent alignment, any other dialogs on that level parent to the previous found dialog and have right or bottom alignment
        private void storeLayoutInfo(StoredMDILayoutContainer storedLayout, MDIWindow parent, WindowAlignment alignmentToParent)
        {
            bool foundWindow = false;
            int  i           = 0;

            for (i = 0; i < children.Count; ++i)
            {
                //Search level for the first dialog, store all elements up till the dialog
                //if a dialog is found
                MDIWindow currentWindow = children[i] as MDIWindow;
                if (currentWindow != null)
                {
                    foundWindow = true;
                    //parent the dialog to the parent passed to the function with the alignment passed in
                    //add child level elements to the "left" or "top" from the list of stored dialogs (calling the recursive func)
                    storedLayout.addWindowEntry(new WindowEntry(currentWindow, alignmentToParent, parent));
                    foundWindow = true;
                    for (int j = 0; j < i; ++j)
                    {
                        MDILayoutContainer childLayout = (MDILayoutContainer)children[j];
                        childLayout.storeLayoutInfo(storedLayout, currentWindow, layoutType == LayoutType.Horizontal ? WindowAlignment.Left : WindowAlignment.Top);
                    }
                    //add remaining child elements to the "right" or "bottom" of the current window
                    //if another window is found, change currentwindow
                    //parent the newly found window to the currentwindow with "left" or "bottom" alignment
                    MDIWindow previousWindow = currentWindow;
                    for (++i; i < children.Count; ++i)
                    {
                        currentWindow = children[i] as MDIWindow;
                        if (currentWindow != null)
                        {
                            storedLayout.addWindowEntry(new WindowEntry(currentWindow, layoutType == LayoutType.Horizontal ? WindowAlignment.Right : WindowAlignment.Bottom, previousWindow));
                            previousWindow = currentWindow;
                        }
                        else
                        {
                            MDILayoutContainer childLayout = (MDILayoutContainer)children[i];
                            childLayout.storeLayoutInfo(storedLayout, previousWindow, layoutType == LayoutType.Horizontal ? WindowAlignment.Right : WindowAlignment.Bottom);
                        }
                    }
                }
            }
            if (!foundWindow)
            {
                //if no dialog is found it means we are at the top level and the default order was changed, no other levels should be able to be completely empty, in this case flip
                //the alignment and call again with no parent dialog (this will cause the first found dialog to be the parent and its sibling will get the correct flipped alignment
                foreach (MDILayoutContainer child in children)
                {
                    child.storeLayoutInfo(storedLayout, parent, child.layoutType == LayoutType.Horizontal ? WindowAlignment.Left : WindowAlignment.Top);
                }
            }
        }
Esempio n. 12
0
 /// <summary>
 /// Show this window relative to another window, will only do something if this window
 /// is not visible.
 /// </summary>
 /// <param name="previous">The previous window.</param>
 /// <param name="alignment">The alignment relative to the previous window.</param>
 public void showRelativeTo(MDIWindow previous, WindowAlignment alignment)
 {
     if (!window.Visible)
     {
         ensureVisible();
         doChangeVisibility(true);
         onShown(EventArgs.Empty);
         if (MDIManager != null)
         {
             MDIManager.showWindow(this, previous, alignment);
         }
     }
 }
Esempio n. 13
0
 protected internal override void restoreToMDILayout(MDIWindow mdiWindow, WindowAlignment windowAlignment)
 {
     if (!window.Visible)
     {
         ensureVisible();
         doChangeVisibility(true);
         onShown(EventArgs.Empty);
         if (MDIManager != null)
         {
             MDIManager.showWindow(this, mdiWindow, windowAlignment);
         }
     }
 }
 /// <summary>
 /// This function removes a MDIWindow from this container. It will clean
 /// up any nested containers as required.
 /// </summary>
 /// <param name="child">The child window to remove.</param>
 public override void removeChild(MDIWindow child)
 {
     if (children.Contains(child))
     {
         separatorWidgetManager.removeSeparator();
         children.Remove(child);
         totalScale -= child.Scale;
         if (_ParentContainer != null && children.Count == 1)
         {
             //Promote the child, which will destroy this container in the process as it is no longer needed.
             _ParentContainer.promoteChild(children[0], this);
         }
         else
         {
             invalidate();
         }
     }
 }
        private void findWindowLanding(MDIWindow source, MDIWindow target, float mouseX, float mouseY)
        {
            if (target != null)
            {
                if (source != target)
                {
                    float top    = target.Location.y;
                    float bottom = top + target.WorkingSize.Height;
                    float left   = target.Location.x;
                    float right  = left + target.WorkingSize.Width;

                    float topDelta    = mouseY - top;
                    float bottomDelta = bottom - mouseY;
                    float leftDelta   = mouseX - left;
                    float rightDelta  = right - mouseX;
                    if (topDelta < bottomDelta && topDelta < leftDelta && topDelta < rightDelta)
                    {
                        finalWindowAlignment = WindowAlignment.Top;
                        windowTargetWidget.setCoord((int)left, (int)top, (int)target.WorkingSize.Width, (int)(target.WorkingSize.Height * 0.5f));
                    }
                    else if (bottomDelta < topDelta && bottomDelta < leftDelta && bottomDelta < rightDelta)
                    {
                        finalWindowAlignment = WindowAlignment.Bottom;
                        windowTargetWidget.setCoord((int)left, (int)(top + target.WorkingSize.Height * 0.5f), (int)target.WorkingSize.Width, (int)(target.WorkingSize.Height * 0.5f));
                    }
                    else if (leftDelta < topDelta && leftDelta < bottomDelta && leftDelta < rightDelta)
                    {
                        finalWindowAlignment = WindowAlignment.Left;
                        windowTargetWidget.setCoord((int)left, (int)top, (int)(target.WorkingSize.Width * 0.5f), (int)target.WorkingSize.Height);
                    }
                    else if (rightDelta < leftDelta && rightDelta < bottomDelta && rightDelta < topDelta)
                    {
                        finalWindowAlignment = WindowAlignment.Right;
                        windowTargetWidget.setCoord((int)(left + target.WorkingSize.Width * 0.5f), (int)top, (int)(target.WorkingSize.Width * 0.5f), (int)target.WorkingSize.Height);
                    }

                    windowTargetWidget.Visible = true;
                }
                else
                {
                    windowTargetWidget.Visible = false;
                }
            }
        }
        public void windowDragEnded(MDIWindow source, float mouseX, float mouseY)
        {
            windowTargetWidget.Visible    = false;
            leftContainerWidget.Visible   = false;
            rightContainerWidget.Visible  = false;
            topContainerWidget.Visible    = false;
            bottomContainerWidget.Visible = false;

            if (dragTargetContainer != null)
            {
                dragSourceWindow._ParentContainer.removeChild(dragSourceWindow);
                dragTargetContainer.addChild(dragSourceWindow);
                this.layout();
            }
            else if (dragTargetWindow != dragSourceWindow && dragTargetWindow != null)
            {
                dragSourceWindow._ParentContainer.removeChild(dragSourceWindow);
                dragTargetWindow._ParentContainer.addChild(dragSourceWindow, dragTargetWindow, finalWindowAlignment);
                this.layout();
            }
        }
        private bool checkContainerWidget(Widget widget, MDIChildContainerBase targetContainer, MDIWindow window, DockLocation dockLocation, float x, float y)
        {
            if (widget.Visible)
            {
                float left   = widget.AbsoluteLeft;
                float top    = widget.AbsoluteTop;
                float right  = left + widget.Width;
                float bottom = top + widget.Height;
                if (x > left && x < right && y > top && y < bottom)
                {
                    dragTargetContainer = targetContainer;
                    dragTargetWindow    = null;

                    windowTargetWidget.Visible = true;
                    switch (dockLocation)
                    {
                    case DockLocation.Left:
                        windowTargetWidget.setCoord((int)Location.x, (int)Location.y, (int)window.DesiredSize.Width, (int)WorkingSize.Height);
                        break;

                    case DockLocation.Right:
                        float width = window.DesiredSize.Width;
                        windowTargetWidget.setCoord((int)(WorkingSize.Width - width + Location.x), (int)Location.y, (int)width, (int)WorkingSize.Height);
                        break;

                    case DockLocation.Top:
                        windowTargetWidget.setCoord((int)Location.x, (int)Location.y, (int)WorkingSize.Width, (int)window.DesiredSize.Height);
                        break;

                    case DockLocation.Bottom:
                        float height = window.DesiredSize.Height;
                        windowTargetWidget.setCoord((int)Location.x, (int)(WorkingSize.Height - height + Location.y), (int)WorkingSize.Width, (int)height);
                        break;
                    }

                    return(true);
                }
            }
            return(false);
        }
        public void windowDragStarted(MDIWindow source, float mouseX, float mouseY)
        {
            dragSourceWindow    = source;
            dragTargetWindow    = null;
            dragTargetContainer = null;

            if ((source.AllowedDockLocations & DockLocation.Left) != 0)
            {
                int x = (int)(left.DesiredSize.Width / 2 + Location.x);
                int y = (int)WorkingSize.Height / 2;
                leftContainerWidget.setPosition(x, y);
                leftContainerWidget.Visible = true;
            }

            if ((source.AllowedDockLocations & DockLocation.Right) != 0)
            {
                int x = (int)(right.DesiredSize.Width / 2 + right.Location.x - rightContainerWidget.Width);
                int y = (int)WorkingSize.Height / 2;
                rightContainerWidget.setPosition(x, y);
                rightContainerWidget.Visible = true;
            }

            if ((source.AllowedDockLocations & DockLocation.Top) != 0)
            {
                int x = (int)WorkingSize.Width / 2;
                int y = (int)(top.DesiredSize.Height / 2 + Location.y);
                topContainerWidget.setPosition(x, y);
                topContainerWidget.Visible = true;
            }

            if ((source.AllowedDockLocations & DockLocation.Bottom) != 0)
            {
                int x = (int)WorkingSize.Width / 2;
                int y = (int)(bottom.DesiredSize.Width / 2 + bottom.Location.y - bottomContainerWidget.Width);
                bottomContainerWidget.setPosition(x, y);
                bottomContainerWidget.Visible = true;
            }
        }
        public void windowDragged(MDIWindow source, float mouseX, float mouseY)
        {
            //If we are currently docked and are allowed to float, start floating immediatly on movement.
            if (((source.AllowedDockLocations & DockLocation.Floating) != 0) &&
                (source.CurrentDockLocation == DockLocation.Left ||
                 source.CurrentDockLocation == DockLocation.Right ||
                 source.CurrentDockLocation == DockLocation.Top ||
                 source.CurrentDockLocation == DockLocation.Bottom))
            {
                source._ParentContainer.removeChild(source);
                floating.addChild(source);
                this.layout();
            }

            if (checkContainerWidget(leftContainerWidget, left, source, DockLocation.Left, mouseX, mouseY) ||
                checkContainerWidget(rightContainerWidget, right, source, DockLocation.Right, mouseX, mouseY) ||
                checkContainerWidget(topContainerWidget, top, source, DockLocation.Top, mouseX, mouseY) ||
                checkContainerWidget(bottomContainerWidget, bottom, source, DockLocation.Bottom, mouseX, mouseY) ||
                processFloating(source, mouseX, mouseY) ||
                processCenter(source, mouseX, mouseY))
            {
            }
        }
Esempio n. 20
0
 /// <summary>
 /// Close a window.
 /// </summary>
 /// <param name="window"></param>
 public void closeWindow(MDIWindow window)
 {
     //if (!windows.Contains(window))
     //{
     //    throw new MDIException("Attempted to close a window that is not part of this MDILayoutManager.");
     //}
     if (windows.Contains(window))
     {
         windows.Remove(window);
         //Check to see if this window was the active window.
         if (window == ActiveWindow)
         {
             if (windows.Count > 0)
             {
                 ActiveWindow = windows[0];
             }
             else
             {
                 ActiveWindow = null;
             }
         }
         window._ParentContainer.removeChild(window);
     }
 }
Esempio n. 21
0
 public override void removeChild(MDIWindow window)
 {
     layoutContainer.removeChild(window);
 }
Esempio n. 22
0
 /// <summary>
 /// Show a window where the location does not matter.
 /// </summary>
 /// <param name="window">The window to add.</param>
 public void showWindow(MDIWindow window)
 {
     setWindowProperties(window);
     rootContainer.addChild(window);
     invalidate();
 }
Esempio n. 23
0
 public override void addChild(MDIWindow window, MDIWindow previous, WindowAlignment alignment)
 {
     layoutContainer.addChild(window, previous, alignment);
 }
Esempio n. 24
0
 internal override void insertChild(MDIWindow child, MDIWindow previous, bool after)
 {
     throw new NotSupportedException();
 }
Esempio n. 25
0
 void activeWindow_MouseDragFinished(MDIWindow source, float mouseX, float mouseY)
 {
     rootContainer.windowDragEnded(source, mouseX, mouseY);
 }
Esempio n. 26
0
 void activeWindow_MouseDragStarted(MDIWindow source, float mouseX, float mouseY)
 {
     rootContainer.windowDragStarted(source, mouseX, mouseY);
 }
Esempio n. 27
0
 protected internal abstract void restoreToMDILayout(MDIWindow mDIWindow, WindowAlignment windowAlignment);
Esempio n. 28
0
 public override void addChild(MDIWindow window, MDIWindow previous, WindowAlignment alignment)
 {
     addChild(window);
 }
 public void addFloatingWindow(MDIWindow floatingWindow)
 {
     floatingWindows.Add(floatingWindow);
 }
Esempio n. 30
0
 internal override void insertChild(MDIWindow child, MDIWindow previous, bool after)
 {
     layoutContainer.insertChild(child, previous, after);
 }