Exemplo n.º 1
0
        /// <summary>
        /// Invoked when a new <see cref="ContentPane"/> has been created and needs to be added to the appropriate target collection.
        /// </summary>
        /// <param name="pane">The pane that was created and needs to be added to the appropriate collection</param>
        protected virtual void AddPane(ContentPane pane)
        {
            DocumentContentHost host = _target as DocumentContentHost;

            if (host != null)
            {
                ContentPane  sibling = GetSiblingDocument();
                TabGroupPane tgp     = null;

                if (sibling != null)
                {
                    tgp = LogicalTreeHelper.GetParent(sibling) as TabGroupPane;
                    Debug.Assert(null != tgp, "Expected all documents to be within a tab group pane.");
                }

                if (null == tgp)
                {
                    SplitPane sp = new SplitPane();
                    tgp = new TabGroupPane {
                        Name = "Z" + Guid.NewGuid().ToString("N")
                    };
                    sp.Panes.Add(tgp);
                    DocumentContentHost dch = host;
                    dch.Panes.Add(sp);
                }

                tgp.Items.Add(pane);
                RaiseInitializeContentPane(pane);
            }
            else
            {
                IList targetCollection = null;

                Debug.Assert(_target == null || !string.IsNullOrEmpty((string)_target.GetValue(FrameworkElement.NameProperty)),
                             "The Name should be set so the container will not be removed when all the panes have been moved elsewhere. Otherwise new panes may not be displayed.");

                SplitPane splitPane = _target as SplitPane;
                if (splitPane != null)
                {
                    targetCollection = splitPane.Panes;
                }
                else
                {
                    TabGroupPane target = _target as TabGroupPane;
                    if (target != null)
                    {
                        targetCollection = target.Items;
                    }
                }

                if (null != targetCollection)
                {
                    targetCollection.Add(pane);

                    RaiseInitializeContentPane(pane);
                }
            }
        }
Exemplo n.º 2
0
        private ContentPane GetSiblingDocument()
        {
            DocumentContentHost dch = _target as DocumentContentHost;

            if (dch == null)
            {
                return(null);
            }

            if (null != dch.ActiveDocument)
            {
                return(dch.ActiveDocument);
            }

            XamDockManager dm = XamDockManager.GetDockManager(dch);

            if (dm == null)
            {
                return(null);
            }

            ContentPane firstDocument = null;

            foreach (ContentPane cp in dm.GetPanes(PaneNavigationOrder.VisibleOrder))
            {
                if (cp.PaneLocation != PaneLocation.Document)
                {
                    continue;
                }

                if (firstDocument == null)
                {
                    firstDocument = cp;
                }

                if (cp.Visibility != Visibility.Visible)
                {
                    continue;
                }

                return(cp);
            }

            return(firstDocument);
        }