/// <summary> /// Paints the fragment /// </summary> /// <param name="g">the device to draw to</param> protected override void PaintImp(RGraphics g) { var offset = (this.HtmlContainer != null && !this.IsFixed) ? this.HtmlContainer.ScrollOffset : RPoint.Empty; var rect = new RRect(this.Bounds.X + offset.X, this.Bounds.Y + offset.Y, this.Bounds.Width, this.Bounds.Height); if (rect.Height > 2 && RenderUtils.IsColorVisible(this.ActualBackgroundColor)) { g.DrawRectangle(g.GetSolidBrush(this.ActualBackgroundColor), rect.X, rect.Y, rect.Width, rect.Height); } var b1 = g.GetSolidBrush(this.ActualBorderTopColor); BordersDrawHandler.DrawBorder(Border.Top, g, this, b1, rect); if (rect.Height > 1) { var b2 = g.GetSolidBrush(this.ActualBorderLeftColor); BordersDrawHandler.DrawBorder(Border.Left, g, this, b2, rect); var b3 = g.GetSolidBrush(this.ActualBorderRightColor); BordersDrawHandler.DrawBorder(Border.Right, g, this, b3, rect); var b4 = g.GetSolidBrush(this.ActualBorderBottomColor); BordersDrawHandler.DrawBorder(Border.Bottom, g, this, b4, rect); } }
/// <summary> /// Draw specific border (top/bottom/left/right) with the box data (style/width/rounded).<br/> /// </summary> /// <param name="border">desired border to draw</param> /// <param name="box">the box to draw its borders, contain the borders data</param> /// <param name="g">the device to draw into</param> /// <param name="rect">the rectangle the border is enclosing</param> /// <param name="isLineStart">Specifies if the border is for a starting line (no bevel on left)</param> /// <param name="isLineEnd">Specifies if the border is for an ending line (no bevel on right)</param> private static void DrawBorder(Border border, CssBox box, RGraphics g, RRect rect, bool isLineStart, bool isLineEnd) { var style = GetStyle(border, box); var color = GetColor(border, box, style); var borderPath = GetRoundedBorderPath(g, border, box, rect); if (borderPath != null) { // rounded border need special path Object prevMode = null; if (box.HtmlContainer != null && !box.HtmlContainer.AvoidGeometryAntialias && box.IsRounded) { prevMode = g.SetAntiAliasSmoothingMode(); } var pen = GetPen(g, style, color, GetWidth(border, box)); using (borderPath) g.DrawPath(pen, borderPath); g.ReturnPreviousSmoothingMode(prevMode); } else { // non rounded border if (style == CssConstants.Inset || style == CssConstants.Outset) { // inset/outset border needs special rectangle SetInOutsetRectanglePoints(border, box, rect, isLineStart, isLineEnd); g.DrawPolygon(g.GetSolidBrush(color), _borderPts); } else { // solid/dotted/dashed border draw as simple line var pen = GetPen(g, style, color, GetWidth(border, box)); switch (border) { case Border.Top: g.DrawLine(pen, Math.Ceiling(rect.Left), rect.Top + box.ActualBorderTopWidth / 2, rect.Right - 1, rect.Top + box.ActualBorderTopWidth / 2); break; case Border.Left: g.DrawLine(pen, rect.Left + box.ActualBorderLeftWidth / 2, Math.Ceiling(rect.Top), rect.Left + box.ActualBorderLeftWidth / 2, Math.Floor(rect.Bottom)); break; case Border.Bottom: g.DrawLine(pen, Math.Ceiling(rect.Left), rect.Bottom - box.ActualBorderBottomWidth / 2, rect.Right - 1, rect.Bottom - box.ActualBorderBottomWidth / 2); break; case Border.Right: g.DrawLine(pen, rect.Right - box.ActualBorderRightWidth / 2, Math.Ceiling(rect.Top), rect.Right - box.ActualBorderRightWidth / 2, Math.Floor(rect.Bottom)); break; } } } }
/// <summary> /// Draw video title on top of the iframe if found. /// </summary> private void DrawTitle(RGraphics g, RRect rect) { if (_videoTitle != null && _imageWord.Width > 40 && _imageWord.Height > 40) { var font = HtmlContainer.Adapter.GetFont("Arial", 9f, RFontStyle.Regular); g.DrawRectangle(g.GetSolidBrush(RColor.FromArgb(160, 0, 0, 0)), rect.Left, rect.Top, rect.Width, ActualFont.Height + 7); var titleRect = new RRect(rect.Left + 3, rect.Top + 3, rect.Width - 6, rect.Height - 6); g.DrawString(_videoTitle, font, RColor.WhiteSmoke, titleRect.Location, RSize.Empty, false); } }
/// <summary> /// Draw play over the iframe if we found link url. /// </summary> private void DrawPlay(RGraphics g, RRect rect) { if (_isVideo && _imageWord.Width > 70 && _imageWord.Height > 50) { var prevMode = g.SetAntiAliasSmoothingMode(); var size = new RSize(60, 40); var left = rect.Left + (rect.Width - size.Width) / 2; var top = rect.Top + (rect.Height - size.Height) / 2; g.DrawRectangle(g.GetSolidBrush(RColor.FromArgb(160, 0, 0, 0)), left, top, size.Width, size.Height); RPoint[] points = { new RPoint(left + size.Width / 3f + 1, top + 3 * size.Height / 4f), new RPoint(left + size.Width / 3f + 1, top + size.Height / 4f), new RPoint(left + 2 * size.Width / 3f + 1, top + size.Height / 2f) }; g.DrawPolygon(g.GetSolidBrush(RColor.White), points); g.ReturnPreviousSmoothingMode(prevMode); } }