コード例 #1
0
        static object OnCoerceValueContentProperty(DependencyObject d, object baseValue)
        {
            DocumentFloatingWindow fl = ((DocumentFloatingWindow)d);

            if (fl.Content != null)
            {
                throw new InvalidOperationException("Content on floating windows can't be set more than one time.");
            }

            if (!(baseValue is DocumentContent))
            {
                throw new InvalidOperationException("Content must be of type DocumentContent");
            }

            FloatingDocumentPane paneToReturn = null;

            if (baseValue is DocumentContent)
            {
                paneToReturn = new FloatingDocumentPane(fl, baseValue as DocumentContent);
            }

            return(paneToReturn);
        }
コード例 #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.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();
            }
        }
コード例 #3
0
 internal void Drag(DocumentContent documentContent, Point point, Point offset)
 {
     if (CaptureMouse())
     {
         DocumentFloatingWindow floatingWindow = new DocumentFloatingWindow(this);
         floatingWindow.Content = documentContent;
         Drag(floatingWindow, point, offset);
     }
 }
コード例 #4
0
 internal FloatingDocumentPane(DocumentFloatingWindow floatingWindow, DocumentContent documentToTransfer)
 {
     _floatingWindow = floatingWindow;
     _documentToTransfer = documentToTransfer;
 }
コード例 #5
0
 internal FloatingDocumentPane(DocumentFloatingWindow floatingWindow, DocumentContent documentToTransfer)
 {
     _floatingWindow     = floatingWindow;
     _documentToTransfer = documentToTransfer;
 }
コード例 #6
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);
            }

        }