当前位置: 首页>>代码示例>>C#>>正文


C# ITextView.GetTightBoundingGeometryFromTextPositions方法代码示例

本文整理汇总了C#中ITextView.GetTightBoundingGeometryFromTextPositions方法的典型用法代码示例。如果您正苦于以下问题:C# ITextView.GetTightBoundingGeometryFromTextPositions方法的具体用法?C# ITextView.GetTightBoundingGeometryFromTextPositions怎么用?C# ITextView.GetTightBoundingGeometryFromTextPositions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITextView的用法示例。


在下文中一共展示了ITextView.GetTightBoundingGeometryFromTextPositions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetPageGeometry

            /// <summary>
            /// Get a geometry for a particular page and transforms it to the parent page
            /// </summary>
            /// <param name="segment">the TextSegment for which geometry we are looking</param> 
            /// <param name="view">the page view</param>
            /// <param name="parentView">the parent page view</param> 
            /// <returns></returns> 
            private Geometry GetPageGeometry(TextSegment segment, ITextView view, ITextView parentView)
            { 
                Debug.Assert((view != null) && (parentView != null), "null text view");
                //in the initial layout update the TextViews might be invalid. This is OK
                //since there will be a second pass
                if (!view.IsValid || !parentView.IsValid) 
                    return null;
 
                //Debug.Assert((view.RenderScope != null) && (parentView.RenderScope != null), "null text view render scope"); 
                if ((view.RenderScope == null) || (parentView.RenderScope == null))
                    return null; 

                Geometry pageGeometry = null;
                pageGeometry = view.GetTightBoundingGeometryFromTextPositions(segment.Start, segment.End);
 
                if (pageGeometry != null)
                { 
                    if (parentView != null) 
                    {
                        Transform additionalTransform = (Transform)view.RenderScope.TransformToVisual(parentView.RenderScope); 
                        if (pageGeometry.Transform != null)
                        {
                            //we need to create geometry group in this case
                            TransformGroup group = new TransformGroup(); 
                            group.Children.Add(pageGeometry.Transform);
                            group.Children.Add(additionalTransform); 
                            pageGeometry.Transform = group; 
                        }
                        else 
                        {
                            //now set the transformation
                            pageGeometry.Transform = additionalTransform;
                        } 
                    }
                } 
 
                return pageGeometry;
            } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:45,代码来源:AnnotationHighlightLayer.cs

示例2: CalculateVisibleRect

        /// <summary> 
        /// Compute visible rectangle.
        /// </summary> 
        private Rect CalculateVisibleRect(ITextView textView, TextElement textElement, TextPointer startPointer, TextPointer endPointer)
        {
            Geometry geometry = textView.GetTightBoundingGeometryFromTextPositions(startPointer, endPointer);
            Rect visibleRect = (geometry != null) ? geometry.Bounds : Rect.Empty; 
            Visual visual = textView.RenderScope;
            while (visual != null && visibleRect != Rect.Empty) 
            { 
                if (VisualTreeHelper.GetClip(visual) != null)
                { 
                    GeneralTransform transform = textView.RenderScope.TransformToAncestor(visual).Inverse;

                    // Safer version of transform to descendent (doing the inverse ourself),
                    // we want the rect inside of our space. (Which is always rectangular and much nicer to work with) 
                    if (transform != null)
                    { 
                        Rect rectBounds = VisualTreeHelper.GetClip(visual).Bounds; 
                        rectBounds = transform.TransformBounds(rectBounds);
 
                        visibleRect.Intersect(rectBounds);
                    }
                    else
                    { 
                        // No visibility if non-invertable transform exists.
                        return Rect.Empty; 
                    } 
                }
 
                visual = VisualTreeHelper.GetParent(visual) as Visual;
            }

            return visibleRect; 
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:35,代码来源:TextElementAutomationPeer.cs


注:本文中的ITextView.GetTightBoundingGeometryFromTextPositions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。