Created
May 2, 2011 23:29
-
-
Save kg/952566 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class TooltipContentBase { | |
public Font Font; | |
public Point Location; | |
public Size Size; | |
public abstract void Render (Graphics g); | |
public abstract Size Measure (Graphics g); | |
} | |
public class DeltaInfoTooltipContent : TooltipContentBase { | |
public readonly DeltaInfo Delta; | |
public DeltaInfo.RenderParams RenderParams; | |
public DeltaInfoTooltipContent (DeltaInfo delta, DeltaInfo.RenderParams renderParams) { | |
Delta = delta; | |
RenderParams = renderParams; | |
} | |
public override void Render (Graphics g) { | |
RenderParams.ContentRegion = new Rectangle( | |
0, 0, Size.Width, Size.Height | |
); | |
RenderParams.Font = Font; | |
Delta.Render(g, ref RenderParams); | |
} | |
public override Size Measure (Graphics g) { | |
var sf = RenderParams.StringFormat; | |
var width = (int)Math.Ceiling(g.MeasureString(Delta.ToString(true), Font, 99999, sf).Width); | |
var lineHeight = g.MeasureString("AaBbYyZz", Font, width, sf).Height; | |
return new Size( | |
width, (int)Math.Ceiling(lineHeight * (Delta.Traceback.Frames.Count + 1)) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment