private void DetectorElement_PreviewDrop(object sender, DragEventArgs e)
        {
            e.Handled = true;
            HideHighlight();
            TearableTabItem droppedItem = e.Data.GetData(typeof(TearableTabItem)) as TearableTabItem;

            if (DropLocation.NA == dropLocation)
            {
                e.Handled = false;
            }
            else
            {
                if (DropLocation.Center != dropLocation)
                {
                    if (null != droppedItem)
                    {
                        OnTabDropChanged(e.Data.GetData(typeof(TearableTabItem)) as TearableTabItem);
                    }
                }
                else if (this.detectorElement is TearableTabControl)
                {
                    (detectorElement as TearableTabControl)?.DropTab(droppedItem);
                }
            }
        }
        private void DetectorElement_DragOver(object sender, DragEventArgs e)
        {
            mousePosition = e.GetPosition(sender as FrameworkElement);
            double vertical   = detectorElement.ActualWidth / 3;
            double horizontal = detectorElement.ActualHeight / 3;
            double opacity    = 0.5;

            dropLocation = DropLocation.NA;

            HideHighlight();
            TearableTabItem tabItemTarget = e.Source as TearableTabItem;

            if (this.IsChildOf(tabItemTarget))
            {
            }
            TearableTabItem tabItemSource = e.Data.GetData(typeof(TearableTabItem)) as TearableTabItem;

            if (this.IsChildOf(tabItemSource))
            {
            }
            if (mousePosition.Y > 25)
            {
                if (mousePosition.X < vertical)
                {
                    gridLeft.Opacity = opacity;
                    dropLocation     = DropLocation.Left;
                }
                else if (mousePosition.X > detectorElement.ActualWidth - vertical)
                {
                    gridRight.Opacity = opacity;
                    dropLocation      = DropLocation.Right;
                }
                else if (mousePosition.Y < horizontal)
                {
                    gridTop.Opacity = opacity;
                    dropLocation    = DropLocation.Top;
                }
                else if (mousePosition.Y > detectorElement.ActualHeight - horizontal)
                {
                    gridBottom.Opacity = opacity;
                    dropLocation       = DropLocation.Bottom;
                }
                else
                {
                    gridTop.Opacity    = opacity;
                    gridBottom.Opacity = opacity;
                    dropLocation       = DropLocation.Center;
                }
            }
        }
Beispiel #3
0
        private void CreateNewRandomTab()
        {
            Random r    = new Random();
            String name = String.Format("{0} test tab", tabCount++);

            for (int i = 0; i < 1; i++)
            {
                TearableTabItem tti = new TearableTabItem()
                {
                    Header  = name,
                    Content = new TextBlock()
                    {
                        Text = name
                    },
                    Background = GetRandomBrush(10, 240)
                };
                int tabControlIndex = r.Next(4 + tabWindows.Count);
                switch (tabControlIndex)
                {
                case 0:
                    ttcTestFirst.Items.Add(tti);
                    break;

                case 1:
                    ttcTestSecond.Items.Add(tti);
                    break;

                case 2:
                    ttcTestThird.Items.Add(tti);
                    break;

                case 3:
                    ttcTestFourth.Items.Add(tti);
                    break;

                default:
                    //tabWindows[tabControlIndex - 4].Items.Add(tti);
                    break;
                }
            }
        }
        public bool DropTab(TearableTabItem tabItem)
        {
            bool retValue = false;

            if (null != ttcLeft)
            {
                retValue = ttcLeft.DropTab(tabItem);
            }
            else if (null != ttcRight)
            {
                retValue = ttcRight.DropTab(tabItem);
            }
            else if (null != itccLeft)
            {
                retValue = itccLeft.DropTab(tabItem);
            }
            else if (null != itccRight)
            {
                retValue = itccRight.DropTab(tabItem);
            }
            return(retValue);
        }
Beispiel #5
0
        public bool DropTab(TearableTabItem tabItem)
        {
            bool retValue = false;

            if (null != ttcTop)
            {
                retValue = ttcTop.DropTab(tabItem);
            }
            else if (null != ttcBottom)
            {
                retValue = ttcBottom.DropTab(tabItem);
            }
            else if (null != itccTop)
            {
                retValue = itccTop.DropTab(tabItem);
            }
            else if (null != itccBottom)
            {
                retValue = itccBottom.DropTab(tabItem);
            }
            return(retValue);
        }
        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);
        }
        public bool AddControl(DropLocation location, TearableTabControl existingTabControl, TearableTabItem newTabItem, ref Grid droppedItemParent)
        {
            TearableTabControl ttcNew           = new TearableTabControl();
            TearableTabControl newTabItemParent = newTabItem.Parent as TearableTabControl;

            if (!ttcNew.DropTab(newTabItem))
            {
            }
            switch (location)
            {
            case DropLocation.Left:
                ttcLeft  = ttcNew;
                ttcRight = existingTabControl;
                break;

            case DropLocation.Right:
                ttcLeft  = existingTabControl;
                ttcRight = ttcNew;
                break;

            case DropLocation.Center:
            case DropLocation.Top:
            case DropLocation.Bottom:
            default:
                throw new NotSupportedException("Only left and right locations are supported in Horizontal");
            }

            // This is where it seems to go wrong as well as in TTSH
            // Start {
            droppedItemParent = existingTabControl.Parent as Grid;
            if (null != droppedItemParent)
            {
                droppedItemParent.Children.Remove(existingTabControl);
            }
            else
            {
            }
            if (this.IsChildOf(newTabItem))
            {
            }
            // } end
            gridContentVertical.Children.Insert(0, ttcLeft);
            Grid.SetColumn(ttcLeft, 0);
            gridContentVertical.Children.Insert(0, ttcRight);
            Grid.SetColumn(ttcRight, 2);

            AttachHandlers(ttcLeft);
            AttachHandlers(ttcRight);

            ttddLeft.AttachDetectorElement(ttcLeft);
            ttddRight.AttachDetectorElement(ttcRight);

            AttachHandlers(ttddLeft);
            AttachHandlers(ttddRight);

            return(true);
        }
Beispiel #8
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);
        }
 public void DropTab(TearableTabItem tabItem)
 {
     tearableTabControlOuter.DropTab(tabItem);
 }
 private void OnTabDropChanged(TearableTabItem droppedTab)
 {
     TabDrop?.Invoke(this, new TabDropEventArgs(dropLocation, droppedTab));
 }
Beispiel #11
0
 public TabDropEventArgs(DropLocation location, TearableTabItem tearableTab)
 {
     this.Location    = location;
     this.TearableTab = tearableTab;
 }