Example #1
0
        /// <summary>
        /// Transfers the windows manager contents after desealization has finished
        /// </summary>
        /// <param name="windowsManager">The windows manager.</param>
        private void TransferWindowsManagerContents(WindowsManager windowsManager)
        {
            windowsManager.Clear();

            // Transfer auto hide and pinned windows for all dock points);
            foreach (Dock dockPosition in DockPositions)
            {
                DockedWindows dockedWindows = _dockedWindows[dockPosition];

                foreach (DockPane pinnedPane in dockedWindows.PinnedPanes)
                {
                    windowsManager.AddPinnedWindow(pinnedPane, dockPosition);
                }

                foreach (DockPane autoHidePane in dockedWindows.AutoHidePanes)
                {
                    windowsManager.AddAutoHideWindow(autoHidePane, dockPosition);
                }
            }

            // Transfer floating windows
            foreach (DockPane floatingPane in _floatingWindows)
            {
                windowsManager.AddFloatingWindow(floatingPane);
            }

            // Transfer document content
            switch (_rootContainer.State)
            {
            case DocumentContainerState.Empty:
                break;

            case DocumentContainerState.ContainsDocuments:
                List <object> documents = new List <object>(_rootContainer.Documents);
                _rootContainer.Clear();
                foreach (object document in documents)
                {
                    if (document is DocumentContent)
                    {
                        DocumentContent documentContent = (document as DocumentContent);
                        documentContent.DetachDockPane();
                        windowsManager.DocumentContainer.AddDocument(documentContent.DockPane);
                    }
                }
                break;

            case DocumentContainerState.SplitHorizontally:
                TransferDocumentGrid(windowsManager, true);
                break;

            case DocumentContainerState.SplitVertically:
                TransferDocumentGrid(windowsManager, false);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Example #2
0
        /// <summary>
        /// Called when tab item is dragged
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="System.Windows.Input.MouseButtonEventArgs"/> instance containing the event data.</param>
        private void OnTabItemMouseMove(object sender, RoutedEventArgs args)
        {
            if ((Mouse.LeftButton != MouseButtonState.Pressed) || (!DragStarted))
            {
                return;
            }

            // Check for minimum distance in order to start drag
            Vector distance = Mouse.GetPosition(this) - DragStartPoint;

            if ((Math.Abs(distance.X) < SystemParameters.MinimumHorizontalDragDistance) &&
                (Math.Abs(distance.Y) < SystemParameters.MinimumVerticalDragDistance))
            {
                return;
            }

            DragStarted = false;

            WindowsManager windowsManager = this.GetLogicalParent <WindowsManager>();
            TabItem        currentItem    = (args.OriginalSource as FrameworkElement).GetVisualParent <TabItem>();

            if (currentItem == null)
            {
                return;
            }

            currentItem.Header  = null;
            currentItem.Content = null;

            DocumentContent dockPaneContent = currentItem.DataContext as DocumentContent;

            Documents.Remove(dockPaneContent);
            dockPaneContent.DetachDockPane();

            windowsManager.DocumentContainer.MergeEmptyDocumentContainers();

            Point    currentMousePoint = Mouse.GetPosition(windowsManager);
            DockPane pane = dockPaneContent.DockPane;

            Canvas.SetLeft(pane, currentMousePoint.X - pane.ActualWidth / 2);
            Canvas.SetTop(pane, currentMousePoint.Y);
            windowsManager.AddFloatingWindow(pane);
        }