Skip to content

Instantly share code, notes, and snippets.

@jongalloway
Created June 19, 2013 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jongalloway/5813528 to your computer and use it in GitHub Desktop.
Save jongalloway/5813528 to your computer and use it in GitHub Desktop.
Micro Framework Emulator - Updated Paint method with scaling
protected override void OnPaint(PaintEventArgs e)
{
// Paint the LCD control. Use the contents of the LCD if available;
// otherwise call through to the base class.
if (_bitmap != null)
{
// Synchonize access to the bitmap with the .NET Micro Framework
// thread.
lock (_bitmap)
{
Bitmap scaled = new Bitmap((int)(_bitmap.Width * 1.5), (int)(_bitmap.Height * 1.5));
using (Graphics graphics = Graphics.FromImage(scaled))
{
graphics.DrawImage(_bitmap, new Rectangle(0, 0, scaled.Width, scaled.Height));
}
// Draw the LCD contents.
e.Graphics.DrawImage(scaled, 0, 0);
if (m_currentGesture == TouchGesture.Rotate &&
(flags & (TouchSampleValidFlag | TouchSampleDownFlag)) == (TouchSampleValidFlag | TouchSampleDownFlag))
{
e.Graphics.DrawEllipse(Pens.Red, _lastMouseDownX - c_GestureRotateXOffset, _lastMouseDownY, 3, 3);
}
}
}
else
// We have no private LCD bitmap, because the .NET Micro Framework
// hasn't called OnDevicePaint yet.
{
base.OnPaintBackground(e);
}
if (this.DesignMode)
{
// At design time, paint a dotted outline around the control.
OnPaintDesignMode(e);
}
base.OnPaint(e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment