//-------------------------------------------------------------------- // // Public Methods // //--------------------------------------------------------------------- #region Public Methods /// <summary> /// Compares 2 FixedHighlight /// </summary> /// <param name="oCompare">the FixedHighlight to compare with</param> /// <returns>true if this FixedHighlight is on the same element with the same offset, and brush</returns> override public bool Equals(object oCompare) { FixedHighlight fh = oCompare as FixedHighlight; if (fh == null) { return(false); } return((fh._element == _element) && (fh._gBeginOffset == _gBeginOffset) && (fh._gEndOffset == _gEndOffset) && (fh._type == _type)); }
// Token: 0x0600301A RID: 12314 RVA: 0x000D8690 File Offset: 0x000D6890 private void _UpdateHighlightForeground(DrawingContext dc, ArrayList highlights) { foreach (object obj in highlights) { FixedHighlight fixedHighlight = (FixedHighlight)obj; Brush brush = null; if (fixedHighlight.HighlightType != FixedHighlightType.None) { Glyphs glyphs = fixedHighlight.Glyphs; if (glyphs != null) { Rect rect = fixedHighlight.ComputeDesignRect(); if (!(rect == Rect.Empty)) { GeneralTransform generalTransform = fixedHighlight.Element.TransformToAncestor(this._page); Transform affineTransform = generalTransform.AffineTransform; if (affineTransform != null) { dc.PushTransform(affineTransform); } else { dc.PushTransform(Transform.Identity); } dc.PushClip(new RectangleGeometry(rect)); if (fixedHighlight.HighlightType == FixedHighlightType.TextSelection) { brush = SelectionHighlightInfo.ForegroundBrush; } else if (fixedHighlight.HighlightType == FixedHighlightType.AnnotationHighlight) { brush = fixedHighlight.ForegroundBrush; } GlyphRun glyphRun = glyphs.ToGlyphRun(); if (brush == null) { brush = glyphs.Fill; } dc.PushGuidelineY1(glyphRun.BaselineOrigin.Y); dc.PushClip(glyphs.Clip); dc.DrawGlyphRun(brush, glyphRun); dc.Pop(); dc.Pop(); dc.Pop(); dc.Pop(); } } } } }
// Token: 0x06002EE0 RID: 12000 RVA: 0x000D382C File Offset: 0x000D1A2C internal override Geometry GetTightBoundingGeometryFromTextPositions(ITextPointer startPosition, ITextPointer endPosition) { PathGeometry pathGeometry = new PathGeometry(); Dictionary <FixedPage, ArrayList> dictionary = new Dictionary <FixedPage, ArrayList>(); FixedTextPointer start = this.Container.VerifyPosition(startPosition); FixedTextPointer end = this.Container.VerifyPosition(endPosition); this.Container.GetMultiHighlights(start, end, dictionary, FixedHighlightType.TextSelection, null, null); ArrayList arrayList; dictionary.TryGetValue(this.FixedPage, out arrayList); if (arrayList != null) { foreach (object obj in arrayList) { FixedHighlight fixedHighlight = (FixedHighlight)obj; if (fixedHighlight.HighlightType != FixedHighlightType.None) { Rect rect = fixedHighlight.ComputeDesignRect(); if (!(rect == Rect.Empty)) { GeneralTransform generalTransform = fixedHighlight.Element.TransformToAncestor(this.FixedPage); Transform transform = generalTransform.AffineTransform; if (transform == null) { transform = Transform.Identity; } Glyphs glyphs = fixedHighlight.Glyphs; if (fixedHighlight.Element.Clip != null) { Rect bounds = fixedHighlight.Element.Clip.Bounds; rect.Intersect(bounds); } Geometry geometry = new RectangleGeometry(rect); geometry.Transform = transform; rect = generalTransform.TransformBounds(rect); pathGeometry.AddGeometry(geometry); } } } } return(pathGeometry); }
// Get the highlights, in Glyphs granularity, that covers this range internal void GetMultiHighlights(FixedTextPointer start, FixedTextPointer end, Dictionary<FixedPage, ArrayList> highlights, FixedHighlightType t, Brush foregroundBrush, Brush backgroundBrush) { Debug.Assert(highlights != null); if (start.CompareTo(end) > 0) { // make sure start <= end FixedTextPointer temp = start; start = end; end = temp; } FixedSOMElement[] elements; //Start and end indices in selection for first and last FixedSOMElements respectively int startIndex = 0; int endIndex = 0; if (_GetFixedNodesForFlowRange(start, end, out elements, out startIndex, out endIndex)) { for(int i=0; i<elements.Length; i++) { FixedSOMElement elem = elements[i]; FixedNode fn = elem.FixedNode; // Get the FixedPage if possible FixedPage page = this.FixedDocument.SyncGetPageWithCheck(fn.Page); if (page == null) { continue; } DependencyObject o = page.GetElement(fn); if (o == null) { continue; } int beginOffset = 0; int endOffset; UIElement e; if (o is Image || o is Path) { e = (UIElement)o; endOffset = 1; } else { Glyphs g = o as Glyphs; if (g == null) { continue; } e = (UIElement)o; beginOffset = elem.StartIndex; endOffset = elem.EndIndex; } if (i == 0) { beginOffset = startIndex; } if (i == elements.Length - 1) { endOffset = endIndex; } ArrayList lfs; if (highlights.ContainsKey(page)) { lfs = highlights[page]; } else { lfs = new ArrayList(); highlights.Add(page, lfs); } FixedSOMTextRun textRun = elem as FixedSOMTextRun; if (textRun != null && textRun.IsReversed) { int oldBeginOffset = beginOffset; beginOffset = elem.EndIndex - endOffset; endOffset = elem.EndIndex - oldBeginOffset; } FixedHighlight fh = new FixedHighlight(e, beginOffset, endOffset, t, foregroundBrush, backgroundBrush); lfs.Add(fh); } } }
// Token: 0x06002EA1 RID: 11937 RVA: 0x000D2BCC File Offset: 0x000D0DCC internal void GetMultiHighlights(FixedTextPointer start, FixedTextPointer end, Dictionary <FixedPage, ArrayList> highlights, FixedHighlightType t, Brush foregroundBrush, Brush backgroundBrush) { if (start.CompareTo(end) > 0) { FixedTextPointer fixedTextPointer = start; start = end; end = fixedTextPointer; } int num = 0; int num2 = 0; FixedSOMElement[] array; if (this._GetFixedNodesForFlowRange(start, end, out array, out num, out num2)) { for (int i = 0; i < array.Length; i++) { FixedSOMElement fixedSOMElement = array[i]; FixedNode fixedNode = fixedSOMElement.FixedNode; FixedPage fixedPage = this.FixedDocument.SyncGetPageWithCheck(fixedNode.Page); if (fixedPage != null) { DependencyObject element = fixedPage.GetElement(fixedNode); if (element != null) { int num3 = 0; UIElement element2; int num4; if (element is Image || element is Path) { element2 = (UIElement)element; num4 = 1; } else { Glyphs glyphs = element as Glyphs; if (glyphs == null) { goto IL_144; } element2 = (UIElement)element; num3 = fixedSOMElement.StartIndex; num4 = fixedSOMElement.EndIndex; } if (i == 0) { num3 = num; } if (i == array.Length - 1) { num4 = num2; } ArrayList arrayList; if (highlights.ContainsKey(fixedPage)) { arrayList = highlights[fixedPage]; } else { arrayList = new ArrayList(); highlights.Add(fixedPage, arrayList); } FixedSOMTextRun fixedSOMTextRun = fixedSOMElement as FixedSOMTextRun; if (fixedSOMTextRun != null && fixedSOMTextRun.IsReversed) { int num5 = num3; num3 = fixedSOMElement.EndIndex - num4; num4 = fixedSOMElement.EndIndex - num5; } FixedHighlight value = new FixedHighlight(element2, num3, num4, t, foregroundBrush, backgroundBrush); arrayList.Add(value); } } IL_144 :; } } }
// Get the highlights, in Glyphs granularity, that covers this range internal void GetMultiHighlights(FixedTextPointer start, FixedTextPointer end, Dictionary <FixedPage, ArrayList> highlights, FixedHighlightType t, Brush foregroundBrush, Brush backgroundBrush) { Debug.Assert(highlights != null); if (start.CompareTo(end) > 0) { // make sure start <= end FixedTextPointer temp = start; start = end; end = temp; } FixedSOMElement[] elements; //Start and end indices in selection for first and last FixedSOMElements respectively int startIndex = 0; int endIndex = 0; if (_GetFixedNodesForFlowRange(start, end, out elements, out startIndex, out endIndex)) { for (int i = 0; i < elements.Length; i++) { FixedSOMElement elem = elements[i]; FixedNode fn = elem.FixedNode; // Get the FixedPage if possible FixedPage page = this.FixedDocument.SyncGetPageWithCheck(fn.Page); if (page == null) { continue; } DependencyObject o = page.GetElement(fn); if (o == null) { continue; } int beginOffset = 0; int endOffset; UIElement e; if (o is Image || o is Path) { e = (UIElement)o; endOffset = 1; } else { Glyphs g = o as Glyphs; if (g == null) { continue; } e = (UIElement)o; beginOffset = elem.StartIndex; endOffset = elem.EndIndex; } if (i == 0) { beginOffset = startIndex; } if (i == elements.Length - 1) { endOffset = endIndex; } ArrayList lfs; if (highlights.ContainsKey(page)) { lfs = highlights[page]; } else { lfs = new ArrayList(); highlights.Add(page, lfs); } FixedSOMTextRun textRun = elem as FixedSOMTextRun; if (textRun != null && textRun.IsReversed) { int oldBeginOffset = beginOffset; beginOffset = elem.EndIndex - endOffset; endOffset = elem.EndIndex - oldBeginOffset; } FixedHighlight fh = new FixedHighlight(e, beginOffset, endOffset, t, foregroundBrush, backgroundBrush); lfs.Add(fh); } } }
// Token: 0x06002D39 RID: 11577 RVA: 0x000CC2E8 File Offset: 0x000CA4E8 public override bool Equals(object oCompare) { FixedHighlight fixedHighlight = oCompare as FixedHighlight; return fixedHighlight != null && (fixedHighlight._element == this._element && fixedHighlight._gBeginOffset == this._gBeginOffset && fixedHighlight._gEndOffset == this._gEndOffset) && fixedHighlight._type == this._type; }
// Token: 0x06003019 RID: 12313 RVA: 0x000D8494 File Offset: 0x000D6694 private void _UpdateHighlightBackground(DrawingContext dc, ArrayList highlights) { PathGeometry pathGeometry = null; Brush brush = null; Rect rect = Rect.Empty; foreach (object obj in highlights) { FixedHighlight fixedHighlight = (FixedHighlight)obj; Brush brush2 = null; if (fixedHighlight.HighlightType != FixedHighlightType.None) { Rect rect2 = fixedHighlight.ComputeDesignRect(); if (!(rect2 == Rect.Empty)) { GeneralTransform generalTransform = fixedHighlight.Element.TransformToAncestor(this._page); Transform transform = generalTransform.AffineTransform; if (transform == null) { transform = Transform.Identity; } Glyphs glyphs = fixedHighlight.Glyphs; if (fixedHighlight.HighlightType == FixedHighlightType.TextSelection) { brush2 = ((glyphs == null) ? SelectionHighlightInfo.ObjectMaskBrush : SelectionHighlightInfo.BackgroundBrush); } else if (fixedHighlight.HighlightType == FixedHighlightType.AnnotationHighlight) { brush2 = fixedHighlight.BackgroundBrush; } if (fixedHighlight.Element.Clip != null) { Rect bounds = fixedHighlight.Element.Clip.Bounds; rect2.Intersect(bounds); } Geometry geometry = new RectangleGeometry(rect2); geometry.Transform = transform; rect2 = generalTransform.TransformBounds(rect2); if (brush2 != brush || rect2.Top > rect.Bottom + 0.1 || rect2.Bottom + 0.1 < rect.Top || rect2.Left > rect.Right + 0.1 || rect2.Right + 0.1 < rect.Left) { if (brush != null) { pathGeometry.FillRule = FillRule.Nonzero; dc.DrawGeometry(brush, null, pathGeometry); } brush = brush2; pathGeometry = new PathGeometry(); pathGeometry.AddGeometry(geometry); rect = rect2; } else { pathGeometry.AddGeometry(geometry); rect.Union(rect2); } } } } if (brush != null) { pathGeometry.FillRule = FillRule.Nonzero; dc.DrawGeometry(brush, null, pathGeometry); } }