Example #1
0
        private static Polygon RenderHighlight(BookmarkModel bookmarkModel, Panel canvas, PageRenderData context)
        {
            int            tokenID = bookmarkModel.TokenID;
            TextRenderData firstHighlightedText = context.Texts.FirstOrDefault(t => t.TokenID == tokenID) ??
                                                  (context.Texts).FirstOrDefault();

            if (firstHighlightedText == null)
            {
                return(null);
            }

            int            endTokenID          = bookmarkModel.EndTokenID;
            TextRenderData lastHighlightedText = context.Texts.LastOrDefault(t => t.TokenID == endTokenID) ??
                                                 (context.Texts).LastOrDefault();

            if (lastHighlightedText == null)
            {
                return(null);
            }

            Rect firtstRect      = firstHighlightedText.Rect;
            Rect lastRect        = lastHighlightedText.Rect;
            var  pointCollection = SelectionHelper.GetSelectionPolygon(
                firtstRect,
                lastRect,
                canvas.ActualWidth,
                context.OffsetX,
                Convert.ToDouble(AppSettings.Default.FontSettings.FontInterval));

            var polygon = new Polygon
            {
                Width  = canvas.ActualWidth,
                Height = canvas.ActualHeight,
                Fill   = new SolidColorBrush(ColorHelper.ToColor(bookmarkModel.Color))
                {
                    Opacity = 0.3
                },
                Points     = pointCollection,
                Visibility = Visibility.Visible
            };

            return(polygon);
        }
 private static PointCollection GetSelectionPolygon(Rect a, Rect b, double width)
 {
     return(SelectionHelper.GetSelectionPolygon(a, b, width, OffsetX,
                                                Convert.ToDouble(AppSettings.Default.FontSettings.FontInterval)));
 }