Author: pbartok
Date: 2006-05-18 16:43:20 -0400 (Thu, 18 May 2006)
New Revision: 60835
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
Log:
2006-05-18 Peter Dennis Bartok <[EMAIL PROTECTED]>
* Control.cs: When double-buffering is enabled, we need to reset
our graphics context between paint calls. Otherwise, any
transformations and other alterations on the context will
become cumulative (#77734)
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-05-18 19:39:37 UTC (rev 60834)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-05-18 20:43:20 UTC (rev 60835)
@@ -1,3 +1,10 @@
+2006-05-18 Peter Dennis Bartok <[EMAIL PROTECTED]>
+
+ * Control.cs: When double-buffering is enabled, we need to reset
+ our graphics context between paint calls. Otherwise, any
+ transformations and other alterations on the context will
+ become cumulative (#77734)
+
2006-05-18 Mike Kestner <[EMAIL PROTECTED]>
* ListView.cs: do focused item selection like MS on clicks.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
2006-05-18 19:39:37 UTC (rev 60834)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
2006-05-18 20:43:20 UTC (rev 60835)
@@ -116,6 +116,7 @@
internal ContextMenu context_menu; //
Context menu associated with the control
private Graphics dc_mem; //
Graphics context for double buffering
+ private GraphicsState dc_state; //
Pristine graphics context to reset after paint code alters dc_mem
private Bitmap bmp_mem; //
Bitmap for double buffering control
private bool needs_redraw = true;
@@ -868,13 +869,19 @@
internal Graphics DeviceContext {
get {
- if (dc_mem==null) {
+ if (dc_mem == null) {
CreateBuffers(this.Width, this.Height);
+ dc_state = dc_mem.Save();
}
return dc_mem;
}
}
+ internal void ResetDeviceContext() {
+ dc_mem.Restore(dc_state);
+ dc_state = dc_mem.Save();
+ }
+
private Bitmap ImageBuffer {
get {
if (bmp_mem==null) {
@@ -3814,8 +3821,10 @@
// and here
http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
case Msg.WM_PAINT: {
PaintEventArgs paint_event;
+ bool reset_context;
paint_event =
XplatUI.PaintEventStart(Handle, true);
+ reset_context = false;
if (paint_event == null) {
return;
@@ -3829,10 +3838,12 @@
}
Graphics dc = null;
- if
(ThemeEngine.Current.DoubleBufferingSupported)
+ if
(ThemeEngine.Current.DoubleBufferingSupported) {
if ((control_style &
ControlStyles.DoubleBuffer) != 0) {
dc =
paint_event.SetGraphics (DeviceContext);
+ reset_context = true;
}
+ }
if (!GetStyle(ControlStyles.Opaque)) {
OnPaintBackground(paint_event);
@@ -3855,6 +3866,10 @@
XplatUI.PaintEventEnd(Handle, true);
+ if (reset_context) {
+ ResetDeviceContext();
+ }
+
return;
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches