/// <summary> /// Hide a dockable content removing it from its container <see cref="Pane"/> /// </summary> /// <param name="content">Content to hide</param> /// <remarks>Note that if you simply remove a content from its container without calling this method, the /// layout serializer component can't managed correctly the removed content.</remarks> internal void Hide(DockableContent content) { if (content.State == DockableContentState.Hidden) { DockableContents.Add(content); return; } if (!content.IsCloseable) return; if (content.State != DockableContentState.FloatingWindow && content.State != DockableContentState.DockableWindow) { //save position only if hiding from a docked or autohidden pane content.SaveCurrentStateAndPosition(); } if (content.State == DockableContentState.AutoHide) { HideFlyoutWindow(); RemoveContentFromTabGroup(content); } if (content.State == DockableContentState.FloatingWindow || content.State == DockableContentState.DockableWindow) { DockableFloatingWindow floatingWindow = Window.GetWindow(content) as DockableFloatingWindow; if (floatingWindow != null && (floatingWindow.Content as Pane).HasSingleItem && !floatingWindow.IsClosing) { floatingWindow.Close(); } } if (content.State != DockableContentState.Hidden) { DockableContents.Add(content); content.SetStateToHidden(); content.DetachFromContainerPane(); } if (ActiveDocument == content) ActiveDocument = null; if (ActiveContent == content) ActiveContent = null; }
protected override void OnInitialized(EventArgs e) { if (_paneToTransfer != null) { //setup window size ManagedContent selectedContent = _paneToTransfer.SelectedItem as ManagedContent; if (selectedContent is DockableContent) { _floatingWindow.SizeToContent = (selectedContent as DockableContent).FloatingWindowSizeToContent; } if (selectedContent != null && selectedContent.FloatingWindowSize.IsEmpty) { selectedContent.FloatingWindowSize = new Size(_paneToTransfer.ActualWidth, _paneToTransfer.ActualHeight); } if (selectedContent != null) { _floatingWindow.Width = selectedContent.FloatingWindowSize.Width; _floatingWindow.Height = selectedContent.FloatingWindowSize.Height; } else { _floatingWindow.Width = _paneToTransfer.ActualWidth; _floatingWindow.Height = _paneToTransfer.ActualHeight; } int selectedIndex = _paneToTransfer.SelectedIndex; //remove contents from container pane and insert in hosted pane while (_paneToTransfer.Items.Count > 0) { DockableContent contentToTranser = _paneToTransfer.Items[0] as DockableContent; contentToTranser.SaveCurrentStateAndPosition(); _paneToTransfer.RemoveContent(0); //add content to my temporary pane Items.Add(contentToTranser); contentToTranser.SetStateToDockableWindow(); } SelectedIndex = selectedIndex; //transfer the style from the original dockablepane //Style = _paneToTransfer.Style; AttachStyleFromPane(_paneToTransfer); ApplyTemplate(); LayoutTransform = (MatrixTransform)_paneToTransfer.TansformToAncestor(); } else if (_contentToTransfer != null) { //setup window size if (_contentToTransfer.FloatingWindowSize.IsEmpty) { _contentToTransfer.FloatingWindowSize = new Size(_contentToTransfer.ContainerPane.ActualWidth, _contentToTransfer.ContainerPane.ActualHeight); } _floatingWindow.Width = _contentToTransfer.FloatingWindowSize.Width; _floatingWindow.Height = _contentToTransfer.FloatingWindowSize.Height; //save current content position in container pane _previousPane = _contentToTransfer.ContainerPane; _arrayIndexPreviousPane = _previousPane.Items.IndexOf(_contentToTransfer); _contentToTransfer.SaveCurrentStateAndPosition(); //remove content from container pane _contentToTransfer.ContainerPane.RemoveContent(_arrayIndexPreviousPane); //add content to this pane Items.Add(_contentToTransfer); SelectedIndex = 0; AttachStyleFromPane(_previousPane as DockablePane); DocumentPane originalDocumentPane = _previousPane as DocumentPane; if (originalDocumentPane != null) { originalDocumentPane.CheckContentsEmpty(); } _contentToTransfer.SetStateToDockableWindow(); LayoutTransform = (MatrixTransform)_contentToTransfer.TansformToAncestor(); } base.OnInitialized(e); }