Exemplo n.º 1
0
        /// <summary>
        /// Retrieves an oriented text position matching position advanced by
        /// a number of lines from its initial position.
        /// </summary>
        /// <param name="position">
        /// Initial text position of an object/character.
        /// </param>
        /// <param name="suggestedX">
        /// The suggested X offset, in pixels, of text position on the destination
        /// line. If suggestedX is set to Double.NaN it will be ignored, otherwise
        /// the method will try to find a position on the destination line closest
        /// to suggestedX.
        /// </param>
        /// <param name="count">
        /// Number of lines to advance. Negative means move backwards.
        /// </param>
        /// <param name="newSuggestedX">
        /// newSuggestedX is the offset at the position moved (useful when moving
        /// between columns or pages).
        /// </param>
        /// <param name="linesMoved">
        /// linesMoved indicates the number of lines moved, which may be less
        /// than count if there is no more content.
        /// </param>
        /// <returns>
        /// A TextPointer and its orientation matching suggestedX on the
        /// destination line.
        /// </returns>
        /// <exception cref="System.InvalidOperationException">
        /// Throws InvalidOperationException if IsValid is false.
        /// If IsValid returns false, Validate method must be called before
        /// calling this method.
        /// </exception>
        internal override ITextPointer GetPositionAtNextLine(ITextPointer position, double suggestedX, int count, out double newSuggestedX, out int linesMoved)
        {
            newSuggestedX = suggestedX;
            linesMoved    = count;

            DocumentsTrace.FixedDocumentSequence.TextOM.Trace(string.Format("GetPositionAtNextLine {0} {1} {2} {3} ", position, position.LogicalDirection, suggestedX, count));
            DocumentSequenceTextPointer newTp   = null;
            LogicalDirection            newEdge = LogicalDirection.Forward;
            DocumentSequenceTextPointer tp      = null;

            if (position != null)
            {
                tp = _docPage.FixedDocumentSequence.TextContainer.VerifyPosition(position);
            }

            // Note we do not handle cross page navigation
            if (tp != null)
            {
                if (ChildTextView != null)
                {
                    if (ChildTextView.TextContainer == tp.ChildBlock.ChildContainer)
                    {
                        ITextPointer childOTP = ChildTextView.GetPositionAtNextLine(tp.ChildPointer.CreatePointer(position.LogicalDirection), suggestedX, count, out newSuggestedX, out linesMoved);
                        if (childOTP != null)
                        {
                            newTp   = new DocumentSequenceTextPointer(ChildBlock, childOTP);
                            newEdge = childOTP.LogicalDirection;
                        }
                    }
                }
            }
            return(DocumentSequenceTextPointer.CreatePointer(newTp, newEdge));
        }
        // Token: 0x06002C21 RID: 11297 RVA: 0x000C86F0 File Offset: 0x000C68F0
        internal override ITextPointer GetTextPositionFromPoint(Point point, bool snapToText)
        {
            DocumentSequenceTextPointer documentSequenceTextPointer = null;
            LogicalDirection            gravity = LogicalDirection.Forward;

            if (this.ChildTextView != null)
            {
                ITextPointer textPositionFromPoint = this.ChildTextView.GetTextPositionFromPoint(point, snapToText);
                if (textPositionFromPoint != null)
                {
                    documentSequenceTextPointer = new DocumentSequenceTextPointer(this.ChildBlock, textPositionFromPoint);
                    gravity = textPositionFromPoint.LogicalDirection;
                }
            }
            if (documentSequenceTextPointer != null)
            {
                return(DocumentSequenceTextPointer.CreatePointer(documentSequenceTextPointer, gravity));
            }
            return(null);
        }
