예제 #1
0
        public void Execute(IPanel panel)
        {
            if (panel == null)
            {
                throw new ArgumentNullException("panel");
            }

            var tabContainer = panel.Parent as TabContainer;

            if (tabContainer != null)
            {
                if (tabContainer.Parent is IPanelContainer)
                {
                    var stackContainer = new StackContainer
                    {
                        Header = new PanelHeader
                        {
                            Text = "Stack Container"
                        },
                        Orientation = FindOptimalStackContainerOrientation(tabContainer)
                                      ?? Orientation.Horizontal
                    };
                    stackContainer.Activate();

                    var parentContainer   = tabContainer.Parent as IPanelContainer;
                    int tabContainerIndex = parentContainer.Presenters.IndexOf(tabContainer);
                    var newTabContainer   = (TabContainer)tabContainer.Clone();

                    parentContainer.Shutdown(tabContainer, b => { });

                    stackContainer.Presenters.Add(tabContainer);
                    stackContainer.Presenters.Add(newTabContainer);

                    parentContainer.Presenters.Insert(tabContainerIndex, stackContainer);
                }
            }
        }