internal TextParentUndoUnit(ITextSelection selection, ITextPointer anchorPosition, ITextPointer movingPosition) : base(String.Empty) { _selection = selection; _undoAnchorPositionOffset = anchorPosition.Offset; _undoAnchorPositionDirection = anchorPosition.LogicalDirection; _undoMovingPositionOffset = movingPosition.Offset; _undoMovingPositionDirection = movingPosition.LogicalDirection; // Bug 1706768: we are seeing unitialized values when the undo // undo is pulled off the undo stack. _redoAnchorPositionOffset // and _redoMovingPositionOffset are supposed to be initialized // with calls to RecordRedoSelectionState before that happens. // // This code path is being left enabled in DEBUG to help track down // the underlying bug post V1. #if DEBUG _redoAnchorPositionOffset = -1; _redoMovingPositionOffset = -1; #else _redoAnchorPositionOffset = 0; _redoMovingPositionOffset = 0; #endif }
// Raises a Changed event for any listeners, covering the // specified text. internal void FireChangedEvent(ITextPointer start, ITextPointer end) { if (Changed != null) { Changed(this, new SpellerHighlightChangedEventArgs(start, end)); } }
//------------------------------------------------------ // // Constructors // //------------------------------------------------------ #region Constructors // Ctor always set mutable flag to false internal DocumentSequenceTextPointer(ChildDocumentBlock childBlock, ITextPointer childPosition) { Debug.Assert(childBlock != null); Debug.Assert(childPosition != null); _childBlock = childBlock; _childTp = childPosition; }
//------------------------------------------------------ // // Constructors // //------------------------------------------------------ #region Constructors // Constructor. internal SpellerStatusTable(ITextPointer textContainerStart, SpellerHighlightLayer highlightLayer) { _highlightLayer = highlightLayer; _runList = new ArrayList(1); _runList.Add(new Run(textContainerStart, RunType.Dirty)); }
//----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors // Creates a new instance. internal SpellingError(Speller speller, ITextPointer start, ITextPointer end) { Invariant.Assert(start.CompareTo(end) < 0); _speller = speller; _start = start.GetFrozenPointer(LogicalDirection.Forward); _end = end.GetFrozenPointer(LogicalDirection.Backward); }
internal TextContainerChangeEventArgs(ITextPointer textPosition, int count, int charCount, TextChangeType textChange, DependencyProperty property, bool affectsRenderOnly) { _textPosition = textPosition.GetFrozenPointer(LogicalDirection.Forward); _count = count; _charCount = charCount; _textChange = textChange; _property = property; _affectsRenderOnly = affectsRenderOnly; }
/// <summary> /// <see cref="ITextView.GetRectangleFromTextPosition"/> /// </summary> /// <remarks> /// Calls GetRawRectangleFromTextPosition to get a rect and a transform, and applies the transform to the /// rect. /// </remarks> internal virtual Rect GetRectangleFromTextPosition(ITextPointer position) { Transform transform; Rect rect = GetRawRectangleFromTextPosition(position, out transform); // Transform must not be null. TextViews returning no transform should return identity Invariant.Assert(transform != null); if (rect != Rect.Empty) { rect = transform.TransformBounds(rect); } return rect; }
// Verifies a TextPointer is non-null and is associated with a given TextContainer. // // Throws an appropriate exception if a test fails. internal static void VerifyPosition(ITextContainer container, ITextPointer position, string paramName) { if (position == null) { throw new ArgumentNullException(paramName); } if (position.TextContainer != container) { throw new ArgumentException(SR.Get(SRID.NotInAssociatedTree, paramName)); } }
// Worker for GetText, accepts any ITextPointer. internal static string GetTextInRun(ITextPointer position, LogicalDirection direction) { char[] text; int textLength; int getTextLength; textLength = position.GetTextRunLength(direction); text = new char[textLength]; getTextLength = position.GetTextInRun(direction, text, 0, textLength); Invariant.Assert(getTextLength == textLength, "textLengths returned from GetTextRunLength and GetTextInRun are innconsistent"); return new string(text); }
// ignoreTextUnitBoundaries - true if normalization should ignore text // normalization (surrogates, combining marks, etc). // Used for fine-grained control by IMEs. internal TextRange(ITextPointer position1, ITextPointer position2, bool ignoreTextUnitBoundaries) { if (position1 == null) { throw new ArgumentNullException("position1"); } if (position2 == null) { throw new ArgumentNullException("position2"); } SetFlags(ignoreTextUnitBoundaries, Flags.IgnoreTextUnitBoundaries); ValidationHelper.VerifyPosition(position1.TextContainer, position1, "position1"); ValidationHelper.VerifyPosition(position1.TextContainer, position2, "position2"); TextRangeBase.Select(this, position1, position2); }
// Verifies two positions are safe to use as a logical text span. // // Throws ArgumentNullException if startPosition == null || endPosition == null // ArgumentException if startPosition.TextContainer != endPosition.TextContainer or // startPosition > endPosition internal static void VerifyPositionPair(ITextPointer startPosition, ITextPointer endPosition) { if (startPosition == null) { throw new ArgumentNullException("startPosition"); } if (endPosition == null) { throw new ArgumentNullException("endPosition"); } if (startPosition.TextContainer != endPosition.TextContainer) { throw new ArgumentException(SR.Get(SRID.InDifferentTextContainers, "startPosition", "endPosition")); } if (startPosition.CompareTo(endPosition) > 0) { throw new ArgumentException(SR.Get(SRID.BadTextPositionOrder, "startPosition", "endPosition")); } }
/// <summary> /// Constructor. /// </summary> /// <param name="startPosition"> /// Position preceeding the TextSegment's content. /// </param> /// <param name="endPosition"> /// Position following the TextSegment's content. /// </param> /// <param name="preserveLogicalDirection"> /// Whether preserves LogicalDirection of start and end positions. /// </param> internal TextSegment(ITextPointer startPosition, ITextPointer endPosition, bool preserveLogicalDirection) { ValidationHelper.VerifyPositionPair(startPosition, endPosition); if (startPosition.CompareTo(endPosition) == 0) { // To preserve segment emptiness // we use the same instance of a pointer // for both segment ends. _start = startPosition.GetFrozenPointer(startPosition.LogicalDirection); _end = _start; } else { Invariant.Assert(startPosition.CompareTo(endPosition) < 0); _start = startPosition.GetFrozenPointer(preserveLogicalDirection ? startPosition.LogicalDirection : LogicalDirection.Backward); _end = endPosition.GetFrozenPointer(preserveLogicalDirection ? endPosition.LogicalDirection : LogicalDirection.Forward); } }
// Like GetText, excepts also accepts a limit parameter -- no text is returned past // this second position. // limit may be null, in which case it is ignored. internal static int GetTextWithLimit(ITextPointer thisPointer, LogicalDirection direction, char[] textBuffer, int startIndex, int count, ITextPointer limit) { int charsCopied; if (limit == null) { // No limit, just call GetText. charsCopied = thisPointer.GetTextInRun(direction, textBuffer, startIndex, count); } else if (direction == LogicalDirection.Forward && limit.CompareTo(thisPointer) <= 0) { // Limit completely blocks the read. charsCopied = 0; } else if (direction == LogicalDirection.Backward && limit.CompareTo(thisPointer) >= 0) { // Limit completely blocks the read. charsCopied = 0; } else { int maxCount; // Get an upper bound on the amount of text to copy. // Since GetText always stops on non-text boundaries, it's // ok if the count too high, it will get truncated anyways. if (direction == LogicalDirection.Forward) { maxCount = Math.Min(count, thisPointer.GetOffsetToPosition(limit)); } else { maxCount = Math.Min(count, limit.GetOffsetToPosition(thisPointer)); } maxCount = Math.Min(count, maxCount); charsCopied = thisPointer.GetTextInRun(direction, textBuffer, startIndex, maxCount); } return charsCopied; }
/// <summary> /// Compares this TextPointer with another TextPointer. /// </summary> /// <param name="position"> /// The TextPointer to compare with. /// </param> /// <returns> /// Less than zero: this TextPointer preceeds position. /// Zero: this TextPointer is at the same location as position. /// Greater than zero: this TextPointer follows position. /// </returns> int ITextPointer.CompareTo(ITextPointer position) { int offset; int result; offset = ((PasswordTextPointer)position)._offset; if (_offset < offset) { result = -1; } else if (_offset > offset) { result = +1; } else { result = 0; } return result; }
/// <summary> /// Apply the display attribute to to the given range. /// </summary> internal void Apply(ITextPointer start, ITextPointer end) { // // #if NOT_YET if (_attr.crText.type != UnsafeNativeMethods.TF_DA_COLORTYPE.TF_CT_NONE) { } if (_attr.crBk.type != UnsafeNativeMethods.TF_DA_COLORTYPE.TF_CT_NONE) { } if (_attr.lsStyle != UnsafeNativeMethods.TF_DA_LINESTYLE.TF_LS_NONE) { } #endif }
// Returns the first dirty run following a specified position in the document. // start/end will be left null if no dirty ranges are found. internal void GetFirstDirtyRange(ITextPointer searchStart, out ITextPointer start, out ITextPointer end) { int index; Run run; start = null; end = null; // If this is ever slow enough to matter, we could cache the value. for (index = FindIndex(searchStart.CreateStaticPointer(), LogicalDirection.Forward); index >= 0 && index < _runList.Count; index++) { run = GetRun(index); if (run.RunType == RunType.Dirty) { // We might get a hit in the first run, in which case start <= searchStart. // Always return searchStart as a minimum. start = TextPointerBase.Max(searchStart, run.Position); end = GetRunEndPositionDynamic(index); break; } } }
//----------------------------------------------------- // // ITextRange Methods // //----------------------------------------------------- #region ITextRange Methods //...................................................... // // Selection Building // //...................................................... /// <summary> /// </summary> // internal static bool Contains(ITextRange thisRange, ITextPointer textPointer) { NormalizeRange(thisRange); if (textPointer == null) { throw new ArgumentNullException("textPointer"); } if (textPointer.TextContainer != thisRange.Start.TextContainer) { throw new ArgumentException(SR.Get(SRID.NotInAssociatedTree), "textPointer"); } // Correct position normalization on range boundary so that // our test would not depend on what side of formatting tags // pointer is located. if (textPointer.CompareTo(thisRange.Start) < 0) { textPointer = textPointer.GetFormatNormalizedPosition(LogicalDirection.Forward); } else if (textPointer.CompareTo(thisRange.End) > 0) { textPointer = textPointer.GetFormatNormalizedPosition(LogicalDirection.Backward); } // Check if at least one segment contains this position. for (int i = 0; i < thisRange._TextSegments.Count; i++) { if (thisRange._TextSegments[i].Contains(textPointer)) { return true; } } return false; }
//------------------------------------------------------ // // Internal Methods // //----------------------------------------------------- #region Internal Methods /// <summary> /// Inserts text at a specified position. /// </summary> /// <param name="position"> /// Position at which to insert the new text. /// </param> /// <param name="textData"> /// Text to insert. /// </param> /// <remarks> /// Use the CanInsertText method to determine if text may be inserted /// at position. /// /// All positions at this location are repositioned /// before or after the inserted text according to their gravity. /// </remarks> internal void InsertText(ITextPointer position, string textData) { int offset; int i; BeginChange(); try { offset = ((PasswordTextPointer)position).Offset; // Strangely, there is no SecureString.InsertAt(offset, string), so // we must use a loop here. for (i = 0; i < textData.Length; i++) { _password.InsertAt(offset + i, textData[i]); } OnPasswordChange(offset, textData.Length); } finally { EndChange(); } }
void System.Windows.Documents.ITextPointer.MoveToPosition(ITextPointer position) { }
// Token: 0x06008E56 RID: 36438 RVA: 0x0025BACC File Offset: 0x00259CCC internal IList <AnnotationHighlightLayer.HighlightSegment> Split(ITextPointer ps1, ITextPointer ps2, IHighlightRange newOwner) { IList <AnnotationHighlightLayer.HighlightSegment> list = new List <AnnotationHighlightLayer.HighlightSegment>(); if (ps1.CompareTo(ps2) == 0) { if (this._segment.Start.CompareTo(ps1) > 0 || this._segment.End.CompareTo(ps1) < 0) { return(list); } if (this._segment.Start.CompareTo(ps1) < 0) { list.Add(new AnnotationHighlightLayer.HighlightSegment(this._segment.Start, ps1, this._owners)); } list.Add(new AnnotationHighlightLayer.HighlightSegment(ps1, ps1, this._owners)); if (this._segment.End.CompareTo(ps1) > 0) { list.Add(new AnnotationHighlightLayer.HighlightSegment(ps1, this._segment.End, this._owners)); } using (IEnumerator <AnnotationHighlightLayer.HighlightSegment> enumerator = list.GetEnumerator()) { while (enumerator.MoveNext()) { AnnotationHighlightLayer.HighlightSegment highlightSegment = enumerator.Current; highlightSegment.AddActiveOwners(this._activeOwners); } goto IL_1A1; } } if (this._segment.Contains(ps1)) { IList <AnnotationHighlightLayer.HighlightSegment> list2 = this.Split(ps1, LogicalDirection.Forward); for (int i = 0; i < list2.Count; i++) { if (list2[i].Segment.Contains(ps2)) { IList <AnnotationHighlightLayer.HighlightSegment> list3 = list2[i].Split(ps2, LogicalDirection.Backward); for (int j = 0; j < list3.Count; j++) { list.Add(list3[j]); } if (!list3.Contains(list2[i])) { list2[i].Discard(); } } else { list.Add(list2[i]); } } } else { list = this.Split(ps2, LogicalDirection.Backward); } IL_1A1: if (list != null && list.Count > 0 && newOwner != null) { if (list.Count == 3) { list[1].AddOwner(newOwner); } else if (list[0].Segment.Start.CompareTo(ps1) == 0 || list[0].Segment.End.CompareTo(ps2) == 0) { list[0].AddOwner(newOwner); } else { list[1].AddOwner(newOwner); } } return(list); }
/// <summary> /// /// </summary> /// <param name="start"></param> /// <param name="end"></param> /// <returns></returns> internal override ReadOnlyCollection <GlyphRun> GetGlyphRuns(ITextPointer start, ITextPointer end) { Debug.Assert(false); return(null); }
// Token: 0x06008E5D RID: 36445 RVA: 0x0025C05C File Offset: 0x0025A25C private void CloseSegment(ref ITextPointer segmentStart, ITextPointer cursor, ITextPointer end) { if (segmentStart != null) { if (cursor.CompareTo(end) > 0) { cursor = end; } ITextPointer insertionPosition = cursor.GetInsertionPosition(LogicalDirection.Backward); if (segmentStart.CompareTo(insertionPosition) < 0) { this._contentSegments.Add(new TextSegment(segmentStart, insertionPosition)); } segmentStart = null; } }
// Token: 0x06006684 RID: 26244 RVA: 0x0000C238 File Offset: 0x0000A438 internal override ITextPointer GetBackspaceCaretUnitPosition(ITextPointer position) { return(null); }
// Token: 0x06006683 RID: 26243 RVA: 0x0000C238 File Offset: 0x0000A438 internal override ITextPointer GetNextCaretUnitPosition(ITextPointer position, LogicalDirection direction) { return(null); }
bool System.Windows.Documents.ITextPointer.HasEqualScope(ITextPointer position) { return(default(bool)); }
// Token: 0x060067E2 RID: 26594 RVA: 0x001D2D10 File Offset: 0x001D0F10 internal Geometry GetTightBoundingGeometryFromTextPositions(ReadOnlyCollection <ColumnResult> columns, ReadOnlyCollection <ParagraphResult> floatingElements, ITextPointer startPosition, ITextPointer endPosition, Rect visibleRect) { Geometry result = null; Invariant.Assert(columns != null && columns.Count <= 1, "Columns collection is null."); Invariant.Assert(floatingElements != null, "Floating element collection is null."); ReadOnlyCollection <ParagraphResult> readOnlyCollection = (columns.Count > 0) ? columns[0].Paragraphs : new ReadOnlyCollection <ParagraphResult>(new List <ParagraphResult>(0)); if (readOnlyCollection.Count > 0 || floatingElements.Count > 0) { result = TextDocumentView.GetTightBoundingGeometryFromTextPositionsHelper(readOnlyCollection, floatingElements, startPosition, endPosition, TextDpi.FromTextDpi(this._dvrTopSpace), visibleRect); Rect viewport = new Rect(0.0, 0.0, TextDpi.FromTextDpi(this._contentRect.du), TextDpi.FromTextDpi(this._contentRect.dv)); CaretElement.ClipGeometryByViewport(ref result, viewport); } return(result); }
/// <summary> /// /// </summary> /// <param name="position"></param> /// <param name="direction"></param> /// <returns></returns> internal override ITextPointer GetNextCaretUnitPosition(ITextPointer position, LogicalDirection direction) { Debug.Assert(false); return(null); }
// Callback for FrameworkElement.ContextMenuOpeningEvent. // If the control is using the default ContextMenu, we initialize it // here. internal static void OnContextMenuOpening(object sender, ContextMenuEventArgs e) { TextEditor This = TextEditor._GetTextEditor(sender); const double KeyboardInvokedSentinel = -1.0; // e.CursorLeft has this value when the menu is invoked with the keyboard. if (This == null || This.TextView == null) { return; } // Get the mouse position that base on RenderScope which we will set // the caret on the RenderScope. Point renderScopeMouseDownPoint = Mouse.GetPosition(This.TextView.RenderScope); ContextMenu contextMenu = null; bool startPositionCustomElementMenu = false; if (This.IsReadOnly) { // If the TextEditor is ReadOnly, only take action if // 1. The selection is non-empty AND // 2. The user clicked inside the selection. if ((e.CursorLeft != KeyboardInvokedSentinel && !This.Selection.Contains(renderScopeMouseDownPoint)) || (e.CursorLeft == KeyboardInvokedSentinel && This.Selection.IsEmpty)) { return; } } else if ((This.Selection.IsEmpty || e.TargetElement is TextElement) && e.TargetElement != null) { // Targeted element has its own ContextMenu, don't override it. contextMenu = (ContextMenu)e.TargetElement.GetValue(FrameworkElement.ContextMenuProperty); } else if (e.CursorLeft == KeyboardInvokedSentinel) { // If the menu was invoked from the keyboard, walk up the tree // from the selection.Start looking for a custom menu. TextPointer start = GetContentPosition(This.Selection.Start) as TextPointer; if (start != null) { TextElement element = start.Parent as TextElement; while (element != null) { contextMenu = (ContextMenu)element.GetValue(FrameworkElement.ContextMenuProperty); if (contextMenu != null) { startPositionCustomElementMenu = true; break; } element = element.Parent as TextElement; } } } // Update the selection caret. // // A negative offset for e.CursorLeft means the user invoked // the menu with a hotkey (shift-F10). Don't mess with the caret // unless the user right-clicked. if (e.CursorLeft != KeyboardInvokedSentinel) { if (!TextEditorMouse.IsPointWithinInteractiveArea(This, Mouse.GetPosition(This.UiScope))) { // Don't bring up a context menu if the user clicked on non-editable space. return; } // Don't update the selection caret if we're bringing up a custom UIElement // ContextMenu. if (contextMenu == null || !(e.TargetElement is UIElement)) { using (This.Selection.DeclareChangeBlock()) // NB: This raises a PUBLIC EVENT. { // If we're not over the selection, move the caret. if (!This.Selection.Contains(renderScopeMouseDownPoint)) { TextEditorMouse.SetCaretPositionOnMouseEvent(This, renderScopeMouseDownPoint, MouseButton.Right, 1 /* clickCount */); } } } } if (contextMenu == null) { // If someone explicitly set it null -- don't mess with it. if (This.UiScope.ReadLocalValue(FrameworkElement.ContextMenuProperty) == null) { return; } // Grab whatever's set to the UiScope's ContextMenu property. contextMenu = This.UiScope.ContextMenu; } // If we are here, it means that either a custom context menu or our default context menu will be opened. // Setting this flag ensures that we dont loose selection highlight while the context menu is open. This.IsContextMenuOpen = true; // If it's not null, someone's overriding our default -- don't mess with it. if (contextMenu != null && !startPositionCustomElementMenu) { // If the user previously raised the ContextMenu with the keyboard, // we've left h/v offsets non-zero, and they need to be cleared now // for mouse placement to work. contextMenu.HorizontalOffset = 0; contextMenu.VerticalOffset = 0; // Since ContextMenuService doesn't open the menu, it won't fire a ContextMenuClosing event. // We need to listen to the Closed event of the ContextMenu itself so we can clear the // IsContextMenuOpen flag. We also do this for the default menu later in this method. contextMenu.Closed += new RoutedEventHandler(OnContextMenuClosed); return; } // Complete the composition before creating the editor context menu. This.CompleteComposition(); if (contextMenu == null) { // It's a default null, so spin up a temporary ContextMenu now. contextMenu = new EditorContextMenu(); ((EditorContextMenu)contextMenu).AddMenuItems(This); } contextMenu.Placement = PlacementMode.RelativePoint; contextMenu.PlacementTarget = This.UiScope; ITextPointer position = null; LogicalDirection direction; // Position the ContextMenu. SpellingError spellingError = (contextMenu is EditorContextMenu) ? This.GetSpellingErrorAtSelection() : null; if (spellingError != null) { // If we have a matching speller error at the selection // start, position relative to the end of the error. position = spellingError.End; direction = LogicalDirection.Backward; } else if (e.CursorLeft == KeyboardInvokedSentinel) { // A negative offset for e.CursorLeft means the user invoked // the menu with a hotkey (shift-F10). Place the menu // relative to Selection.Start. position = This.Selection.Start; direction = LogicalDirection.Forward; } else { direction = LogicalDirection.Forward; } // Calculate coordinats for the ContextMenu. // They must be set relative to UIScope - as EditorContextMenu constructor assumes. if (position != null && position.CreatePointer(direction).HasValidLayout) { double horizontalOffset; double verticalOffset; GetClippedPositionOffsets(This, position, direction, out horizontalOffset, out verticalOffset); contextMenu.HorizontalOffset = horizontalOffset; contextMenu.VerticalOffset = verticalOffset; } else { Point uiScopeMouseDownPoint = Mouse.GetPosition(This.UiScope); contextMenu.HorizontalOffset = uiScopeMouseDownPoint.X; contextMenu.VerticalOffset = uiScopeMouseDownPoint.Y; } // Since ContextMenuService doesn't open the menu, it won't fire a ContextMenuClosing event. // We need to listen to the Closed event of the ContextMenu itself so we can clear the // IsContextMenuOpen flag. contextMenu.Closed += new RoutedEventHandler(OnContextMenuClosed); // This line raises a public event. contextMenu.IsOpen = true; e.Handled = true; }
/// <summary> /// Calculates x, y offsets for a ContextMenu based on an ITextPointer and /// the viewports of its containers. /// </summary> private static void GetClippedPositionOffsets(TextEditor This, ITextPointer position, LogicalDirection direction, out double horizontalOffset, out double verticalOffset) { // GetCharacterRect will return the position that base on UiScope. Rect positionRect = position.GetCharacterRect(direction); // Get the base offsets for our ContextMenu. horizontalOffset = positionRect.X; verticalOffset = positionRect.Y + positionRect.Height; // Clip to the child render scope. FrameworkElement element = This.TextView.RenderScope as FrameworkElement; if (element != null) { GeneralTransform transform = element.TransformToAncestor(This.UiScope); if (transform != null) { ClipToElement(element, transform, ref horizontalOffset, ref verticalOffset); } } // Clip to parent visuals. // This is unintuitive -- you might expect parents to have increasingly // larger viewports. But any parent that behaves like a ScrollViewer // will have a smaller view port that we need to clip against. for (Visual visual = This.UiScope; visual != null; visual = VisualTreeHelper.GetParent(visual) as Visual) { element = visual as FrameworkElement; if (element != null) { GeneralTransform transform = visual.TransformToDescendant(This.UiScope); if (transform != null) { ClipToElement(element, transform, ref horizontalOffset, ref verticalOffset); } } } // Clip to the window client rect. PresentationSource source = PresentationSource.CriticalFromVisual(This.UiScope); IWin32Window window = source as IWin32Window; if (window != null) { IntPtr hwnd = IntPtr.Zero; hwnd = window.Handle; NativeMethods.RECT rc = new NativeMethods.RECT(0, 0, 0, 0); SafeNativeMethods.GetClientRect(new HandleRef(null, hwnd), ref rc); // Convert to mil measure units. Point minPoint = new Point(rc.left, rc.top); Point maxPoint = new Point(rc.right, rc.bottom); CompositionTarget compositionTarget = source.CompositionTarget; minPoint = compositionTarget.TransformFromDevice.Transform(minPoint); maxPoint = compositionTarget.TransformFromDevice.Transform(maxPoint); // Convert to local coordinates. GeneralTransform transform = compositionTarget.RootVisual.TransformToDescendant(This.UiScope); if (transform != null) { transform.TryTransform(minPoint, out minPoint); transform.TryTransform(maxPoint, out maxPoint); // Finally, do the clip. horizontalOffset = ClipToBounds(minPoint.X, horizontalOffset, maxPoint.X); verticalOffset = ClipToBounds(minPoint.Y, verticalOffset, maxPoint.Y); } // ContextMenu code takes care of clipping to desktop. } }
/// <summary> /// Called from an event reporting that the drop happened. /// </summary> internal void TargetOnDrop(DragEventArgs e) { // if (!AllowDragDrop(e)) { return; } ITextSelection selection = _textEditor.Selection; Invariant.Assert(selection != null); if (e.Data == null || e.AllowedEffects == DragDropEffects.None) { e.Effects = DragDropEffects.None; return; } if ((int)(e.KeyStates & DragDropKeyStates.ControlKey) != 0) { e.Effects = DragDropEffects.Copy; } else if (e.Effects != DragDropEffects.Copy) { e.Effects = DragDropEffects.Move; } // Force a layout update on the content so the GetTextPositionFromPoint // call following can succeed. if (!_textEditor.TextView.Validate(e.GetPosition(_textEditor.TextView.RenderScope))) { e.Effects = DragDropEffects.None; return; } // Get the text position from the text target point. ITextPointer dropPosition = GetDropPosition(_textEditor.TextView.RenderScope as Visual, e.GetPosition(_textEditor.TextView.RenderScope)); if (dropPosition != null) { if (_dragSourceTextRange != null && _dragSourceTextRange.Start.TextContainer == selection.Start.TextContainer && !selection.IsEmpty && IsSelectionContainsDropPosition(selection, dropPosition)) { // When we drop inside of selected area, we // should not select dropped content, // otherwise it looks for end user as if // nothing happened. // Set caret to this position. selection.SetCaretToPosition(dropPosition, LogicalDirection.Backward, /*allowStopAtLineEnd:*/ false, /*allowStopNearSpace:*/ true); // Indicate the resulting effect of an action // Note that dropResult may stay equal to DragDropResult.Drop e.Effects = DragDropEffects.None; // Mark the event as handled e.Handled = true; } else { using (selection.DeclareChangeBlock()) { // For MaxLength filter work correctly in case // when we dragdrop within the same TextContainer, // we need to delete dragged content first - // before dropping when filtering will occur. // Note, that this will duplicate operation on // source side, but it will be void deletion action if ((e.Effects & DragDropEffects.Move) != 0 && // _dragSourceTextRange != null && _dragSourceTextRange.Start.TextContainer == selection.Start.TextContainer) { _dragSourceTextRange.Text = String.Empty; } // When we drop outside of selection, // we should ignore current selection and // move ip into dropping point. selection.SetCaretToPosition(dropPosition, LogicalDirection.Backward, /*allowStopAtLineEnd:*/ false, /*allowStopNearSpace:*/ true); // _DoPaste raises a public event -- could raise recoverable exception. e.Handled = TextEditorCopyPaste._DoPaste(_textEditor, e.Data, /*isDragDrop:*/ true); // } } if (e.Handled) { // Set the drop target as the foreground window. Win32SetForegroundWindow(); // Set the focus into the drop target. _textEditor.UiScope.Focus(); } else { // When a target did not handle a drop event, we must // prevent from deleting a content on source end - // otherwise we'll have data loss e.Effects = DragDropEffects.None; } } }
/// A handler for an event reporting that the drag over during drag-and-drop operation. internal void TargetOnDragOver(DragEventArgs e) { if (!AllowDragDrop(e)) { return; } // Ok, there's data to move or copy here. if ((e.AllowedEffects & DragDropEffects.Move) != 0) { e.Effects = DragDropEffects.Move; } bool ctrlKeyDown = ((int)(e.KeyStates & DragDropKeyStates.ControlKey) != 0); if (ctrlKeyDown) { e.Effects |= DragDropEffects.Copy; } // Show the caret on the drag over target position. if (_caretDragDrop != null) { // Update the layout to get the corrected text position. Otherwise, we can get the // incorrected text position. if (!_textEditor.TextView.Validate(e.GetPosition(_textEditor.TextView.RenderScope))) { return; } // Find the scroller from the render scope FrameworkElement scroller = _textEditor._Scroller; // Automatically scroll the dropable content(line or page up/down) if scroller is available if (scroller != null) { // Get the ScrollInfo to scroll a line or page up/down IScrollInfo scrollInfo = scroller as IScrollInfo; if (scrollInfo == null && scroller is ScrollViewer) { scrollInfo = ((ScrollViewer)scroller).ScrollInfo; } Invariant.Assert(scrollInfo != null); // Takes care of scrolling mechanism when vertical scrollbar is available, it creates a virtual // block within the viewport where if you position your mouse during drag leads to scrolling,here // it is of 16pixels and within first 8pixels it does scrolling by line and for next it scrolls by page. Point pointScroller = e.GetPosition((IInputElement)scroller); double pageHeight = (double)_textEditor.UiScope.GetValue(TextEditor.PageHeightProperty); double slowAreaHeight = ScrollViewer._scrollLineDelta; if (pointScroller.Y < slowAreaHeight) { // Drag position is on the scroll area that we need to scroll up if (pointScroller.Y > slowAreaHeight / 2) { // scroll a line up scrollInfo.LineUp(); } else { // scroll a page up scrollInfo.PageUp(); } } else if (pointScroller.Y > (pageHeight - slowAreaHeight)) { // Drag position is on the scroll area that we need to scroll down if (pointScroller.Y < (pageHeight - slowAreaHeight / 2)) { // scroll a line down scrollInfo.LineDown(); } else { // scroll a page down scrollInfo.PageDown(); } } } // Get the current text position from the dropable mouse point. _textEditor.TextView.RenderScope.UpdateLayout(); // if (_textEditor.TextView.IsValid) { ITextPointer dragPosition = GetDropPosition(_textEditor.TextView.RenderScope as Visual, e.GetPosition(_textEditor.TextView.RenderScope)); if (dragPosition != null) { // Get the caret position to show the dropable point. Rect caretRectangle = this.TextView.GetRectangleFromTextPosition(dragPosition); // NOTE: We DO NOT use GetCurrentValue because springload formatting should NOT be involved for drop caret. object fontStylePropertyValue = dragPosition.GetValue(TextElement.FontStyleProperty); bool italic = (_textEditor.AcceptsRichContent && fontStylePropertyValue != DependencyProperty.UnsetValue && (FontStyle)fontStylePropertyValue == FontStyles.Italic); Brush caretBrush = TextSelection.GetCaretBrush(_textEditor); // Show the caret on the dropable position. _caretDragDrop.Update(/*visible:*/ true, caretRectangle, caretBrush, 0.5, italic, CaretScrollMethod.None, /*wordWrappingPosition*/ double.NaN); } } } }
// Token: 0x06006685 RID: 26245 RVA: 0x0000C238 File Offset: 0x0000A438 internal override ReadOnlyCollection <GlyphRun> GetGlyphRuns(ITextPointer start, ITextPointer end) { return(null); }
/// <summary> /// Gets collection of AutomationPeers for given text range. /// </summary> internal override List <AutomationPeer> GetAutomationPeersFromRange(ITextPointer start, ITextPointer end) { return(new List <AutomationPeer>()); }
// Token: 0x06006682 RID: 26242 RVA: 0x0000B02A File Offset: 0x0000922A internal override bool IsAtCaretUnitBoundary(ITextPointer position) { return(false); }
/// <summary> /// /// </summary> /// <param name="position"></param> /// <returns></returns> internal override bool IsAtCaretUnitBoundary(ITextPointer position) { Debug.Assert(false); return(false); }
/// <summary> /// Returns tight bounding path geometry. /// </summary> internal Geometry GetTightBoundingGeometryFromTextPositions(ReadOnlyCollection <ColumnResult> columns, ReadOnlyCollection <ParagraphResult> floatingElements, ITextPointer startPosition, ITextPointer endPosition, Rect visibleRect) { Geometry geometry = null; // Floater always has one column, so we can skip getting a column from the text position range Invariant.Assert(columns != null && columns.Count <= 1, "Columns collection is null."); Invariant.Assert(floatingElements != null, "Floating element collection is null."); ReadOnlyCollection <ParagraphResult> paragraphs = (columns.Count > 0) ? columns[0].Paragraphs : new ReadOnlyCollection <ParagraphResult>(new List <ParagraphResult>(0)); if (paragraphs.Count > 0 || floatingElements.Count > 0) { geometry = TextDocumentView.GetTightBoundingGeometryFromTextPositionsHelper(paragraphs, floatingElements, startPosition, endPosition, TextDpi.FromTextDpi(_dvrTopSpace), visibleRect); // restrict geometry to the floater'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); } return(geometry); }
// Token: 0x060039C3 RID: 14787 RVA: 0x00106550 File Offset: 0x00104750 internal TextParentUndoUnit(ITextSelection selection, ITextPointer anchorPosition, ITextPointer movingPosition) : base(string.Empty) { this._selection = selection; this._undoAnchorPositionOffset = anchorPosition.Offset; this._undoAnchorPositionDirection = anchorPosition.LogicalDirection; this._undoMovingPositionOffset = movingPosition.Offset; this._undoMovingPositionDirection = movingPosition.LogicalDirection; this._redoAnchorPositionOffset = 0; this._redoMovingPositionOffset = 0; }
/// <summary> /// Returns tight bounding path geometry. /// </summary> internal Geometry GetTightBoundingGeometryFromTextPositions(ReadOnlyCollection<ColumnResult> columns, ReadOnlyCollection<ParagraphResult> floatingElements, ITextPointer startPosition, ITextPointer endPosition, Rect visibleRect) { Geometry geometry = null; // Floater always has one column, so we can skip getting a column from the text position range Invariant.Assert(columns != null && columns.Count <= 1, "Columns collection is null."); Invariant.Assert(floatingElements != null, "Floating element collection is null."); ReadOnlyCollection<ParagraphResult> paragraphs = (columns.Count > 0) ? columns[0].Paragraphs : new ReadOnlyCollection<ParagraphResult>(new List<ParagraphResult>(0)); if (paragraphs.Count > 0 || floatingElements.Count > 0) { geometry = TextDocumentView.GetTightBoundingGeometryFromTextPositionsHelper(paragraphs, floatingElements, startPosition, endPosition, TextDpi.FromTextDpi(_dvrTopSpace), visibleRect); // restrict geometry to the floater'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); } return (geometry); }
void System.Windows.Documents.ITextPointer.DeleteContentToPosition(ITextPointer limit) { }
bool System.Windows.Documents.ITextPointer.HasEqualScope(ITextPointer position) { return default(bool); }
int System.Windows.Documents.ITextPointer.GetOffsetToPosition(ITextPointer position) { return(default(int)); }
//Searches for the specified pattern and updates start *or* end pointers depending on search direction //At the end of the operation, start or end should be pointing to the beginning/end of the page //of occurance of pattern respectively internal static TextRange Find ( ITextPointer start, ITextPointer end, string findPattern, CultureInfo cultureInfo, bool matchCase, bool matchWholeWord, bool matchLast, bool matchDiacritics, bool matchKashida, bool matchAlefHamza) { Debug.Assert(start != null); Debug.Assert(end != null); Debug.Assert( ((start is DocumentSequenceTextPointer) && (end is DocumentSequenceTextPointer)) || ((start is FixedTextPointer) && (end is FixedTextPointer)) ); Debug.Assert(findPattern != null); if (findPattern.Length == 0) { return null; } IDocumentPaginatorSource paginatorSource = start.TextContainer.Parent as IDocumentPaginatorSource; DynamicDocumentPaginator paginator = paginatorSource.DocumentPaginator as DynamicDocumentPaginator; Debug.Assert(paginator != null); int pageNumber = -1; int endPageNumber = -1; if (matchLast) { endPageNumber = paginator.GetPageNumber( (ContentPosition) start); pageNumber = paginator.GetPageNumber( (ContentPosition) end); } else { endPageNumber = paginator.GetPageNumber( (ContentPosition) end); pageNumber = paginator.GetPageNumber( (ContentPosition) start); } TextRange result = null; CompareInfo compareInfo = cultureInfo.CompareInfo; bool replaceAlefWithAlefHamza = false; CompareOptions compareOptions = _InitializeSearch(cultureInfo, matchCase, matchAlefHamza, matchDiacritics, ref findPattern, out replaceAlefWithAlefHamza); //Translate the page number int translatedPageNumber = pageNumber; //If this is a DocumentSequence, we need to pass translated page number to the below call FixedDocumentSequence documentSequence = paginatorSource as FixedDocumentSequence; DynamicDocumentPaginator childPaginator = null; if (documentSequence != null) { documentSequence.TranslatePageNumber(pageNumber, out childPaginator, out translatedPageNumber); } if (pageNumber - endPageNumber != 0) { ITextPointer firstSearchPageStart = null; ITextPointer firstSearchPageEnd = null; _GetFirstPageSearchPointers(start, end, translatedPageNumber, matchLast, out firstSearchPageStart, out firstSearchPageEnd); Debug.Assert(firstSearchPageStart != null); Debug.Assert(firstSearchPageEnd != null); //Need to search the first page using TextFindEngine to start exactly from the requested search location to avoid false positives result = TextFindEngine.InternalFind( firstSearchPageStart, firstSearchPageEnd, findPattern, cultureInfo, matchCase, matchWholeWord, matchLast, matchDiacritics, matchKashida, matchAlefHamza); if (result == null) { //Start from the next page and check all pages until the end pageNumber = matchLast ? pageNumber-1 : pageNumber+1; int increment = matchLast ? -1 : 1; for (; matchLast ? pageNumber >= endPageNumber : pageNumber <= endPageNumber; pageNumber+=increment) { FixedDocument fixedDoc = null; translatedPageNumber = pageNumber; childPaginator = null; if (documentSequence != null) { documentSequence.TranslatePageNumber(pageNumber, out childPaginator, out translatedPageNumber); fixedDoc = (FixedDocument) childPaginator.Source; } else { fixedDoc = paginatorSource as FixedDocument; } Debug.Assert(fixedDoc != null); String pageString = _GetPageString(fixedDoc, translatedPageNumber, replaceAlefWithAlefHamza); if (pageString == null) { //This is not a page-per-stream //Default back to slow search return TextFindEngine.InternalFind( start, end, findPattern, cultureInfo, matchCase, matchWholeWord, matchLast, matchDiacritics, matchKashida, matchAlefHamza); } if ( _FoundOnPage(pageString, findPattern, cultureInfo, compareOptions) ) { //Update end or start pointer depending on search direction if (documentSequence != null) { ChildDocumentBlock childBlock = documentSequence.TextContainer.FindChildBlock(fixedDoc.DocumentReference); if (matchLast) { end = new DocumentSequenceTextPointer(childBlock, new FixedTextPointer(false, LogicalDirection.Backward, fixedDoc.FixedContainer.FixedTextBuilder.GetPageEndFlowPosition(translatedPageNumber))); start = new DocumentSequenceTextPointer(childBlock, new FixedTextPointer(false, LogicalDirection.Forward, fixedDoc.FixedContainer.FixedTextBuilder.GetPageStartFlowPosition(translatedPageNumber))); } else { start = new DocumentSequenceTextPointer(childBlock, new FixedTextPointer(false, LogicalDirection.Forward, fixedDoc.FixedContainer.FixedTextBuilder.GetPageStartFlowPosition(translatedPageNumber))); end = new DocumentSequenceTextPointer(childBlock, new FixedTextPointer(false, LogicalDirection.Backward, fixedDoc.FixedContainer.FixedTextBuilder.GetPageEndFlowPosition(translatedPageNumber))); } } else { //We are working on a FixedDocument FixedTextBuilder textBuilder = ((FixedDocument)(paginatorSource)).FixedContainer.FixedTextBuilder; if (matchLast) { end = new FixedTextPointer(false, LogicalDirection.Backward, textBuilder.GetPageEndFlowPosition(pageNumber)); start = new FixedTextPointer(false, LogicalDirection.Forward, textBuilder.GetPageStartFlowPosition(pageNumber)); } else { start = new FixedTextPointer(false, LogicalDirection.Forward, textBuilder.GetPageStartFlowPosition(pageNumber)); end = new FixedTextPointer(false, LogicalDirection.Backward, textBuilder.GetPageEndFlowPosition(pageNumber)); } } result = TextFindEngine.InternalFind( start, end, findPattern, cultureInfo, matchCase, matchWholeWord, matchLast, matchDiacritics, matchKashida, matchAlefHamza); //If the result is null, this means we had a false positive if (result != null) { return result; } } } } } else { //Make sure fast search result and slow search result are consistent FixedDocument fixedDoc = childPaginator != null ? childPaginator.Source as FixedDocument : paginatorSource as FixedDocument; String pageString = _GetPageString(fixedDoc, translatedPageNumber, replaceAlefWithAlefHamza); if (pageString == null || _FoundOnPage(pageString, findPattern, cultureInfo, compareOptions)) { //The search is only limited to the current page result = TextFindEngine.InternalFind( start, end, findPattern, cultureInfo, matchCase, matchWholeWord, matchLast, matchDiacritics, matchKashida, matchAlefHamza); } } return result; }
void System.Windows.Documents.ITextPointer.DeleteContentToPosition(ITextPointer limit) { }
internal Rect GetRectangleFromRowEndPosition(ITextPointer position) { Debug.Assert( TableParagraph.Table != null && CalculatedColumns != null ); PTS.FSTABLEROWDESCRIPTION[] arrayTableRowDesc; PTS.FSKUPDATE fskupdTable; PTS.FSRECT rectTable; if (QueryTableDetails(out arrayTableRowDesc, out fskupdTable, out rectTable)) { int vrCur = GetTableOffsetFirstRowTop() + rectTable.v; for (int iR = 0; iR < arrayTableRowDesc.Length; ++iR) { TableRow row = ((RowParagraph)(PtsContext.HandleToObject(arrayTableRowDesc[iR].fsnmRow))).Row; if(((TextPointer)position).CompareTo(row.ContentEnd) == 0) { return new Rect( TextDpi.FromTextDpi(rectTable.u + rectTable.du), TextDpi.FromTextDpi(vrCur), 1.0, TextDpi.FromTextDpi(arrayTableRowDesc[iR].u.dvrRow)); } vrCur += arrayTableRowDesc[iR].u.dvrRow; } } // Valid row end position should have been specified. Debug.Assert(false); return System.Windows.Rect.Empty; }
int System.Windows.Documents.ITextPointer.CompareTo(ITextPointer position) { return(default(int)); }
internal Geometry GetTightBoundingGeometryFromTextPositions(ITextPointer startPosition, ITextPointer endPosition, Rect visibleRect) { Debug.Assert( TableParagraph.Table != null && CalculatedColumns != null ); Geometry geometry = null; PTS.FSTABLEROWDESCRIPTION[] arrayTableRowDesc; PTS.FSKUPDATE fskupdTable; PTS.FSRECT rectTable; if (QueryTableDetails(out arrayTableRowDesc, out fskupdTable, out rectTable)) { bool passedEndPosition = false; for (int iR = 0; iR < arrayTableRowDesc.Length && !passedEndPosition; ++iR) { PTS.FSKUPDATE[] arrayUpdate; IntPtr[] arrayFsCell; PTS.FSTABLEKCELLMERGE[] arrayTableCellMerge; QueryRowDetails( arrayTableRowDesc[iR].pfstablerow, out arrayFsCell, out arrayUpdate, out arrayTableCellMerge); for (int iC = 0; iC < arrayFsCell.Length; ++iC) { if (arrayFsCell[iC] == IntPtr.Zero) { // paginated case - cell may be null continue; } CellParaClient cpc = (CellParaClient)(PtsContext.HandleToObject(arrayFsCell[iC])); if (endPosition.CompareTo(cpc.Cell.ContentStart) <= 0) { // remember that at least one cell in this row starts after the range's end. // in this case it is safe to break after this whole row is processed. // Note: can not break right away because cells in arrayFsCell come not // necessarily in backing store (cp) order. passedEndPosition = true; } else { if (startPosition.CompareTo(cpc.Cell.ContentEnd) <= 0) { Geometry cellGeometry = cpc.GetTightBoundingGeometryFromTextPositions(startPosition, endPosition, visibleRect); CaretElement.AddGeometry(ref geometry, cellGeometry); } } } } } if (geometry != null) { geometry = Geometry.Combine(geometry, Visual.Clip, GeometryCombineMode.Intersect, null); } return geometry; }
/// <summary> /// Responds to change affecting entire content of associated FlowDocument. /// </summary> /// <param name="affectsLayout">Whether change affects layout.</param> /// <param name="start">Start of the affected content range.</param> /// <param name="end">End of the affected content range.</param> void IFlowDocumentFormatter.OnContentInvalidated(bool affectsLayout, ITextPointer start, ITextPointer end) { if (affectsLayout) { InvalidateBRTLayout(start, end); } else { _brt.OnInvalidateRender(start, end); } }
/// <summary> /// /// </summary> /// <param name="position"></param> /// <returns></returns> internal override ITextPointer GetBackspaceCaretUnitPosition(ITextPointer position) { Debug.Assert(false); return(null); }
int System.Windows.Documents.ITextPointer.CompareTo(ITextPointer position) { return default(int); }
/// <summary> /// Invalidates a subset of the break record table, no event is fired /// </summary> private void InvalidateBRTLayout(ITextPointer start, ITextPointer end) { _brt.OnInvalidateLayout(start, end); }
int System.Windows.Documents.ITextPointer.GetOffsetToPosition(ITextPointer position) { return default(int); }
/// <summary> /// Constructor. /// </summary> /// <param name="position">Position of an object/character.</param> /// <param name="succeeded">Whether operation was successful.</param> /// <param name="error">Error occurred during an asynchronous operation.</param> /// <param name="cancelled">Whether an asynchronous operation has been cancelled.</param> /// <param name="userState">Unique identifier for the asynchronous task.</param> public BringPositionIntoViewCompletedEventArgs(ITextPointer position, bool succeeded, Exception error, bool cancelled, object userState) : base(error, cancelled, userState) { //_position = position; //_succeeded = succeeded; }
void System.Windows.Documents.ITextPointer.MoveToPosition(ITextPointer position) { }
/// <summary> /// Constructor. /// </summary> /// <param name="position">Initial text position of an object/character.</param> /// <param name="suggestedOffset"> /// The suggestedX parameter is the suggested X offset, in pixels, of /// the TextPointer on the destination line. /// </param> /// <param name="count">Number of lines to advance. Negative means move backwards.</param> /// <param name="newPosition">ITextPointer matching the given position advanced by the given number of line.</param> /// <param name="newSuggestedOffset">The offset at the position moved (useful when moving between columns or pages).</param> /// <param name="pagesMoved">Indicates the number of pages moved, which may be less than count if there is no more content.</param> /// <param name="succeeded">Whether operation was successful.</param> /// <param name="error">Error occurred during an asynchronous operation.</param> /// <param name="cancelled">Whether an asynchronous operation has been cancelled.</param> /// <param name="userState">Unique identifier for the asynchronous task.</param> public BringPageIntoViewCompletedEventArgs(ITextPointer position, Point suggestedOffset, int count, ITextPointer newPosition, Point newSuggestedOffset, int pagesMoved, bool succeeded, Exception error, bool cancelled, object userState) : base(error, cancelled, userState) { _position = position; //_suggestedX = suggestedX; _count = count; _newPosition = newPosition; _newSuggestedOffset = newSuggestedOffset; //_linesMoved = linesMoved; //_succeeded = succeeded; }
private static void _GetFirstPageSearchPointers ( ITextPointer start, ITextPointer end, int pageNumber, bool matchLast, out ITextPointer firstSearchPageStart, out ITextPointer firstSearchPageEnd) { if (matchLast) { //The page in question is the last page //Need to search between the start of the last page and the end pointer DocumentSequenceTextPointer endAsDSTP = end as DocumentSequenceTextPointer; if (endAsDSTP != null) { FlowPosition pageStartFlowPosition = ((FixedTextContainer)(endAsDSTP.ChildBlock.ChildContainer)).FixedTextBuilder.GetPageStartFlowPosition(pageNumber); firstSearchPageStart = new DocumentSequenceTextPointer(endAsDSTP.ChildBlock, new FixedTextPointer(false, LogicalDirection.Forward,pageStartFlowPosition)); } else { FixedTextPointer endAsFTP = end as FixedTextPointer; Debug.Assert(endAsFTP != null); firstSearchPageStart = new FixedTextPointer(false, LogicalDirection.Forward, endAsFTP.FixedTextContainer.FixedTextBuilder.GetPageStartFlowPosition(pageNumber)); } firstSearchPageEnd = end; } else { //The page in question is the first page //Need to search between the start pointer and the end of the first page DocumentSequenceTextPointer startAsDSTP = start as DocumentSequenceTextPointer; if (startAsDSTP != null) { FlowPosition pageEndFlowPosition = ((FixedTextContainer)startAsDSTP.ChildBlock.ChildContainer).FixedTextBuilder.GetPageEndFlowPosition(pageNumber); firstSearchPageEnd = new DocumentSequenceTextPointer( startAsDSTP.ChildBlock, new FixedTextPointer(false, LogicalDirection.Backward, pageEndFlowPosition)); } else { FixedTextPointer startAsFTP = start as FixedTextPointer; Debug.Assert(startAsFTP != null); firstSearchPageEnd = new FixedTextPointer(false, LogicalDirection.Backward, startAsFTP.FixedTextContainer.FixedTextBuilder.GetPageEndFlowPosition(pageNumber)); } firstSearchPageStart = start; } }
/// <summary> /// <see cref="TextViewBase.GetTightBoundingGeometryFromTextPositions"/> /// </summary> internal override Geometry GetTightBoundingGeometryFromTextPositions(ITextPointer startPosition, ITextPointer endPosition) { if (startPosition != null && endPosition != null && ChildTextView != null) { DocumentSequenceTextPointer startTp = null; DocumentSequenceTextPointer endTp = null; startTp = _docPage.FixedDocumentSequence.TextContainer.VerifyPosition(startPosition); endTp = _docPage.FixedDocumentSequence.TextContainer.VerifyPosition(endPosition); if (startTp != null && endTp != null) { return(ChildTextView.GetTightBoundingGeometryFromTextPositions(startTp.ChildPointer, endTp.ChildPointer)); } } return(new PathGeometry());; }
/// <summary> /// Returns the paragraphs for the appropriate cell, given a point /// </summary> /// <param name="position">Position of cell.</param> /// <returns> /// Array of paragraph results /// </returns> internal ReadOnlyCollection<ParagraphResult> GetParagraphsFromPosition(ITextPointer position) { CellParaClient cpc = GetCellParaClientFromPosition(position); List<ParagraphResult> listResults = new List<ParagraphResult>(0); if(cpc != null) { listResults.Add(cpc.CreateParagraphResult()); } return new ReadOnlyCollection<ParagraphResult>(listResults); }
/// <summary> /// Provides a collection of glyph properties corresponding to runs /// of Unicode code points. /// </summary> /// <param name="start"> /// A position preceding the first code point to examine. /// </param> /// <param name="end"> /// A position following the last code point to examine. /// </param> /// <returns> /// A collection of glyph property runs. /// </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> /// <remarks> /// A "glyph" in this context is the lowest level rendered representation /// of text. Each entry in the output array describes a constant run of /// properties on the glyphs corresponding to a range of Unicode code points. /// With this array, it's possible to enumerate the glpyh properties for /// each code point in the specified text run. /// </remarks> internal override ReadOnlyCollection <GlyphRun> GetGlyphRuns(ITextPointer start, ITextPointer end) { throw new NotImplementedException(); }
internal CellParaClient GetCellParaClientFromPosition(ITextPointer position) { Debug.Assert( TableParagraph.Table != null && CalculatedColumns != null ); PTS.FSTABLEROWDESCRIPTION[] arrayTableRowDesc; PTS.FSKUPDATE fskupdTable; PTS.FSRECT rectTable; if (QueryTableDetails(out arrayTableRowDesc, out fskupdTable, out rectTable)) { for (int iR = 0; iR < arrayTableRowDesc.Length; ++iR) { PTS.FSKUPDATE[] arrayUpdate; IntPtr[] arrayFsCell; PTS.FSTABLEKCELLMERGE[] arrayTableCellMerge; QueryRowDetails( arrayTableRowDesc[iR].pfstablerow, out arrayFsCell, out arrayUpdate, out arrayTableCellMerge); for (int iC = 0; iC < arrayFsCell.Length; ++iC) { if (arrayFsCell[iC] == IntPtr.Zero) { // paginated case - cell may be null continue; } CellParaClient cpc = (CellParaClient)(PtsContext.HandleToObject(arrayFsCell[iC])); if(position.CompareTo(cpc.Cell.ContentStart) >= 0 && position.CompareTo(cpc.Cell.ContentEnd) <= 0) { return cpc; } } } } return (null); }
// Token: 0x06007C9B RID: 31899 RVA: 0x00230C80 File Offset: 0x0022EE80 private void ProcessOverlapingSegments(IHighlightRange highlightRange, out ITextPointer invalidateStart, out ITextPointer invalidateEnd) { ReadOnlyCollection <TextSegment> textSegments = highlightRange.Range.TextSegments; invalidateStart = null; invalidateEnd = null; int num = 0; IEnumerator <TextSegment> enumerator = textSegments.GetEnumerator(); TextSegment textSegment = enumerator.MoveNext() ? enumerator.Current : TextSegment.Null; while (num < this._segments.Count && !textSegment.IsNull) { AnnotationHighlightLayer.HighlightSegment highlightSegment = this._segments[num]; if (highlightSegment.Segment.Start.CompareTo(textSegment.Start) <= 0) { if (highlightSegment.Segment.End.CompareTo(textSegment.Start) > 0) { IList <AnnotationHighlightLayer.HighlightSegment> list = highlightSegment.Split(textSegment.Start, textSegment.End, highlightRange); if (!list.Contains(highlightSegment)) { highlightSegment.ClearOwners(); } this._segments.Remove(highlightSegment); this._segments.InsertRange(num, list); num = num + list.Count - 1; if (textSegment.End.CompareTo(highlightSegment.Segment.End) <= 0) { textSegment = (enumerator.MoveNext() ? enumerator.Current : TextSegment.Null); } else { textSegment = new TextSegment(highlightSegment.Segment.End, textSegment.End); } if (invalidateStart == null) { invalidateStart = highlightSegment.Segment.Start; } } else { num++; } } else { if (invalidateStart == null) { invalidateStart = textSegment.Start; } if (textSegment.End.CompareTo(highlightSegment.Segment.Start) > 0) { AnnotationHighlightLayer.HighlightSegment item = new AnnotationHighlightLayer.HighlightSegment(textSegment.Start, highlightSegment.Segment.Start, highlightRange); this._segments.Insert(num++, item); textSegment = new TextSegment(highlightSegment.Segment.Start, textSegment.End); } else { this._segments.Insert(num++, new AnnotationHighlightLayer.HighlightSegment(textSegment.Start, textSegment.End, highlightRange)); textSegment = (enumerator.MoveNext() ? enumerator.Current : TextSegment.Null); } } } if (!textSegment.IsNull) { if (invalidateStart == null) { invalidateStart = textSegment.Start; } this._segments.Insert(num++, new AnnotationHighlightLayer.HighlightSegment(textSegment.Start, textSegment.End, highlightRange)); } while (enumerator.MoveNext()) { List <AnnotationHighlightLayer.HighlightSegment> segments = this._segments; int index = num++; TextSegment textSegment2 = enumerator.Current; ITextPointer start = textSegment2.Start; textSegment2 = enumerator.Current; segments.Insert(index, new AnnotationHighlightLayer.HighlightSegment(start, textSegment2.End, highlightRange)); } if (invalidateStart != null) { if (num == this._segments.Count) { num--; } invalidateEnd = this._segments[num].Segment.End; } }