internal override void OnEndDrag()
        {
            if (HostedPane.Items.Count > 0)
            {
                DocumentContent content = HostedPane.Items[0] as DocumentContent;
                if (!content.IsFloatingAllowed)
                {
                    HostedPane.Items.RemoveAt(0);
                    _previousPane.Items.Insert(_arrayIndexPreviousPane, content);
                    _previousPane.SelectedItem = content;
                    Close();
                }
                else
                {
                    DocumentPane originalDocumentPane = _previousPane as DocumentPane;
                    originalDocumentPane.CheckContentsEmpty();
                }
            }
            else
            {
                DocumentPane originalDocumentPane = _previousPane as DocumentPane;
                originalDocumentPane.CheckContentsEmpty();
                Close();
            }


            base.OnEndDrag();
        }
Esempio n. 2
0
        public DockableFloatingWindow(DockingManager manager, DockableContent content)
            : this(manager)
        {
            //create a new temporary pane
            FloatingDockablePane pane = new FloatingDockablePane(this);

            //setup window size
            //Width = content.ContainerPane.ActualWidth;
            //Height = content.ContainerPane.ActualHeight;

            if (content.FloatingWindowSize.IsEmpty)
            {
                content.FloatingWindowSize = new Size(content.ContainerPane.ActualWidth, content.ContainerPane.ActualHeight);
            }

            Width  = content.FloatingWindowSize.Width;
            Height = content.FloatingWindowSize.Height;

            //save current content position in container pane
            _previousPane           = content.ContainerPane;
            _arrayIndexPreviousPane = _previousPane.Items.IndexOf(content);

            if (pane.GetType().IsSubclassOf(content.ContainerPane.Style.TargetType))
            {
                pane.Style = content.ContainerPane.Style;
            }

            //remove content from container pane
            content.ContainerPane.RemoveContent(_arrayIndexPreviousPane);

            //add content to my temporary pane
            pane.Items.Add(content);

            //let templates access this pane
            HostedPane = pane;

            //Change state on contents
            IsDockableWindow = true;

            DocumentPane originalDocumentPane = _previousPane as DocumentPane;
            if (originalDocumentPane != null)
            {
                originalDocumentPane.CheckContentsEmpty();
            }
        }
        /// <summary>
        /// Close this document removing it from its parent container
        /// </summary>
        /// <remarks>Use this function to close a document and remove it from its parent container. Please note
        /// that if you simply remove it from its parent <see cref="DocumentPane"/> without call this method, events like
        /// <see cref="OnClosing"/>/<see cref="OnClosed"/> are not called.
        /// <para>
        /// Note:<see cref="DockableContent"/> cannot be closed: AvalonDock simply hide a <see cref="DockableContent"/> removing all the reference to it.
        /// </para>
        /// </remarks>
        public void Close()
        {
            CancelEventArgs e = new CancelEventArgs(false);

            OnClosing(e);

            if (e.Cancel)
            {
                return;
            }

            DocumentPane parentPane = ContainerPane as DocumentPane;

            if (parentPane != null)
            {
                parentPane.Items.Remove(this);

                parentPane.CheckContentsEmpty();
            }

            OnClosed();
        }
        /// <summary>
        /// Close this content without notifications
        /// </summary>
        internal void InternalClose()
        {
            DocumentPane   parentPane = ContainerPane as DocumentPane;
            DockingManager manager    = Manager;

            if (manager != null)
            {
                if (manager.ActiveContent == this)
                {
                    manager.ActiveContent = null;
                }

                if (manager.ActiveDocument == this)
                {
                    manager.ActiveDocument = null;
                }
            }

            if (parentPane != null)
            {
                parentPane.Items.Remove(this);

                parentPane.CheckContentsEmpty();
            }
            else
            {
                FloatingDockablePane floatingParentPane = ContainerPane as FloatingDockablePane;
                if (floatingParentPane != null)
                {
                    floatingParentPane.RemoveContent(0);
                    if (floatingParentPane.FloatingWindow != null &&
                        !floatingParentPane.FloatingWindow.IsClosing)
                    {
                        floatingParentPane.FloatingWindow.Close();
                    }
                }
            }
        }
        /// <summary>
        /// Close this content without notifications
        /// </summary>
        internal void InternalClose()
        {
            this.LastActivation = DateTime.MinValue; // make this content ineligible for ActiveDocument selection when ActiveDocument is set to null
            DockingManager manager = Manager;

            if (manager != null)
            {
                if (manager.ActiveContent == this)
                {
                    manager.ActiveContent = null;
                }

                if (manager.ActiveDocument == this)
                {
                    manager.ActiveDocument = null;
                }
            }

            DocumentPane         parentPane         = ContainerPane as DocumentPane;
            FloatingDocumentPane floatingParentPane = ContainerPane as FloatingDocumentPane;

            if (floatingParentPane != null)
            {
                floatingParentPane.RemoveContent(0);
                if (floatingParentPane.FloatingWindow != null &&
                    !floatingParentPane.FloatingWindow.IsClosing)
                {
                    floatingParentPane.FloatingWindow.Close();
                }
            }
            else if (parentPane != null)
            {
                parentPane.Items.Remove(this);

                parentPane.CheckContentsEmpty();
            }
        }
Esempio n. 6
0
        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);
        }