void ITabTearOffHandler.HandleTargetlessDrop(object item, TabControl sourceTabControl, int sourceIndex, Point dropLocation)
        {
            ShellView sourceWindow = Window.GetWindow(sourceTabControl) as ShellView;

            if (sourceWindow == null)
            {
                return;
            }
            if (sourceTabControl.Items.Count == 1)
            {
                sourceWindow.Left = dropLocation.X;
                sourceWindow.Top  = dropLocation.Y;
                sourceWindow.Activate();
            }
            else
            {
                ShellView targetWindow = this._shellViewFactory.Create();
                using (sourceWindow.CreateIgnoreSelectionChangedScope())
                {
                    targetWindow.Left   = dropLocation.X;
                    targetWindow.Top    = dropLocation.Y;
                    targetWindow.Height = sourceWindow.WindowState == WindowState.Normal ? sourceWindow.ActualHeight : sourceWindow.RestoreBounds.Height;
                    targetWindow.Width  = sourceWindow.WindowState == WindowState.Normal ? sourceWindow.ActualWidth : sourceWindow.RestoreBounds.Width;
                    sourceTabControl.Items.RemoveAt(sourceIndex);
                    targetWindow.Show();
                    targetWindow.Activate();
                }
                targetWindow.TabControl.SelectedIndex = targetWindow.TabControl.Items.Add(item);
            }
        }
        void ITabTearOffHandler.HandleTargetedDrop(object item, TabControl sourceTabControl, int sourceIndex, TabControl targetTabControl, int insertionIndex)
        {
            ShellView sourceWindow = Window.GetWindow(sourceTabControl) as ShellView;

            if (sourceWindow == null)
            {
                return;
            }
            using (sourceWindow.CreateIgnoreSelectionChangedScope())
            {
                sourceTabControl.Items.RemoveAt(sourceIndex);
            }
            targetTabControl.Items.Insert(insertionIndex, item);
            targetTabControl.SelectedIndex = insertionIndex;
            if (sourceTabControl.Items.Count != 0)
            {
                return;
            }
            sourceWindow.Close();
            this._shellViewFactory.Release(sourceWindow);
        }
        void ITabTearOffHandler.HandleReorder(object item, TabControl tabControl, int sourceIndex, int insertionIndex)
        {
            int tabIndex = insertionIndex - (insertionIndex > sourceIndex ? 1 : 0);

            if (tabIndex == sourceIndex)
            {
                return;
            }
            ShellView window = Window.GetWindow(tabControl) as ShellView;

            if (window == null)
            {
                return;
            }
            using (window.CreateIgnoreSelectionChangedScope())
            {
                tabControl.Items.RemoveAt(sourceIndex);
                tabControl.Items.Insert(tabIndex, item);
                tabControl.SelectedIndex = tabIndex;
            }
        }