コード例 #1
0
        internal void Drag(DocumentContent documentContent, Point point, Point offset)
        {
            if (CaptureMouse())
            {
                DocumentFloatingWindow floatingWindow = new DocumentFloatingWindow(this);
                floatingWindow.Owner = Window.GetWindow(this);
                floatingWindow.CopyInputBindingsFromOwner();
                floatingWindow.Content = documentContent;
                Drag(floatingWindow, point, offset);
            }

        }
コード例 #2
0
        /// <summary>
        /// Show or add a document in AvalonDock
        /// </summary>
        /// <param name="document">Document to show/add.</param>
        /// <param name="floating">Indicates if the document should be placed in a floating window</param>
        /// <remarks>If document provided is not present in the <see cref="Documents"/> list, this method inserts it in first position of <see cref="MainDocumentPane.Items"/> collection.
        /// In both cases select it in the container <see cref="DocumentPane"/>.</remarks>
        internal void Show(DocumentContent document, bool floating)
        {
            bool found = Documents.FirstOrDefault(d => d == document) != null;

            if (!found && MainDocumentPane != null)
            {
                if (document.Parent is DocumentPane)
                {
                    ((DocumentPane)document.Parent).Items.Clear();
                }

                if (floating)
                {
                    DocumentFloatingWindow floatingWindow = new DocumentFloatingWindow(this);
                    floatingWindow.Owner = Window.GetWindow(this);
                    floatingWindow.CopyInputBindingsFromOwner();
                    floatingWindow.Content = document;
                    floatingWindow.Show();
                }
                else
                    MainDocumentPane.Items.Insert(0, document);
            }
            else if (found && document.ContainerPane is FloatingDocumentPane)
            {
                var containerPane = document.ContainerPane as FloatingDocumentPane;
                DocumentPane previousPane = containerPane.PreviousPane;
                int arrayIndexPreviuosPane = containerPane.ArrayIndexPreviousPane;
                //if previous pane exist that redock to it
                if (previousPane == null ||
                    previousPane.GetManager() != this)
                {
                    previousPane = MainDocumentPane;
                    arrayIndexPreviuosPane = 0;
                }

                if (previousPane != null)
                {
                    if (arrayIndexPreviuosPane > previousPane.Items.Count)
                        arrayIndexPreviuosPane = previousPane.Items.Count;

                    previousPane.Items.Insert(arrayIndexPreviuosPane,
                        containerPane.RemoveContent(0));
                }

                containerPane.FloatingWindow.Close();
            }

        }