Exemplo n.º 3
0
        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------

        #region Internal Methods

        /// <summary>
        /// Retrieves a position matching a point.
        /// </summary>
        /// <param name="point">
        /// Point in pixel coordinates to test.
        /// </param>
        /// <param name="snapToText">
        /// If true, this method must always return a positioned text position
        /// (the closest position as calculated by the control's heuristics).
        /// If false, this method should return null position, if the test
        /// point does not fall within any character bounding box.
        /// </param>
        /// <returns>
        /// A text position and its orientation matching or closest to the point.
        /// </returns>
        /// <exception cref="System.InvalidOperationException">
        /// Throws InvalidOperationException if IsValid is false.
        /// If IsValid returns false, Validate method must be called before
        /// calling this method.
        /// </exception>
        internal override ITextPointer GetTextPositionFromPoint(Point point, bool snapToText)
        {
            DocumentsTrace.FixedDocumentSequence.TextOM.Trace(string.Format("GetTextPositionFromPoint {0}-{1}", point, snapToText));
            DocumentSequenceTextPointer tp   = null;
            LogicalDirection            edge = LogicalDirection.Forward;

            if (ChildTextView != null)
            {
                ITextPointer childOTP = ChildTextView.GetTextPositionFromPoint(point, snapToText);
                if (childOTP != null)
                {
                    tp   = new DocumentSequenceTextPointer(ChildBlock, childOTP);
                    edge = childOTP.LogicalDirection;
                }
            }

            // When snapToText is true, ChildTextView.GetTextPositionFromPoint will guranttee to
            // return a non-null position.
            // In current code, ChildTextView can't be null.
            return(tp == null ? null : DocumentSequenceTextPointer.CreatePointer(tp, edge));
        }
        // Token: 0x06002C24 RID: 11300 RVA: 0x000C8824 File Offset: 0x000C6A24
        internal override ITextPointer GetPositionAtNextLine(ITextPointer position, double suggestedX, int count, out double newSuggestedX, out int linesMoved)
        {
            newSuggestedX = suggestedX;
            linesMoved    = count;
            DocumentSequenceTextPointer thisTp  = null;
            LogicalDirection            gravity = LogicalDirection.Forward;
            DocumentSequenceTextPointer documentSequenceTextPointer = null;

            if (position != null)
            {
                documentSequenceTextPointer = this._docPage.FixedDocumentSequence.TextContainer.VerifyPosition(position);
            }
            if (documentSequenceTextPointer != null && this.ChildTextView != null && this.ChildTextView.TextContainer == documentSequenceTextPointer.ChildBlock.ChildContainer)
            {
                ITextPointer positionAtNextLine = this.ChildTextView.GetPositionAtNextLine(documentSequenceTextPointer.ChildPointer.CreatePointer(position.LogicalDirection), suggestedX, count, out newSuggestedX, out linesMoved);
                if (positionAtNextLine != null)
                {
                    thisTp  = new DocumentSequenceTextPointer(this.ChildBlock, positionAtNextLine);
                    gravity = positionAtNextLine.LogicalDirection;
                }
            }
            return(DocumentSequenceTextPointer.CreatePointer(thisTp, gravity));
        }
Exemplo n.º 5
0
 /// <summary>
 /// <see cref="ITextPointer.CreatePointer(int,LogicalDirection)"/>
 /// </summary>
 ITextPointer ITextPointer.CreatePointer(int distance, LogicalDirection gravity)
 {
     return(DocumentSequenceTextPointer.CreatePointer(this, distance, gravity));
 }
Exemplo n.º 6
0
 /// <summary>
 /// <see cref="ITextPointer.CreatePointer(int)"/>
 /// </summary>
 ITextPointer ITextPointer.CreatePointer(int distance)
 {
     return(DocumentSequenceTextPointer.CreatePointer(this, distance));
 }
Exemplo n.º 7
0
 /// <summary>
 /// <see cref="ITextPointer.CreatePointer()"/>
 /// </summary>
 ITextPointer ITextPointer.CreatePointer()
 {
     return(DocumentSequenceTextPointer.CreatePointer(this));
 }
Exemplo n.º 8
0
 // Token: 0x06002C15 RID: 11285 RVA: 0x000C82C9 File Offset: 0x000C64C9
 public static ITextPointer CreatePointer(DocumentSequenceTextPointer thisTp, LogicalDirection gravity)
 {
     return(DocumentSequenceTextPointer.CreatePointer(thisTp, 0, gravity));
 }
Exemplo n.º 9
0
 // Token: 0x06002C14 RID: 11284 RVA: 0x000C82B5 File Offset: 0x000C64B5
 public static ITextPointer CreatePointer(DocumentSequenceTextPointer thisTp, int distance)
 {
     return(DocumentSequenceTextPointer.CreatePointer(thisTp, distance, thisTp.ChildPointer.LogicalDirection));
 }