Example #1
0
        // Token: 0x0600676F RID: 26479 RVA: 0x001CECD4 File Offset: 0x001CCED4
        internal Geometry GetTightBoundingGeometryFromTextPositions(ITextPointer startPosition, ITextPointer endPosition, Rect visibleRect)
        {
            Geometry geometry = null;

            if (endPosition.CompareTo(this.Cell.StaticElementEnd) >= 0)
            {
                geometry = new RectangleGeometry(this._rect.FromTextDpi());
            }
            else
            {
                SubpageParagraphResult            subpageParagraphResult = (SubpageParagraphResult)this.CreateParagraphResult();
                ReadOnlyCollection <ColumnResult> columns = subpageParagraphResult.Columns;
                Transform transform = new TranslateTransform(-TextDpi.FromTextDpi(base.ContentRect.u), -TextDpi.FromTextDpi(base.ContentRect.v));
                visibleRect = transform.TransformBounds(visibleRect);
                geometry    = TextDocumentView.GetTightBoundingGeometryFromTextPositionsHelper(columns[0].Paragraphs, subpageParagraphResult.FloatingElements, startPosition, endPosition, 0.0, visibleRect);
                if (geometry != null)
                {
                    Rect viewport = new Rect(0.0, 0.0, TextDpi.FromTextDpi(base.ContentRect.du), TextDpi.FromTextDpi(base.ContentRect.dv));
                    CaretElement.ClipGeometryByViewport(ref geometry, viewport);
                    transform = new TranslateTransform(TextDpi.FromTextDpi(base.ContentRect.u), TextDpi.FromTextDpi(base.ContentRect.v));
                    CaretElement.AddTransformToGeometry(geometry, transform);
                }
            }
            return(geometry);
        }
Example #2
0
        // Token: 0x0600651A RID: 25882 RVA: 0x001C62C0 File Offset: 0x001C44C0
        private static void DumpSubpageParagraphResult(XmlTextWriter writer, SubpageParagraphResult paragraph, Visual visualParent)
        {
            writer.WriteStartElement("SubpageParagraph");
            writer.WriteStartElement("Element");
            writer.WriteAttributeString("Type", paragraph.Element.GetType().FullName);
            writer.WriteEndElement();
            LayoutDump.DumpRect(writer, "LayoutBox", paragraph.LayoutBox);
            Visual visualParent2 = LayoutDump.DumpParagraphOffset(writer, paragraph, visualParent);

            LayoutDump.DumpColumnResults(writer, paragraph.Columns, visualParent2);
            writer.WriteEndElement();
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="startPosition"></param>
        /// <param name="endPosition"></param>
        /// <param name="visibleRect"></param>
        /// <returns></returns>
        internal Geometry GetTightBoundingGeometryFromTextPositions(ITextPointer startPosition, ITextPointer endPosition, Rect visibleRect)
        {
            Geometry geometry = null;

            // Find out if cell is selected. We consider cell selected if its end tag is crossed by selection.
            // The asymmetry is important here - it allows to use only normalized positions
            // and still be able to select individual cells.
            // Note that this logic is an assumption in textselection unit expansion mechanism
            // (TexSelection.ExtendSelectionToStructuralUnit method).
            if (endPosition.CompareTo(Cell.StaticElementEnd) >= 0)
            {
                geometry = new RectangleGeometry(_rect.FromTextDpi());
            }
            else
            {
                SubpageParagraphResult            paragraphResult = (SubpageParagraphResult)(CreateParagraphResult());
                ReadOnlyCollection <ColumnResult> colResults      = paragraphResult.Columns;
                Transform transform;

                transform   = new TranslateTransform(-TextDpi.FromTextDpi(ContentRect.u), -TextDpi.FromTextDpi(ContentRect.v));
                visibleRect = transform.TransformBounds(visibleRect);
                transform   = null;

                geometry = TextDocumentView.GetTightBoundingGeometryFromTextPositionsHelper(colResults[0].Paragraphs, paragraphResult.FloatingElements, startPosition, endPosition, 0.0, visibleRect);

                if (geometry != null)
                {
                    //  restrict geometry to the cell's content rect boundary.
                    //  because of end-of-line / end-of-para simulation calculated geometry could be larger.
                    Rect viewport = new Rect(0, 0, TextDpi.FromTextDpi(ContentRect.du), TextDpi.FromTextDpi(ContentRect.dv));
                    CaretElement.ClipGeometryByViewport(ref geometry, viewport);

                    transform = new TranslateTransform(TextDpi.FromTextDpi(ContentRect.u), TextDpi.FromTextDpi(ContentRect.v));
                    CaretElement.AddTransformToGeometry(geometry, transform);
                }
            }

            return(geometry);
        }