Created
June 19, 2013 11:10
-
-
Save jongalloway/5813528 to your computer and use it in GitHub Desktop.
Micro Framework Emulator - Updated Paint method with scaling
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
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