Skip to content

Instantly share code, notes, and snippets.

@cwensley
Created February 28, 2013 06:39
Show Gist options
  • Save cwensley/5054735 to your computer and use it in GitHub Desktop.
Save cwensley/5054735 to your computer and use it in GitHub Desktop.
class MyImageLabel : Drawable {
Font font = Fonts.Sans (10);
public Image Image { get; set; }
public string Text { get; set; }
public override void OnPaint (PaintEventArgs e)
{
if (Image != null)
e.Graphics.DrawImage (Image, 0, 0);
if (Text != null)
e.Graphics.DrawText (font, Colors.Black, 0, 0, Text);
}
}
public class MyForm : Form
{
public MyForm ()
{
this.ClientSize = new Size (200, 200);
this.AddDockedControl (new MyImageLabel {
Text = "Hello there",
Image = Bitmap.FromResource("Eto.Test.TestImage.png")
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment