Esempio n. 1
0
 /// <summary>
 /// Fires BringPointIntoViewCompleted event.
 /// </summary>
 /// <param name="e">Event arguments for the BringPointIntoViewCompleted event.</param> 
 protected virtual void OnBringPointIntoViewCompleted(BringPointIntoViewCompletedEventArgs e)
 { 
     if (this.BringPointIntoViewCompleted != null) 
     {
         this.BringPointIntoViewCompleted(this, e); 
     }
 }
Esempio n. 2
0
        /// <summary> 
        /// Handler for ITextView.BringPointIntoViewCompleted event.
        /// </summary> 
        private void HandleBringPointIntoViewCompleted(object sender, BringPointIntoViewCompletedEventArgs e)
        {
            ITextPointer cursorPosition;
            Rect lastCharacterRect; 

            Invariant.Assert(sender is ITextView); 
            ((ITextView)sender).BringPointIntoViewCompleted -= new BringPointIntoViewCompletedEventHandler(HandleBringPointIntoViewCompleted); 

            // If the mouse selection state is not available, it means that the mouse was 
            // already released. It may happen when there is delay in view transitions
            // (i.e. page transition in DocumentViewerBase).
            // In such case ignore this event.
            if (_mouseSelectionState == null) 
            {
                return; 
            } 
            _mouseSelectionState.BringIntoViewInProgress = false;
 
            if (e != null && !e.Cancelled && e.Error == null)
            {
                Invariant.Assert(e.UserState == this && this.TextView == sender);
 
                cursorPosition = e.Position;
 
                if (cursorPosition != null) 
                {
                    // Check end-of-container condition 
                    if (cursorPosition.GetNextInsertionPosition(LogicalDirection.Forward) == null &&
                        cursorPosition.ParentType != null) //
                    {
                        // We are at the end of text container. Check whether mouse is farther than a last character 
                        lastCharacterRect = cursorPosition.GetCharacterRect(LogicalDirection.Backward);
                        if (e.Point.X > lastCharacterRect.X + lastCharacterRect.Width) 
                        { 
                            cursorPosition = this.TextContainer.End;
                        } 
                    }

                    // Move the caret/selection to match the cursor position.
                    this.Selection.ExtendSelectionByMouse(cursorPosition, _forceWordSelection, _forceParagraphSelection); 
                }
                else 
                { 
                    CancelExtendSelection();
                } 
            }
            else
            {
                CancelExtendSelection(); 
            }
        }