/// <summary> /// Handler for ITextView.BringPageIntoViewCompleted event. /// </summary> private static void HandleSelectByPageCompleted(object sender, BringPageIntoViewCompletedEventArgs e) { TextEditor This; Invariant.Assert(sender is ITextView); ((ITextView)sender).BringPageIntoViewCompleted -= new BringPageIntoViewCompletedEventHandler(HandleSelectByPageCompleted); if (e != null && !e.Cancelled && e.Error == null) { This = e.UserState as TextEditor; if (This == null || !This._IsEnabled) { return; } TextEditorTyping._FlushPendingInputItems(This); using (This.Selection.DeclareChangeBlock()) { // Update suggestedX TextEditorSelection.UpdateSuggestedXOnColumnOrPageBoundary(This, e.NewSuggestedOffset.X); int newComparedToOld = e.NewPosition.CompareTo(e.Position); if (e.Count < 0) // Moving up if count < 0, moving down otherwise { // Shift key is down - Extend the selection edge if (newComparedToOld < 0) { // We have another page in a given direction; move to it ExtendSelectionAndBringIntoView(e.NewPosition, This); } else { // No more pages in this direction. Move to container start. ExtendSelectionAndBringIntoView(e.NewPosition.TextContainer.Start, This); } } else { // Shift key is down - Extend the selection edge if (newComparedToOld > 0) { // We have another page in a given direction; move to it ExtendSelectionAndBringIntoView(e.NewPosition, This); } else { // No more pages in this direction. Move to container end. ExtendSelectionAndBringIntoView(e.NewPosition.TextContainer.End, This); } } } } }
/// <summary> /// Fires BringPageIntoViewCompleted event. /// </summary> /// <param name="e">Event arguments for the BringPageIntoViewCompleted event.</param> protected virtual void OnBringPageIntoViewCompleted(BringPageIntoViewCompletedEventArgs e) { if (this.BringPageIntoViewCompleted != null) { this.BringPageIntoViewCompleted(this, e); } }
/// <summary> /// Handler for ITextView.BringPageIntoViewCompleted event. /// </summary> private static void HandleMoveByPageCompleted(object sender, BringPageIntoViewCompletedEventArgs e) { Invariant.Assert(sender is ITextView); ((ITextView)sender).BringPageIntoViewCompleted -= new BringPageIntoViewCompletedEventHandler(HandleMoveByPageCompleted); if (e != null && !e.Cancelled && e.Error == null) { TextEditor This = e.UserState as TextEditor; if (This == null || !This._IsEnabled) { return; } TextEditorTyping._FlushPendingInputItems(This); using (This.Selection.DeclareChangeBlock()) { // Update suggestedX TextEditorSelection.UpdateSuggestedXOnColumnOrPageBoundary(This, e.NewSuggestedOffset.X); // Move insertion point to next or previous page This.Selection.SetCaretToPosition(e.NewPosition, e.NewPosition.LogicalDirection, /*allowStopAtLineEnd:*/true, /*allowStopNearSpace:*/true); } } }