HitTestFilterBehavior HitTestFilter(DependencyObject potentialHit)
        {
            TabDockSpot spot = potentialHit as TabDockSpot;

            if (spot != null && spot.IsHitTestVisible)
            {
                this.hitTestSpot = spot;
                return(HitTestFilterBehavior.Stop);
            }

            return(HitTestFilterBehavior.Continue);
        }
        HitTestFilterBehavior HitTestFilter(DependencyObject potentialHit)
        {
            TabDockSpot spot = potentialHit as TabDockSpot;

            if (spot != null && spot.IsHitTestVisible)
            {
                this.hitTestSpot = spot;
                return HitTestFilterBehavior.Stop;
            }

            return HitTestFilterBehavior.Continue;
        }
        void UpdateHitState()
        {
            var pos = Mouse.GetPosition(this.draggedItem);

            if (this.preMoving)
            {
                var vector = pos - this.offset;
                if ((Math.Abs(vector.X) >= SystemParameters.MinimumHorizontalDragDistance) ||
                    (Math.Abs(vector.Y) >= SystemParameters.MinimumVerticalDragDistance))
                {
                    this.StartMoving();
                }
                else
                {
                    return;
                }
            }

            bool positionSet      = false;
            var  result           = VisualTreeHelper.HitTest(Application.Current.MainWindow, Mouse.GetPosition(Application.Current.MainWindow));
            var  newTargetControl = (result != null && result.VisualHit != null) ? result.VisualHit.FindParent <ActivatableTabControl>() : null;

            foreach (var floater in this.sourceSplitTabsControl.FloatingWindows)
            {
                result = VisualTreeHelper.HitTest(floater, Mouse.GetPosition(floater));
                if (result != null && result.VisualHit != null)
                {
                    newTargetControl = result.VisualHit.FindParent <ActivatableTabControl>() ?? newTargetControl;
                }
            }

            SetNewDropTarget(newTargetControl);

            if (this.dropTarget.IsVisible)
            {
                this.hitTestSpot = null;
                VisualTreeHelper.HitTest(this.dropTarget, this.HitTestFilter, this.HitTestResult, new PointHitTestParameters(Mouse.GetPosition(this.dropTarget)));
                if (this.hitTestSpot != null)
                {
                    var spot = this.hitTestSpot;

                    if (spot != null)
                    {
                        var rect = spot.DestinationNode.GetScreenRect();

                        if (spot.IsTabbed)
                        {
                            this.dragShadow.Left   = rect.X;
                            this.dragShadow.Top    = rect.Y;
                            this.dragShadow.Width  = rect.Width;
                            this.dragShadow.Height = rect.Height;
                            positionSet            = true;
                        }
                        else
                        {
                            switch (spot.Dock)
                            {
                            case Dock.Top:
                                this.dragShadow.Left   = rect.X;
                                this.dragShadow.Top    = rect.Y;
                                this.dragShadow.Width  = rect.Width;
                                this.dragShadow.Height = rect.Height / 2;
                                positionSet            = true;
                                break;

                            case Dock.Bottom:
                                this.dragShadow.Width  = rect.Width;
                                this.dragShadow.Height = rect.Height / 2;
                                this.dragShadow.Left   = rect.X;
                                this.dragShadow.Top    = rect.Y + this.dragShadow.Height;
                                positionSet            = true;
                                break;

                            case Dock.Left:
                                this.dragShadow.Left   = rect.X;
                                this.dragShadow.Top    = rect.Y;
                                this.dragShadow.Width  = rect.Width / 2;
                                this.dragShadow.Height = rect.Height;
                                positionSet            = true;
                                break;

                            case Dock.Right:
                                this.dragShadow.Width  = rect.Width / 2;
                                this.dragShadow.Height = rect.Height;
                                this.dragShadow.Left   = rect.X + this.dragShadow.Width;
                                this.dragShadow.Top    = rect.Y;
                                positionSet            = true;
                                break;
                            }
                        }
                    }
                }
            }

            if (!positionSet)
            {
                pos = this.draggedItem.PointToScreenIndependent(pos);
                this.dragShadow.Left   = pos.X - offset.X;
                this.dragShadow.Top    = pos.Y - offset.Y;
                this.dragShadow.Width  = dragWindowSize.Width;
                this.dragShadow.Height = dragWindowSize.Height;
            }
        }
        void UpdateHitState()
        {
            var pos = Mouse.GetPosition(this.draggedItem);

            if (this.preMoving)
            {
                var vector = pos - this.offset;
                if ((Math.Abs(vector.X) >= SystemParameters.MinimumHorizontalDragDistance) ||
                    (Math.Abs(vector.Y) >= SystemParameters.MinimumVerticalDragDistance))
                {
                    this.StartMoving();
                }
                else
                {
                    return;
                }
            }

            bool positionSet = false;
            var result = VisualTreeHelper.HitTest(Application.Current.MainWindow, Mouse.GetPosition(Application.Current.MainWindow));
            var newTargetControl = (result != null && result.VisualHit != null) ? result.VisualHit.FindParent<ActivatableTabControl>() : null;

            foreach (var floater in this.sourceSplitTabsControl.FloatingWindows)
            {
                result = VisualTreeHelper.HitTest(floater, Mouse.GetPosition(floater));
                if (result != null && result.VisualHit != null)
                {
                    newTargetControl = result.VisualHit.FindParent<ActivatableTabControl>() ?? newTargetControl;
                }
            }

            SetNewDropTarget(newTargetControl);

            if (this.dropTarget.IsVisible)
            {
                this.hitTestSpot = null;
                VisualTreeHelper.HitTest(this.dropTarget, this.HitTestFilter, this.HitTestResult, new PointHitTestParameters(Mouse.GetPosition(this.dropTarget)));
                if (this.hitTestSpot != null)
                {
                    var spot = this.hitTestSpot;

                    if (spot != null)
                    {
                        var rect = spot.DestinationNode.GetScreenRect();

                        if (spot.IsTabbed)
                        {
                            this.dragShadow.Left = rect.X;
                            this.dragShadow.Top = rect.Y;
                            this.dragShadow.Width = rect.Width;
                            this.dragShadow.Height = rect.Height;
                            positionSet = true;
                        }
                        else
                        {
                            switch (spot.Dock)
                            {
                                case Dock.Top:
                                    this.dragShadow.Left = rect.X;
                                    this.dragShadow.Top = rect.Y;
                                    this.dragShadow.Width = rect.Width;
                                    this.dragShadow.Height = rect.Height / 2;
                                    positionSet = true;
                                    break;
                                case Dock.Bottom:
                                    this.dragShadow.Width = rect.Width;
                                    this.dragShadow.Height = rect.Height / 2;
                                    this.dragShadow.Left = rect.X;
                                    this.dragShadow.Top = rect.Y + this.dragShadow.Height;
                                    positionSet = true;
                                    break;
                                case Dock.Left:
                                    this.dragShadow.Left = rect.X;
                                    this.dragShadow.Top = rect.Y;
                                    this.dragShadow.Width = rect.Width / 2;
                                    this.dragShadow.Height = rect.Height;
                                    positionSet = true;
                                    break;
                                case Dock.Right:
                                    this.dragShadow.Width = rect.Width / 2;
                                    this.dragShadow.Height = rect.Height;
                                    this.dragShadow.Left = rect.X + this.dragShadow.Width;
                                    this.dragShadow.Top = rect.Y;
                                    positionSet = true;
                                    break;
                            }
                        }
                    }
                }
            }

            if (!positionSet)
            {
                pos = this.draggedItem.PointToScreenIndependent(pos);
                this.dragShadow.Left = pos.X - offset.X;
                this.dragShadow.Top = pos.Y - offset.Y;
                this.dragShadow.Width = dragWindowSize.Width;
                this.dragShadow.Height = dragWindowSize.Height;
            }
        }