Guest User

Untitled

a guest
Jan 22nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. var charSizeF = e.Graphics.MeasureString(Text.Substring(0,1), Font);
  2. var textSizeF = e.Graphics.MeasureString(Text, Font);
  3.  
  4. Size = new Size((int)(textSizeF.Width + _textPaddingMultiplierWidth * charSizeF.Width), (int)(charSizeF.Height * _textPaddingMultiplierHeight));
  5.  
  6. var screenLocParent = Parent.PointToScreen(Parent.Location);
  7.  
  8. var screenLocThis = new Point(screenLocParent.X + Parent.ClientRectangle.Width - Size.Width, screenLocParent.Y + _matchingItemOnRight.Location.Y - (Size.Height / 2));
  9.  
  10. Location = Parent.PointToClient(screenLocThis);
  11.  
  12. var crX = ClientRectangle.X;
  13. var crY = ClientRectangle.Y;
  14. var crWidth = ClientRectangle.Width;
  15. var crHeight = ClientRectangle.Height;
  16.  
  17. if (Padding != Padding.Empty)
  18. {
  19. crX += Padding.Left;
  20. crY += Padding.Top;
  21. crWidth -= (Padding.Left + Padding.Right);
  22. crHeight -= (Padding.Top + Padding.Bottom);
  23. }
  24.  
  25. var paintRect = new Rectangle(crX, crY, crWidth, crHeight);
  26.  
  27. e.Graphics.DrawString(
  28. Text,
  29. Font,
  30. new SolidBrush(ForeColor),
  31. paintRect, style);
Add Comment
Please, Sign In to add comment