Advertisement
Illania

DrawContent

Feb 16th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.36 KB | None | 0 0
  1.  public class MessageBubbleEditPainter : RichTextEditPainter
  2.     {
  3.  
  4.  
  5.         protected override void DrawContent(ControlGraphicsInfoArgs info)
  6.         {
  7.             var darkBlueColor = Color.FromArgb(18, 61, 87);
  8.             var blueBrush = new SolidBrush(darkBlueColor);
  9.             var bluePen = new Pen(darkBlueColor);
  10.             var backColor = info.ViewInfo.Appearance.GetBackColor();
  11.             if (backColor == Color.Empty) backColor = Color.White;
  12.             if (info.ViewInfo is MessageBubbleEditViewInfo vi)
  13.             {
  14.                 vi.FillBackground = true;
  15.                 info.ViewInfo.PaintAppearance.BackColor = darkBlueColor;
  16.                 info.ViewInfo.PaintAppearance.ForeColor = Color.White;
  17.                 Brush brush = new SolidBrush(backColor);
  18.                 info.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
  19.                 info.Graphics.FillRectangle(brush, info.Bounds);
  20.                 var rect = vi.ClientRect;
  21.                 rect.Inflate(4, 4);
  22.                 info.Graphics.DrawRectangle(bluePen, rect);
  23.                 info.Graphics.FillRectangle(blueBrush, rect);
  24.  
  25.                 var bubbleTail = PlacementHelper.AlignTriangleToRectangle(rect, ContentAlignment.MiddleLeft, 3, 6);
  26.                 info.Graphics.FillPolygon(blueBrush, bubbleTail);
  27.             }
  28.             base.DrawContent(info);
  29.         }
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement