コード例 #1
0
        // Token: 0x06006F07 RID: 28423 RVA: 0x001FE3FC File Offset: 0x001FC5FC
        private static IContentHost GetICHFromFlowDocument(TextElement contentElement, FlowDocument flowDocument)
        {
            IContentHost result   = null;
            ITextView    textView = flowDocument.StructuralCache.TextContainer.TextView;

            if (textView != null)
            {
                if (textView.RenderScope is FlowDocumentView)
                {
                    if (VisualTreeHelper.GetChildrenCount(textView.RenderScope) > 0)
                    {
                        result = (VisualTreeHelper.GetChild(textView.RenderScope, 0) as IContentHost);
                    }
                }
                else if (textView.RenderScope is FrameworkElement)
                {
                    List <DocumentPageView> list = new List <DocumentPageView>();
                    ContentHostHelper.FindDocumentPageViews(textView.RenderScope, list);
                    for (int i = 0; i < list.Count; i++)
                    {
                        if (list[i].DocumentPage is FlowDocumentPage)
                        {
                            textView = (ITextView)((IServiceProvider)list[i].DocumentPage).GetService(typeof(ITextView));
                            if (textView != null && textView.IsValid && (textView.Contains(contentElement.ContentStart) || textView.Contains(contentElement.ContentEnd)))
                            {
                                result = (list[i].DocumentPage.Visual as IContentHost);
                            }
                        }
                    }
                }
            }
            return(result);
        }
コード例 #2
0
        // Token: 0x06006F08 RID: 28424 RVA: 0x001FE508 File Offset: 0x001FC708
        private static void FindDocumentPageViews(Visual root, List <DocumentPageView> pageViews)
        {
            Invariant.Assert(root != null);
            Invariant.Assert(pageViews != null);
            if (root is DocumentPageView)
            {
                pageViews.Add((DocumentPageView)root);
                return;
            }
            int internalVisualChildrenCount = root.InternalVisualChildrenCount;

            for (int i = 0; i < internalVisualChildrenCount; i++)
            {
                Visual           visual           = root.InternalGetVisualChild(i);
                FrameworkElement frameworkElement = visual as FrameworkElement;
                if (frameworkElement != null)
                {
                    if (frameworkElement.TemplatedParent != null)
                    {
                        if (frameworkElement is DocumentPageView)
                        {
                            pageViews.Add(frameworkElement as DocumentPageView);
                        }
                        else
                        {
                            ContentHostHelper.FindDocumentPageViews(frameworkElement, pageViews);
                        }
                    }
                }
                else
                {
                    ContentHostHelper.FindDocumentPageViews(visual, pageViews);
                }
            }
        }
コード例 #3
0
        // Token: 0x06006F06 RID: 28422 RVA: 0x001FE374 File Offset: 0x001FC574
        internal static IContentHost FindContentHost(ContentElement contentElement)
        {
            IContentHost result = null;

            if (contentElement == null)
            {
                return(null);
            }
            if (contentElement is TextElement)
            {
                TextContainer    textContainer = ((TextElement)contentElement).TextContainer;
                DependencyObject parent        = textContainer.Parent;
                if (parent is IContentHost)
                {
                    result = (IContentHost)parent;
                }
                else if (parent is FlowDocument)
                {
                    result = ContentHostHelper.GetICHFromFlowDocument((TextElement)contentElement, (FlowDocument)parent);
                }
                else if (textContainer.TextView != null && textContainer.TextView.RenderScope is IContentHost)
                {
                    result = (IContentHost)textContainer.TextView.RenderScope;
                }
            }
            return(result);
        }