Пример #1
0
 void DragDropController_MouseMove(object sender, MouseEventArgs e)
 {
     if (dragState == DragState.Drag)
     {
         FlowLayoutEvents.OnPanelDrag(e.Location);
     }
 }
Пример #2
0
        void CustomOnResize(object sender, EventArgs e)
        {
            if (WindowState != LastWindowState)
            {
                LastWindowState = WindowState;
                FlowLayoutEvents.OnMainPanelLayoutChanged();
            }

            LocateComponents();
        }
Пример #3
0
        /// <summary>
        /// Resizes all panels on the form using the layout lines
        /// All panels are displayed at the maximum size possible
        /// </summary>
        void ResizeUsingLayoutLines()
        {
            Dictionary <Locations, int>  indicesOfLinesAroundPanel;
            Dictionary <Locations, bool> canSizeInDirection;

            foreach (IDockableControl controlToSize in dockableControlsInPanel)
            {
                indicesOfLinesAroundPanel = new Dictionary <Locations, int>();
                canSizeInDirection        = new Dictionary <Locations, bool>();
                int newPositionOfEdge;

                Control copyOfControl = (Control)controlToSize;
                if (controlToSize.AutoSizeType != AutosizeTypes.Constant)
                {
                    //Check around the panel
                    foreach (var direction in (Locations[])Enum.GetValues(typeof(Locations)))
                    {
                        indicesOfLinesAroundPanel[direction] = myLayoutLines.GetLineIndex(myLayoutLines.AddLineFromSideOfPanel(copyOfControl, direction), InvertLocation(direction));

                        //The panel can size if a layout line exists that matches the side of the panel,
                        //and the autosize type allows the panel to be resized
                        canSizeInDirection[direction] = ((indicesOfLinesAroundPanel[direction] != -1) &&
                                                         AutosizeTypeAllowsResize(direction, controlToSize));
                    }
                    //Size the panel in each direction
                    foreach (var direction in (Locations[])Enum.GetValues(typeof(Locations)))
                    {
                        if (canSizeInDirection[direction])
                        {
                            //Gets the furthest position to which a panel can be resized.
                            newPositionOfEdge = myLayoutLines.GetSizeChangeAllowed(copyOfControl, direction);

                            switch (direction)
                            {
                            case Locations.Top:
                            {
                                //Resize the panel by the required amount
                                //The height is increased by the difference between the possible position
                                //and the current position of the edge
                                copyOfControl.Height += copyOfControl.Top - newPositionOfEdge;
                                //The location of the top of the control is reduced by the same amount
                                copyOfControl.Top -= copyOfControl.Top - newPositionOfEdge;

                                //Move the relevant layout line to the new position
                                if (indicesOfLinesAroundPanel[Locations.Top] != -1)
                                {
                                    myLayoutLines.LinesForLayout[Locations.Bottom][(indicesOfLinesAroundPanel[Locations.Top])].StaticLocation = newPositionOfEdge;
                                }
                                //Update the length of the lines to the sides of the panel.
                                if (indicesOfLinesAroundPanel[Locations.Right] != -1)
                                {
                                    //Set the start point of the line to the side to the new position
                                    myLayoutLines.LinesForLayout[Locations.Left][(indicesOfLinesAroundPanel[Locations.Right])].setStartPointY(newPositionOfEdge);
                                    //Set the end point of the line to the side to the new position,
                                    //maintining the link between the start point of one line and the end point of the previous line.
                                    if (indicesOfLinesAroundPanel[Locations.Right] > 0)
                                    {
                                        myLayoutLines.LinesForLayout[Locations.Left][(indicesOfLinesAroundPanel[Locations.Right]) - 1].setEndPointY(newPositionOfEdge);
                                    }
                                }
                                if (indicesOfLinesAroundPanel[Locations.Left] != -1)
                                {
                                    myLayoutLines.LinesForLayout[Locations.Right][(indicesOfLinesAroundPanel[Locations.Left])].setStartPointY(newPositionOfEdge);
                                    if (indicesOfLinesAroundPanel[Locations.Left] > 0)
                                    {
                                        myLayoutLines.LinesForLayout[Locations.Right][(indicesOfLinesAroundPanel[Locations.Left]) - 1].setEndPointY(newPositionOfEdge);
                                    }
                                }

                                break;
                            }

                            case Locations.Left:     //See comments in above sections
                            {
                                copyOfControl.Width += copyOfControl.Left - newPositionOfEdge;
                                copyOfControl.Left  -= copyOfControl.Left - newPositionOfEdge;

                                if (indicesOfLinesAroundPanel[Locations.Left] != -1)
                                {
                                    myLayoutLines.LinesForLayout[Locations.Right][(indicesOfLinesAroundPanel[Locations.Left])].StaticLocation = newPositionOfEdge;
                                }
                                if (indicesOfLinesAroundPanel[Locations.Bottom] != -1)
                                {
                                    myLayoutLines.LinesForLayout[Locations.Top][(indicesOfLinesAroundPanel[Locations.Bottom])].setStartPointX(newPositionOfEdge);
                                    if (indicesOfLinesAroundPanel[Locations.Bottom] > 0)
                                    {
                                        myLayoutLines.LinesForLayout[Locations.Top][(indicesOfLinesAroundPanel[Locations.Bottom]) - 1].setEndPointX(newPositionOfEdge);
                                    }
                                }
                                if (indicesOfLinesAroundPanel[Locations.Top] != -1)
                                {
                                    myLayoutLines.LinesForLayout[Locations.Bottom][(indicesOfLinesAroundPanel[Locations.Top])].setStartPointX(newPositionOfEdge);
                                    if (indicesOfLinesAroundPanel[Locations.Top] > 0)
                                    {
                                        myLayoutLines.LinesForLayout[Locations.Bottom][(indicesOfLinesAroundPanel[Locations.Top]) - 1].setEndPointX(newPositionOfEdge);
                                    }
                                }

                                break;
                            }

                            case Locations.Bottom:     //See comments in above sections
                            {
                                copyOfControl.Height += newPositionOfEdge - copyOfControl.Bottom;

                                if (indicesOfLinesAroundPanel[Locations.Bottom] != -1)
                                {
                                    myLayoutLines.LinesForLayout[Locations.Top][(indicesOfLinesAroundPanel[Locations.Bottom])].StaticLocation = newPositionOfEdge;
                                }
                                if (indicesOfLinesAroundPanel[Locations.Left] != -1)
                                {
                                    myLayoutLines.LinesForLayout[Locations.Right][(indicesOfLinesAroundPanel[Locations.Left])].setEndPointY(newPositionOfEdge);
                                    if (indicesOfLinesAroundPanel[Locations.Left] < myLayoutLines.LinesForLayout[Locations.Right].Count - 1)
                                    {
                                        myLayoutLines.LinesForLayout[Locations.Right][(indicesOfLinesAroundPanel[Locations.Left]) + 1].setStartPointY(newPositionOfEdge);
                                    }
                                }
                                if (indicesOfLinesAroundPanel[Locations.Right] != -1)
                                {
                                    myLayoutLines.LinesForLayout[Locations.Left][(indicesOfLinesAroundPanel[Locations.Right])].setEndPointY(newPositionOfEdge);
                                    if (indicesOfLinesAroundPanel[Locations.Right] < myLayoutLines.LinesForLayout[Locations.Left].Count - 1)
                                    {
                                        myLayoutLines.LinesForLayout[Locations.Left][(indicesOfLinesAroundPanel[Locations.Right]) + 1].setStartPointY(newPositionOfEdge);
                                    }
                                }

                                break;
                            }

                            case Locations.Right:     //See comments in above sections
                            {
                                copyOfControl.Width += newPositionOfEdge - copyOfControl.Right;

                                if (indicesOfLinesAroundPanel[Locations.Right] != -1)
                                {
                                    myLayoutLines.LinesForLayout[Locations.Left][(indicesOfLinesAroundPanel[Locations.Right])].StaticLocation = newPositionOfEdge;
                                }
                                if (indicesOfLinesAroundPanel[Locations.Top] != -1)
                                {
                                    myLayoutLines.LinesForLayout[Locations.Bottom][(indicesOfLinesAroundPanel[Locations.Top])].setEndPointX(newPositionOfEdge);
                                    if (indicesOfLinesAroundPanel[Locations.Top] < myLayoutLines.LinesForLayout[Locations.Bottom].Count - 1)
                                    {
                                        myLayoutLines.LinesForLayout[Locations.Bottom][(indicesOfLinesAroundPanel[Locations.Top]) + 1].setStartPointX(newPositionOfEdge);
                                    }
                                }
                                if (indicesOfLinesAroundPanel[Locations.Bottom] != -1)
                                {
                                    myLayoutLines.LinesForLayout[Locations.Top][(indicesOfLinesAroundPanel[Locations.Bottom])].setEndPointX(newPositionOfEdge);
                                    if (indicesOfLinesAroundPanel[Locations.Bottom] < myLayoutLines.LinesForLayout[Locations.Top].Count - 1)
                                    {
                                        myLayoutLines.LinesForLayout[Locations.Top][(indicesOfLinesAroundPanel[Locations.Bottom]) + 1].setStartPointX(newPositionOfEdge);
                                    }
                                }

                                break;
                            }
                            }
                        }
                    }
                }
            }

            FlowLayoutEvents.OnMainPanelResize();
        }
Пример #4
0
 void CustomEndResize(object sender, EventArgs e)
 {
     FlowLayoutEvents.OnMainPanelLayoutChanged();
 }