public bool AddSplitControl(DropLocation location, DropLocation sourceLoaction, TearableTabItem ttItem)
        {
            ITabControlContainer itcc;
            Grid droppedItemParent = null;

            switch (location)
            {
            case DropLocation.Top:
            case DropLocation.Bottom:
                itcc = new TearableTabSplitHorizontal(this);
                break;

            case DropLocation.Left:
            case DropLocation.Right:
                itcc = new TearableTabSplitVertical(this);
                break;

            case DropLocation.Center:
            default:
                throw new NotSupportedException("Center not supported");
            }

            switch (sourceLoaction)
            {
            case DropLocation.Left:
                if (ttcLeft.Items.Contains(ttItem) && 1 == ttcLeft.Items.Count)
                {
                    return(false);
                }
                DetachHandlers(ttcLeft);
                gridContentVertical.Children.Remove(ttcLeft);
                TearableTabControl ttcLeftTmp = ttcLeft;
                if (ttcLeft == null)
                {
                }
                if (itcc.AddControl(location, ttcLeft, ttItem, ref droppedItemParent))
                {
                    ttddLeft.Visibility = Visibility.Collapsed;
                    ttddLeft.DetachDetectorElement();
                    Grid.SetColumn(itcc as UIElement, 0);
                    itccLeft = itcc;
                    ttcLeft  = null;
                    if (null == droppedItemParent)
                    {
                        gridContentVertical.Children.Insert(0, itcc as UIElement);
                    }
                    else
                    {
                        droppedItemParent.Children.Add(itcc as UIElement);
                    }
                }
                else
                {
                    (ttcLeftTmp.Parent as Grid).Children.Remove(ttcLeftTmp);
                    gridContentVertical.Children.Insert(0, ttcLeftTmp);
                }
                break;

            case DropLocation.Right:
                if (ttcRight.Items.Contains(ttItem) && 1 == ttcRight.Items.Count)
                {
                    return(false);
                }
                DetachHandlers(ttcRight);
                gridContentVertical.Children.Remove(ttcRight);
                TearableTabControl ttcRightTmp = ttcRight;
                if (ttcRight == null)
                {
                }
                if (itcc.AddControl(location, ttcRight, ttItem, ref droppedItemParent))
                {
                    ttddRight.Visibility = Visibility.Collapsed;
                    ttddRight.DetachDetectorElement();
                    Grid.SetColumn(itcc as UIElement, 2);
                    itccRight = itcc;
                    ttcRight  = null;
                    if (null == droppedItemParent)
                    {
                        gridContentVertical.Children.Insert(0, itcc as UIElement);
                    }
                    else
                    {
                        droppedItemParent.Children.Add(itcc as UIElement);
                    }
                }
                else
                {
                    (ttcRightTmp.Parent as Grid).Children.Remove(ttcRightTmp);
                    gridContentVertical.Children.Insert(0, ttcRightTmp);
                }
                break;

            case DropLocation.Top:
            case DropLocation.Bottom:
            case DropLocation.Center:
            default:
                throw new NotSupportedException("Center not supported");
            }
            //try
            //{
            //  gridContentVertical.Children.Insert(0, itcc as UIElement);
            //}
            //catch (Exception ex)
            //{
            //}

            return(true);
        }
Exemplo n.º 2
0
        public bool AddSplitControl(DropLocation location, DropLocation sourceLoaction, TearableTabItem ttItem)
        {
            ITabControlContainer itcc;
            Grid droppedItemParent = null;

            switch (location)
            {
            case DropLocation.Top:
            case DropLocation.Bottom:
                itcc = new TearableTabSplitHorizontal(this);
                break;

            case DropLocation.Left:
            case DropLocation.Right:
                itcc = new TearableTabSplitVertical(this);
                break;

            case DropLocation.Center:
            default:
                throw new NotSupportedException("Center not supported");
            }
            tabs[location] = itcc;
            switch (sourceLoaction)
            {
            case DropLocation.Top:
                if (ttcTop.Items.Contains(ttItem) && 1 == ttcTop.Items.Count)
                {
                    return(false);
                }
                DetachHandlers(ttcTop);
                gridContentHorizontal.Children.Remove(ttcTop);
                TearableTabControl ttcTopTmp = ttcTop;
                if (this.TabParent == null)
                {
                }
                if (ttcTop == null)
                {
                    // ADE 20210319
                    return(false);
                }
                if (itcc.AddControl(location, ttcTop, ttItem, ref droppedItemParent))
                {
                    ttddTop.Visibility = Visibility.Collapsed;
                    ttddTop.DetachDetectorElement();
                    Grid.SetRow(itcc as UIElement, 0);
                    itccTop = itcc;
                    ttcTop  = null;
                    if (null == droppedItemParent)
                    {
                        gridContentHorizontal.Children.Insert(0, itcc as UIElement);
                    }
                    else
                    {
                        droppedItemParent.Children.Add(itcc as UIElement);
                    }
                }
                else
                {
                    (ttcTopTmp.Parent as Grid).Children.Remove(ttcTopTmp);
                    gridContentHorizontal.Children.Insert(0, ttcTopTmp);
                }
                break;

            case DropLocation.Bottom:
                if (ttcBottom.Items.Contains(ttItem) && 1 == ttcBottom.Items.Count)
                {
                    return(false);
                }
                DetachHandlers(ttcBottom);
                gridContentHorizontal.Children.Remove(ttcBottom);
                TearableTabControl ttcBottomTmp = ttcBottom;
                if (ttcBottom == null)
                {
                }
                if (itcc.AddControl(location, ttcBottom, ttItem, ref droppedItemParent))
                {
                    ttddBottom.Visibility = Visibility.Collapsed;
                    ttddBottom.DetachDetectorElement();
                    Grid.SetRow(itcc as UIElement, 2);
                    itccBottom = itcc;
                    ttcBottom  = null;
                    if (null == droppedItemParent)
                    {
                        gridContentHorizontal.Children.Insert(0, itcc as UIElement);
                    }
                    else
                    {
                        droppedItemParent.Children.Add(itcc as UIElement);
                    }
                }
                else
                {
                    (ttcBottomTmp.Parent as Grid).Children.Remove(ttcBottomTmp);
                    gridContentHorizontal.Children.Insert(0, ttcBottomTmp);
                }
                break;

            case DropLocation.Left:
            case DropLocation.Right:
            case DropLocation.Center:
            default:
                throw new NotSupportedException("Center not supported");
            }

            return(true);
        }