Esempio n. 1
0
 /// <summary>
 /// Removes a panel from the content tab control, triggers the PanelClosed event and re-draws the control.
 /// </summary>
 /// <param name="PanelToRemove">The panel to be removed from the tab control</param>
 public void RemovePanelFromControl(MyPanel PanelToRemove)
 {
     if (PanelToRemove.InContentPanel)
     {
         PanelsToDisplay.Remove(PanelToRemove);
         PanelToRemove.InContentPanel = false;
         DisplayControls();
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Adds a panel to the tab control and re-draws the control.
        /// </summary>
        /// <param name="PanelToAdd">The panel to be added to the control.</param>
        public void AddPanelToTabControl(MyPanel PanelToAdd)
        {
            if (!PanelToAdd.InContentPanel)
            {
                PanelsToDisplay.Add(PanelToAdd);
                PanelToAdd.RemoveToolbarButtons();
                PanelToAdd.PanelIndex     = PanelsToDisplay.Count - 1;
                PanelToAdd.InContentPanel = true;

                //Add tool strip button to close the panel.
                MyToolStripButton ButtonToAdd;
                ButtonToAdd                = new MyToolStripButton(PanelsToDisplay.Count - 1);
                ButtonToAdd.Text           = PanelToAdd.Name;
                ButtonToAdd.ButtonClicked += tempButton_CustomCheckedChanged;
                closePanels.DropDownItems.Add(ButtonToAdd);

                DisplayControls();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Updates the rectangle of remaining area on the panel after a control is added
        /// </summary>
        /// <param name="addedControl">The control that was added</param>
        void UpdateRemainingSize(IDockableControl addedControl)
        {
            Control controlCopy = (Control)addedControl;

            if (addedControl.FillStyle == FillStyles.FullHeight)
            {
                remainingSize.Width -= controlCopy.Width;
                if (MyPanel.IsDockedAtLeft(addedControl.DockType))
                {
                    remainingSize.Location = new Point(remainingSize.Left + controlCopy.Width, remainingSize.Top);
                }
            }
            if (addedControl.FillStyle == FillStyles.FullWidth)
            {
                remainingSize.Height -= controlCopy.Height;
                if (MyPanel.IsDockedAtLeft(addedControl.DockType))
                {
                    remainingSize.Location = new Point(remainingSize.Left, remainingSize.Top + controlCopy.Height);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Starts the dynamic drag-drop process on the form by displaying the drag-drop interface.
        /// Events are subscribed to so that when the panel is clicked again the panel is dropped.
        /// </summary>
        /// <param name="panelBeingDragged">The panel that has been selected</param>
        /// <param name="visibleControls">A list of all visible panels on the form</param>
        /// <param name="startLocation">The initial click location</param>
        /// <param name="dockPoints">A dictionary of the available points the panel can be docked to on the form</param>
        public void StartDragDropLayout(MyPanel panelBeingDragged, List <MyPanel> visibleControls, Point startLocation, Dictionary <DockTypes, Point> dockPoints)
        {
            this.visiblePanels       = visibleControls;
            this.panelBeingRelocated = panelBeingDragged;
            this.startLocation       = startLocation;
            this.dockPoints          = dockPoints;

            MouseMove += DragDropController_MouseMove;
            MouseUp   += DragDropController_MouseUp;
            FlowLayoutEvents.PanelDrag += MyEvents_PanelDrag;

            Program.AddEventToForms(DropPanelOnCurrentForm);

            rectanglesToDraw.Clear();

            dragState = DragState.Drag;

            StartLayout();

            parentForm.IOController.ShowDynamicLayoutPanel(this);
        }
Esempio n. 5
0
        void UpdatePoints(IDockableControl controlBeingAdded)
        {
            Control controlCopy = (Control)controlBeingAdded;

            //Depending on how the control fills the screen,
            //update the location of the dock points
            switch (controlBeingAdded.FillStyle)
            {
            case FillStyles.FullWidth:
            {
                //Change the locatoin of the dock points that are affected by the control
                if (MyPanel.IsDockedAtTop(controlBeingAdded.DockType))
                {
                    dockPointLocations[DockTypes.TopLeft]  = AddHeightToDockPoint(DockTypes.TopLeft, controlCopy.Height);
                    dockPointLocations[DockTypes.Left]     = AddHeightToDockPoint(DockTypes.Left, controlCopy.Height);
                    dockPointLocations[DockTypes.Top]      = AddHeightToDockPoint(DockTypes.Top, controlCopy.Height);
                    dockPointLocations[DockTypes.None]     = AddHeightToDockPoint(DockTypes.None, controlCopy.Height);
                    dockPointLocations[DockTypes.TopRight] = AddHeightToDockPoint(DockTypes.TopRight, controlCopy.Height);
                    dockPointLocations[DockTypes.Right]    = AddHeightToDockPoint(DockTypes.Right, controlCopy.Height);
                    dockPointLocations[DockTypes.Top2]     = AddHeightToDockPoint(DockTypes.Top2, controlCopy.Height);
                }
                else
                {
                    dockPointLocations[DockTypes.BottomLeft]  = AddHeightToDockPoint(DockTypes.BottomLeft, -controlCopy.Height);
                    dockPointLocations[DockTypes.Bottom]      = AddHeightToDockPoint(DockTypes.Bottom, -controlCopy.Height);
                    dockPointLocations[DockTypes.BottomRight] = AddHeightToDockPoint(DockTypes.BottomRight, -controlCopy.Height);
                    dockPointLocations[DockTypes.Bottom2]     = AddHeightToDockPoint(DockTypes.Bottom2, -controlCopy.Height);
                }
                break;
            }

            case FillStyles.FullHeight:
            {
                if (MyPanel.IsDockedAtLeft(controlBeingAdded.DockType))
                {
                    dockPointLocations[DockTypes.TopLeft]    = AddWidthToDockPoint(DockTypes.TopLeft, controlCopy.Width);
                    dockPointLocations[DockTypes.Left]       = AddWidthToDockPoint(DockTypes.Left, controlCopy.Width);
                    dockPointLocations[DockTypes.BottomLeft] = AddWidthToDockPoint(DockTypes.BottomLeft, controlCopy.Width);
                    dockPointLocations[DockTypes.Top]        = AddWidthToDockPoint(DockTypes.Top, controlCopy.Width);
                    dockPointLocations[DockTypes.None]       = AddWidthToDockPoint(DockTypes.None, controlCopy.Width);
                    dockPointLocations[DockTypes.Bottom]     = AddWidthToDockPoint(DockTypes.Bottom, controlCopy.Width);
                }
                else
                {
                    dockPointLocations[DockTypes.TopRight]    = AddWidthToDockPoint(DockTypes.TopRight, -controlCopy.Width);
                    dockPointLocations[DockTypes.Right]       = AddWidthToDockPoint(DockTypes.Right, -controlCopy.Width);
                    dockPointLocations[DockTypes.BottomRight] = AddWidthToDockPoint(DockTypes.BottomRight, -controlCopy.Width);
                    dockPointLocations[DockTypes.Top2]        = AddWidthToDockPoint(DockTypes.Top2, -controlCopy.Width);
                    dockPointLocations[DockTypes.Bottom2]     = AddWidthToDockPoint(DockTypes.Bottom2, -controlCopy.Width);
                }
                break;
            }

            case FillStyles.None:
            {
                //If the panel being added will affect the dock point:
                if ((controlBeingAdded.DockPointLocation == dockPointLocations[DockTypes.TopLeft]) || (controlBeingAdded.DockPointLocation == dockPointLocations[DockTypes.Left]) || (controlBeingAdded.DockPointLocation == dockPointLocations[DockTypes.None]))
                {
                    dockPointLocations[DockTypes.TopLeft] = AddHeightToDockPoint(DockTypes.TopLeft, controlCopy.Height);
                    dockPointLocations[DockTypes.Left]    = AddHeightToDockPoint(DockTypes.Left, controlCopy.Height);
                    dockPointLocations[DockTypes.None]    = AddHeightToDockPoint(DockTypes.None, controlCopy.Height);
                }
                if (controlBeingAdded.DockPointLocation == dockPointLocations[DockTypes.BottomLeft])
                {
                    dockPointLocations[DockTypes.BottomLeft] = AddHeightToDockPoint(DockTypes.BottomLeft, -controlCopy.Height);
                }
                if (controlBeingAdded.DockPointLocation == dockPointLocations[DockTypes.Top])
                {
                    dockPointLocations[DockTypes.Top] = AddWidthToDockPoint(DockTypes.Top, controlCopy.Width);
                }
                if (controlBeingAdded.DockPointLocation == dockPointLocations[DockTypes.Bottom])
                {
                    dockPointLocations[DockTypes.Bottom] = AddWidthToDockPoint(DockTypes.Bottom, controlCopy.Width);
                }
                if (controlBeingAdded.DockPointLocation == dockPointLocations[DockTypes.TopRight])
                {
                    dockPointLocations[DockTypes.TopRight] = AddHeightToDockPoint(DockTypes.TopRight, controlCopy.Height);
                }
                if (controlBeingAdded.DockPointLocation == dockPointLocations[DockTypes.Right])
                {
                    dockPointLocations[DockTypes.Right] = AddHeightToDockPoint(DockTypes.Right, controlCopy.Height);
                }
                if (controlBeingAdded.DockPointLocation == dockPointLocations[DockTypes.BottomRight])
                {
                    dockPointLocations[DockTypes.BottomRight] = AddHeightToDockPoint(DockTypes.BottomRight, -controlCopy.Height);
                }
                if (controlBeingAdded.DockPointLocation == dockPointLocations[DockTypes.Top2])
                {
                    dockPointLocations[DockTypes.Top2] = AddWidthToDockPoint(DockTypes.Top2, -controlCopy.Width);
                }
                if (controlBeingAdded.DockPointLocation == dockPointLocations[DockTypes.Bottom2])
                {
                    dockPointLocations[DockTypes.Bottom2] = AddWidthToDockPoint(DockTypes.Bottom2, -controlCopy.Width);
                }
                break;
            }
            }
        }
Esempio n. 6
0
 public MyContextMenu(MyPanel parent)
 {
     _parent = parent;
     SetupComponents();
 }
Esempio n. 7
0
        /// <summary>
        /// Inserts a panel into the layout lines system, and updates the lines around it.
        /// </summary>
        /// <param name="p">The control to add to the layout lines system</param>
        /// <param name="DockType">The dock type of the control that is added to the system</param>
        public void AddPanel(Control p, DockTypes DockType)
        {
            int  leftIndex   = 0;
            int  rightIndex  = 0;
            int  topIndex    = 0;
            int  bottomIndex = 0;
            int  indexToInsertPanelLineAt;
            Line panelLineToInsert;

            int[]      lineIndicesRestrictingPanel;
            List <int> lineIndicesToRemove = new List <int>();
            Locations  horizontalLocationToAddLine, verticalLocationToAddLine;

            horizontalLocationToAddLine = (MyPanel.IsDockedAtLeft(DockType) ? Locations.Left : Locations.Right);
            verticalLocationToAddLine   = (MyPanel.IsDockedAtTop(DockType) ? Locations.Top : Locations.Bottom);

            //VERTICAL POSITION
            lineIndicesRestrictingPanel = GetIndicesOfLinesRestrictingPanel(p, verticalLocationToAddLine);

            leftIndex  = lineIndicesRestrictingPanel[0];
            rightIndex = lineIndicesRestrictingPanel[1];

            if (leftIndex == rightIndex)
            {
                lines[verticalLocationToAddLine].Insert(leftIndex + 1, new Line(lines[verticalLocationToAddLine][leftIndex]));
                rightIndex = leftIndex + 1;
            }

            lines[verticalLocationToAddLine][leftIndex].setEndPointX(p.Left);
            lines[verticalLocationToAddLine][rightIndex].setStartPointX(p.Right);

            if (lines[verticalLocationToAddLine][rightIndex].Length == 0)
            {
                lineIndicesToRemove.Add(rightIndex);
            }
            for (int i = rightIndex - 1; i > leftIndex; i--)
            {
                lineIndicesToRemove.Add(i);
            }
            if (lines[verticalLocationToAddLine][leftIndex].Length == 0)
            {
                lineIndicesToRemove.Add(leftIndex);
                indexToInsertPanelLineAt = leftIndex;
            }
            else
            {
                indexToInsertPanelLineAt = leftIndex + 1;
            }

            foreach (int index in lineIndicesToRemove)
            {
                lines[verticalLocationToAddLine].RemoveAt(index);
            }
            lineIndicesToRemove.Clear();

            panelLineToInsert = AddLineFromSideOfPanel(p, (verticalLocationToAddLine == Locations.Top ? Locations.Bottom : Locations.Top));
            lines[verticalLocationToAddLine].Insert(indexToInsertPanelLineAt, panelLineToInsert);


            //HORIZONTAL POSITION
            lineIndicesRestrictingPanel = GetIndicesOfLinesRestrictingPanel(p, horizontalLocationToAddLine);

            topIndex    = lineIndicesRestrictingPanel[0];
            bottomIndex = lineIndicesRestrictingPanel[1];

            //If only one line index, the same layout line covers the whole of the top of the panel
            if (topIndex == bottomIndex)
            {
                //Add a copy of this line
                lines[horizontalLocationToAddLine].Insert(topIndex + 1, new Line(lines[horizontalLocationToAddLine][topIndex]));
                bottomIndex = topIndex + 1;
            }

            //Set the end of the left line and start of the right line to the corners of the panel.
            lines[horizontalLocationToAddLine][topIndex].setEndPointY(p.Top);
            lines[horizontalLocationToAddLine][bottomIndex].setStartPointY(p.Bottom);

            //Remove any zero length lines at the bottom of the panel
            if (lines[horizontalLocationToAddLine][bottomIndex].Length == 0)
            {
                lineIndicesToRemove.Add(bottomIndex);
            }
            //Set a flag to remove any lines contained within the bounds of the panel
            for (int lineIndex = bottomIndex - 1; lineIndex > topIndex; lineIndex--)
            {
                lineIndicesToRemove.Add(lineIndex);
            }
            //Remove zero length lines at the top of the panel
            if (lines[horizontalLocationToAddLine][topIndex].Length == 0)
            {
                lineIndicesToRemove.Add(topIndex);
                indexToInsertPanelLineAt = topIndex;
                //If lines to the left are removed, the insertion index is the top index
            }
            else
            {
                indexToInsertPanelLineAt = topIndex + 1;
                //Else the insertion index is one above the top index
            }

            //Remove the lines marked for removal
            foreach (int index in lineIndicesToRemove)
            {
                lines[horizontalLocationToAddLine].RemoveAt(index);
            }
            lineIndicesToRemove.Clear();

            //Insert the line based on the edge of the panel
            panelLineToInsert = AddLineFromSideOfPanel(p, (horizontalLocationToAddLine == Locations.Left ? Locations.Right : Locations.Left));
            lines[horizontalLocationToAddLine].Insert(indexToInsertPanelLineAt, panelLineToInsert);
        }