* PrintPreviewControl.cs: Remove extraneous Invalidate calls. Separate
authorAndreia Gaita <avidigal@novell.com>
Sun, 15 Jul 2007 20:21:07 +0000 (20:21 -0000)
committerAndreia Gaita <avidigal@novell.com>
Sun, 15 Jul 2007 20:21:07 +0000 (20:21 -0000)
full preview invalidation from layout invalidation, and only invalidate
the layout when setting zoom or other properties. Invalidation should
always be done even when resetting properties with the same values as
what is there. Fixes #81744 and #79830.

2007-07-15  Andreia Gaita <avidigal@novell.com>

svn path=/trunk/mcs/; revision=82016

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/PrintPreviewControl.cs

index c49441c77bfbe552877d2190393e8c4270001181..cd3dfd9eede3036b9e5521840b7f845def8e4be0 100644 (file)
@@ -1,3 +1,11 @@
+2007-07-15  Andreia Gaita <avidigal@novell.com>
+
+       * PrintPreviewControl.cs: Remove extraneous Invalidate calls. Separate
+       full preview invalidation from layout invalidation, and only invalidate
+       the layout when setting zoom or other properties. Invalidation should
+       always be done even when resetting properties with the same values as
+       what is there. Fixes #81744 and #79830.
+
 2007-07-15  Carlos Alberto Cortez <calberto.cortez@gmail.com>
 
        * ListView.cs: Implement initial support for Groups. Split some of the
index 0740089b607e81a01f17d8266bc312ae4c1b97a4..675bda93d743d19837ec9b823910d2ff93f0134a 100644 (file)
@@ -92,23 +92,16 @@ namespace System.Windows.Forms {
                public bool AutoZoom {
                        get { return autozoom; }
                        set {
-                               if (autozoom != value) {
-                                       InvalidatePreview ();
-                                       Invalidate ();
-                               }
                                autozoom = value;
+                               InvalidateLayout ();
                        }
                }
                [DefaultValue(1)]
                public int Columns {
                        get { return columns; }
                        set {
-                               if (columns != value) {
-                                       columns = value;
-                                       if (AutoZoom)
-                                               InvalidatePreview ();
-                                       Invalidate ();
-                               }
+                               columns = value;
+                               InvalidateLayout ();
                        }
                }
                [DefaultValue(null)]
@@ -132,12 +125,8 @@ namespace System.Windows.Forms {
                public int Rows {
                        get { return rows; }
                        set {
-                               if (rows != value) {
-                                       rows = value;
-                                       if (AutoZoom)
-                                               InvalidatePreview ();
-                                       Invalidate ();
-                               }
+                               rows = value;
+                               InvalidateLayout ();
                        }
                }
                [DefaultValue(0)]
@@ -152,10 +141,12 @@ namespace System.Windows.Forms {
                                                value = 1;
                                }
 
-                               if (startPage != value)
-                                       Invalidate ();
+                               int start = StartPage;
                                startPage = value;
-                               OnStartPageChanged (EventArgs.Empty);
+                               if (start != startPage) {
+                                       InvalidateLayout ();
+                                       OnStartPageChanged (EventArgs.Empty);
+                               }
                        }
                }
 
@@ -180,13 +171,11 @@ namespace System.Windows.Forms {
                public double Zoom {
                        get { return zoom; }
                        set {
-                               if (zoom < 0.0)
+                               if (value <= 0)
                                        throw new ArgumentException ("zoom");
-                               if (zoom != value) {
-                                       InvalidatePreview ();
-                                       Invalidate ();
-                               }
+                               autozoom = false;
                                zoom = value;
+                               InvalidateLayout ();                            
                        }
                }
                #endregion // Public Instance Properties
@@ -243,13 +232,7 @@ namespace System.Windows.Forms {
                                }
                                page_infos = null;
                        }
-                       if (image_cache != null) {
-                               for (int i = 0; i < image_cache.Length; i++) {
-                                       if (image_cache[i] !=null)
-                                               image_cache[i].Dispose();
-                               }
-                               image_cache = null;
-                       }
+                       InvalidateLayout();
                }
 
                [EditorBrowsable(EditorBrowsableState.Never)]
@@ -285,17 +268,8 @@ namespace System.Windows.Forms {
 
                protected override void OnResize(EventArgs e)
                {
+                       InvalidateLayout ();
                        base.OnResize (e);
-                       if (AutoZoom) {
-                               if (page_infos != null && page_infos.Length > 0) {
-                                       Size new_size = ThemeEngine.Current.PrintPreviewControlGetPageSize (this);
-                                       if (new_size.Width != image_size.Width && new_size.Height != image_size.Height)
-                                               image_cache = null;
-                               }
-                       }
-
-                       UpdateScrollBars ();
-                       Invalidate ();
                }
 
                protected virtual void OnStartPageChanged(EventArgs e)
@@ -416,5 +390,16 @@ namespace System.Windows.Forms {
 
                        ResumeLayout (false);
                }
+
+               private void InvalidateLayout() {
+                       if (image_cache != null) {
+                               for (int i = 0; i < image_cache.Length; i++) {
+                                       if (image_cache[i] !=null)
+                                               image_cache[i].Dispose();
+                               }
+                               image_cache = null;
+                       }
+                       Invalidate ();
+               }
        }
 }