コード例 #1
0
        private void SetPropertyWindowVisibility(bool isVisible,
                                                 LayoutAnchorable window, LayoutAnchorablePane container)
        {
            if (isVisible && window.Parent == null)
            {
                if (propertyWindowGroup.Parent == null)
                {
                    windowPanel.Children.Insert(0, propertyWindowGroup);
                }

                if (window == taskPanel)
                {
                    propertyWindowGroup.Children.Insert(0, container);
                }
                else
                {
                    propertyWindowGroup.Children.Add(container);
                }
                container.Children.Add(window);
                window.Show();
            }
            else if (!isVisible && window.Parent != null)
            {
                window.Close();
            }
        }
コード例 #2
0
        private void RemoveDynamicPanel(LayoutAnchorable anchorable)
        {
            var invalidationSubscriptions = InvalidationSubscriptions.Where(o => o.Object == anchorable).ToList();

            foreach (var subscription in invalidationSubscriptions)
            {
                subscription.Break();
                InvalidationSubscriptions.Remove(subscription);
            }

            var view      = anchorable.Content.SafeCast <UserControl>();
            var viewModel = view.DataContext;

            view.DataContext = null;
            if (viewModel is IDestructible destructible)
            {
                destructible.TearDown();
            }

            anchorable.Hiding -= OnRemoveHandler;
            if (anchorable.GetRoot() == DockingView.DockingManager.Layout)
            {
                anchorable.Close();
            }

            ActivePanels.Remove(anchorable);
        }
コード例 #3
0
        /// <summary>
        /// Removes the editor pane.
        /// </summary>
        /// <param name="editorPane">The editor pane.</param>
        /// <seealso cref="CleanEditorPane"/>
        private void RemoveEditorPane([NotNull] LayoutAnchorable editorPane)
        {
            editorPane.IsActiveChanged -= EditorPaneIsActiveChanged;
            editorPane.Closing         -= EditorPaneClosing;
            editorPane.Closed          -= EditorPaneClosed;

            // If this editor pane was closed by user, no need to do that; it is necessary for closing programmatically
            if (editorPane.Root != null)
            {
                editorPane.Close();
            }
        }
コード例 #4
0
        /// <summary>
        /// Closes the document.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="document" /> is <c>null</c>.</exception>
        public static void CloseDocument(LayoutAnchorable document)
        {
            Argument.IsNotNull(() => document);

            document.Close();
        }
コード例 #5
0
        protected virtual void FixupLayout(LayoutRoot layout)
        {
            int i;

            foreach (ILayoutPreviousContainer layoutPreviousContainer in
                     from lc in layout.Descendents().OfType <ILayoutPreviousContainer>()
                     where lc.PreviousContainerId != null
                     select lc)
            {
                ILayoutPaneSerializable layoutPaneSerializable = layout.Descendents().OfType <ILayoutPaneSerializable>().FirstOrDefault <ILayoutPaneSerializable>((ILayoutPaneSerializable lps) => lps.Id == layoutPreviousContainer.PreviousContainerId);
                if (layoutPaneSerializable == null)
                {
                    throw new ArgumentException(string.Format("Unable to find a pane with id ='{0}'", layoutPreviousContainer.PreviousContainerId));
                }
                layoutPreviousContainer.PreviousContainer = layoutPaneSerializable as ILayoutContainer;
            }
            LayoutAnchorable[] array = (
                from lc in layout.Descendents().OfType <LayoutAnchorable>()
                where lc.Content == null
                select lc).ToArray <LayoutAnchorable>();
            for (i = 0; i < (int)array.Length; i++)
            {
                LayoutAnchorable content          = array[i];
                LayoutAnchorable layoutAnchorable = null;
                if (content.ContentId != null)
                {
                    layoutAnchorable = this._previousAnchorables.FirstOrDefault <LayoutAnchorable>((LayoutAnchorable a) => a.ContentId == content.ContentId);
                }
                if (this.LayoutSerializationCallback != null)
                {
                    LayoutSerializationCallbackEventArgs layoutSerializationCallbackEventArg = new LayoutSerializationCallbackEventArgs(content, (layoutAnchorable != null ? layoutAnchorable.Content : null));
                    this.LayoutSerializationCallback(this, layoutSerializationCallbackEventArg);
                    if (layoutSerializationCallbackEventArg.Cancel)
                    {
                        content.Close();
                    }
                    else if (layoutSerializationCallbackEventArg.Content != null)
                    {
                        content.Content = layoutSerializationCallbackEventArg.Content;
                    }
                    else if (layoutSerializationCallbackEventArg.Model.Content != null)
                    {
                        content.Hide(false);
                    }
                }
                else if (layoutAnchorable != null)
                {
                    content.Content    = layoutAnchorable.Content;
                    content.IconSource = layoutAnchorable.IconSource;
                }
                else
                {
                    content.Hide(false);
                }
            }
            LayoutDocument[] layoutDocumentArray = (
                from lc in layout.Descendents().OfType <LayoutDocument>()
                where lc.Content == null
                select lc).ToArray <LayoutDocument>();
            for (i = 0; i < (int)layoutDocumentArray.Length; i++)
            {
                LayoutDocument layoutDocument  = layoutDocumentArray[i];
                LayoutDocument layoutDocument1 = null;
                if (layoutDocument.ContentId != null)
                {
                    layoutDocument1 = this._previousDocuments.FirstOrDefault <LayoutDocument>((LayoutDocument a) => a.ContentId == layoutDocument.ContentId);
                }
                if (this.LayoutSerializationCallback != null)
                {
                    LayoutSerializationCallbackEventArgs layoutSerializationCallbackEventArg1 = new LayoutSerializationCallbackEventArgs(layoutDocument, (layoutDocument1 != null ? layoutDocument1.Content : null));
                    this.LayoutSerializationCallback(this, layoutSerializationCallbackEventArg1);
                    if (layoutSerializationCallbackEventArg1.Cancel)
                    {
                        layoutDocument.Close();
                    }
                    else if (layoutSerializationCallbackEventArg1.Content != null)
                    {
                        layoutDocument.Content = layoutSerializationCallbackEventArg1.Content;
                    }
                    else if (layoutSerializationCallbackEventArg1.Model.Content != null)
                    {
                        layoutDocument.Close();
                    }
                }
                else if (layoutDocument1 != null)
                {
                    layoutDocument.Content = layoutDocument1.Content;
                }
                else
                {
                    layoutDocument.Close();
                }
            }
            layout.CollectGarbage();
        }