Example #1
0
        private static void MergeSubContainers(Container parentContainer)
        {
            var parentContainerSize = (parentContainer.IsHorizontal)? parentContainer.Width : parentContainer.Height;

            for (var parentPIndex = parentContainer.Panels.Count - 1; parentPIndex >= 0  ; parentPIndex--)
            {
                var childContainer = parentContainer.Panels[parentPIndex] as Container;
                if (childContainer == null ||
                    childContainer.IsHorizontal != parentContainer.IsHorizontal)
                    continue;

                for (var childPIndex = childContainer.Panels.Count - 1; childPIndex > 0  ; childPIndex--)
                {
                    var childPanel = childContainer.Panels[childPIndex];
                    parentContainer.InsertPanel(childPanel,childContainer,false);

                    var childPanelSize = (childContainer.IsHorizontal)? childPanel.Width : childPanel.Height;

                    var rightRPos = 1.0f;
                    if(parentContainer.Splitters.Count > parentPIndex + 1)
                        rightRPos = parentContainer.Splitters[parentPIndex+1].RelativePosition;

                    var right = rightRPos*parentContainerSize;
                    var leftSplitter = parentContainer.Splitters[parentPIndex];
                    leftSplitter.RelativePosition = (right - childPanelSize)/parentContainerSize;
                }

                ReplaceContainerByPaneGroup(childContainer);
            }
            parentContainer.Invalidate();
        }
Example #2
0
 /// <summary>
 /// Move pane to a container relative to targetPaneGroup. 
 /// </summary>
 /// <param name="pane">Pane to be moved</param>
 /// <param name="targetPaneGroup"> </param>
 /// <param name="depth">Refer a parent container of targetPaneGroup, each depth is one parent container away. 
 /// Depth 0 add a PaneContainer in the same container if the container is horizontal, if not
 /// adds the movedPane to a new child vertical container</param>
 /// <param name="moveRigth"> True to move pane to the rigth of targetPaneGroup </param>
 internal static void MovePaneHorizontally(TabButton pane, PaneGroup targetPaneGroup, uint depth, bool moveRigth)
 {
     var container = GetParentContainer(targetPaneGroup);
     if (!container.IsHorizontal)
     {
         var childContainer = new Container(container);
         childContainer.IsHorizontal = true;
         container.ReplacePanel(targetPaneGroup,childContainer,false);
         childContainer.InsertPanel(targetPaneGroup);
         container = childContainer;
     }
     var paneGroup = new PaneGroup(container);
     paneGroup.AddPage(pane);
     container.InsertPanel(paneGroup,targetPaneGroup,!moveRigth);
 }
Example #3
0
        private static void ReplaceContainerByPaneGroup(Container childContainer)
        {
            var parentContainer = childContainer.Parent as Container;
            if (parentContainer == null)
                return;

            if (childContainer.Panels.Count != 1)
                return;

            parentContainer.ReplacePanel(childContainer,childContainer.Panels[0],true);
            MergeSubContainers(parentContainer);
        }