private static void RunTest(TextSelectionPoint tsp, int[] indexes, WhitespaceHandling ws, bool reverse) { if (reverse) { Array.Reverse(indexes); } Console.WriteLine("Running movement tests for {0}, ws={1}, reverse={2}", tsp, ws, reverse); TextSelectionHelper tsh = new TextSelectionHelper(tsp, ws); int n = 0; while (tsp != null) { Console.WriteLine("Scanning: '{0}' (={1})", tsp.Char, (int)tsp.Char); Assert.IsTrue(n < indexes.Length, "Too many iterations, expected {0}", indexes.Length); Assert.IsTrue(indexes[n] == tsp.Index, "Wrong value at iteration {0} (expected {1}, got {2}", n, indexes[n], tsp.Index); if (reverse) { tsp = tsh.Previous; } else { tsp = tsh.Next; } n++; } }
// Token: 0x06007CED RID: 31981 RVA: 0x0023255C File Offset: 0x0023075C private static FlowDirection GetTextFlowDirection(ITextPointer pointer) { Invariant.Assert(pointer != null, "Null pointer passed."); Invariant.Assert(pointer.IsAtInsertionPosition, "Pointer is not an insertion position"); int num = 0; LogicalDirection logicalDirection = pointer.LogicalDirection; TextPointerContext pointerContext = pointer.GetPointerContext(logicalDirection); FlowDirection result; if ((pointerContext == TextPointerContext.ElementEnd || pointerContext == TextPointerContext.ElementStart) && !TextSchema.IsFormattingType(pointer.ParentType)) { result = (FlowDirection)pointer.GetValue(FrameworkElement.FlowDirectionProperty); } else { Rect anchorRectangle = TextSelectionHelper.GetAnchorRectangle(pointer); ITextPointer textPointer = pointer.GetNextInsertionPosition(logicalDirection); if (textPointer != null) { textPointer = textPointer.CreatePointer((logicalDirection == LogicalDirection.Backward) ? LogicalDirection.Forward : LogicalDirection.Backward); if (logicalDirection == LogicalDirection.Forward) { if (pointerContext == TextPointerContext.ElementEnd && textPointer.GetPointerContext(textPointer.LogicalDirection) == TextPointerContext.ElementStart) { return((FlowDirection)pointer.GetValue(FrameworkElement.FlowDirectionProperty)); } } else if (pointerContext == TextPointerContext.ElementStart && textPointer.GetPointerContext(textPointer.LogicalDirection) == TextPointerContext.ElementEnd) { return((FlowDirection)pointer.GetValue(FrameworkElement.FlowDirectionProperty)); } Rect anchorRectangle2 = TextSelectionHelper.GetAnchorRectangle(textPointer); if (anchorRectangle2 != Rect.Empty && anchorRectangle != Rect.Empty) { num = Math.Sign(anchorRectangle2.Left - anchorRectangle.Left); if (logicalDirection == LogicalDirection.Backward) { num = -num; } } } if (num == 0) { result = (FlowDirection)pointer.GetValue(FrameworkElement.FlowDirectionProperty); } else { result = ((num > 0) ? FlowDirection.LeftToRight : FlowDirection.RightToLeft); } } return(result); }
// Token: 0x06008E59 RID: 36441 RVA: 0x0025BD90 File Offset: 0x00259F90 private void GetSegmentGeometry(GeometryGroup geometry, TextSegment segment, ITextView parentView) { List <ITextView> documentPageTextViews = TextSelectionHelper.GetDocumentPageTextViews(segment); foreach (ITextView view in documentPageTextViews) { Geometry pageGeometry = this.GetPageGeometry(segment, view, parentView); if (pageGeometry != null) { geometry.Children.Add(pageGeometry); } } }
// Token: 0x060062D1 RID: 25297 RVA: 0x001BB730 File Offset: 0x001B9930 private static IList <IAttachedAnnotation> GetSpannedAnnotations(AnnotationService service) { AnnotationHelper.CheckInputs(service); bool flag = true; DocumentViewerBase documentViewerBase = service.Root as DocumentViewerBase; if (documentViewerBase == null) { FlowDocumentReader flowDocumentReader = service.Root as FlowDocumentReader; if (flowDocumentReader != null) { documentViewerBase = (AnnotationHelper.GetFdrHost(flowDocumentReader) as DocumentViewerBase); } } else { flag = (documentViewerBase.Document is FlowDocument); } bool flag2 = true; ITextSelection textSelection = AnnotationHelper.GetTextSelection((FrameworkElement)service.Root); Invariant.Assert(textSelection != null, "TextSelection is null"); int num = 0; int num2 = 0; if (documentViewerBase != null) { TextSelectionHelper.GetPointerPage(textSelection.Start, out num); TextSelectionHelper.GetPointerPage(textSelection.End, out num2); if (num == -1 || num2 == -1) { throw new ArgumentException(SR.Get("InvalidSelectionPages")); } flag2 = AnnotationHelper.AreAllPagesVisible(documentViewerBase, num, num2); } IList <IAttachedAnnotation> list; if (flag2) { list = service.GetAttachedAnnotations(); } else if (flag) { list = AnnotationHelper.GetSpannedAnnotationsForFlow(service, textSelection); } else { list = AnnotationHelper.GetSpannedAnnotationsForFixed(service, num, num2); } IList <TextSegment> textSegments = textSelection.TextSegments; if (list != null && list.Count > 0 && (flag2 || !flag)) { for (int i = list.Count - 1; i >= 0; i--) { TextAnchor textAnchor = list[i].AttachedAnchor as TextAnchor; if (textAnchor == null || !textAnchor.IsOverlapping(textSegments)) { list.RemoveAt(i); } } } return(list); }
// Token: 0x06007CDD RID: 31965 RVA: 0x00231C6C File Offset: 0x0022FE6C private void SetMarkerTransform(Path marker, ITextPointer anchor, ITextPointer baseAnchor, int xScaleFactor) { if (marker == null) { return; } GeometryGroup geometryGroup = marker.Data as GeometryGroup; Rect anchorRectangle = TextSelectionHelper.GetAnchorRectangle(anchor); if (anchorRectangle == Rect.Empty) { return; } double num = anchorRectangle.Height - MarkedHighlightComponent.MarkerVerticalSpace - this._bottomTailHeight - this._topTailHeight; double scaleY = 0.0; double scaleY2 = 0.0; if (num > 0.0) { scaleY = num / this._bodyHeight; scaleY2 = 1.0; } ScaleTransform value = new ScaleTransform(1.0, scaleY); TranslateTransform value2 = new TranslateTransform(anchorRectangle.X, anchorRectangle.Y + this._topTailHeight + MarkedHighlightComponent.MarkerVerticalSpace); TransformGroup transformGroup = new TransformGroup(); transformGroup.Children.Add(value); transformGroup.Children.Add(value2); ScaleTransform value3 = new ScaleTransform((double)xScaleFactor, scaleY2); TranslateTransform value4 = new TranslateTransform(anchorRectangle.X, anchorRectangle.Bottom - this._bottomTailHeight); TranslateTransform value5 = new TranslateTransform(anchorRectangle.X, anchorRectangle.Top + MarkedHighlightComponent.MarkerVerticalSpace); TransformGroup transformGroup2 = new TransformGroup(); transformGroup2.Children.Add(value3); transformGroup2.Children.Add(value4); TransformGroup transformGroup3 = new TransformGroup(); transformGroup3.Children.Add(value3); transformGroup3.Children.Add(value5); if (geometryGroup.Children[0] != null) { geometryGroup.Children[0].Transform = transformGroup3; } if (geometryGroup.Children[1] != null) { geometryGroup.Children[1].Transform = transformGroup; } if (geometryGroup.Children[2] != null) { geometryGroup.Children[2].Transform = transformGroup2; } if (baseAnchor != null) { ITextView documentPageTextView = TextSelectionHelper.GetDocumentPageTextView(baseAnchor); ITextView documentPageTextView2 = TextSelectionHelper.GetDocumentPageTextView(anchor); if (documentPageTextView != documentPageTextView2 && documentPageTextView.RenderScope != null && documentPageTextView2.RenderScope != null) { geometryGroup.Transform = (Transform)documentPageTextView2.RenderScope.TransformToVisual(documentPageTextView.RenderScope); } } }