Author: gert
Date: 2007-03-14 14:19:13 -0500 (Wed, 14 Mar 2007)
New Revision: 74293

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ErrorProvider.cs
   trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
   
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ErrorProviderTest.cs
Log:
* ErrorProviderTest.cs: Enabled previously failing tests.
* ErrorProvider.cs: Invoke default ctor from 2.0-only ctor. Fixes bug
#80803. Avoid NullReferenceException when Control does not have
parent. Fixed different blinkstyle issues. Only subscribe to Tick
event a single time. Only draw error icon when control is created and
visible. Fixes failing unit tests.


Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-03-14 19:01:54 UTC (rev 74292)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-03-14 19:19:13 UTC (rev 74293)
@@ -1,3 +1,11 @@
+2007-03-14  Gert Driesen  <[EMAIL PROTECTED]>
+
+       * ErrorProvider.cs: Invoke default ctor from 2.0-only ctor. Fixes bug
+       #80803. Avoid NullReferenceException when Control does not have
+       parent. Fixed different blinkstyle issues. Only subscribe to Tick
+       event a single time. Only draw error icon when control is created and
+       visible. Fixes failing unit tests.
+
 2007-03-14  Andreia Gaita  <[EMAIL PROTECTED]>
 
        * TabControl.cs: Add support for 2.0 Deselecting, Deselected and

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ErrorProvider.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ErrorProvider.cs 
2007-03-14 19:01:54 UTC (rev 74292)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ErrorProvider.cs 
2007-03-14 19:19:13 UTC (rev 74293)
@@ -42,7 +42,6 @@
            , ISupportInitialize
 #endif
        {
-
                private class ErrorWindow : UserControl
                {
                        public ErrorWindow ()
@@ -83,7 +82,7 @@
                                if (ep.container != null) {
                                        ep.container.Controls.Add(window);
                                        
ep.container.Controls.SetChildIndex(window, 0);
-                               } else {
+                               } else if (control.Parent != null) {
                                        control.Parent.Controls.Add(window);
                                        
control.Parent.Controls.SetChildIndex(window, 0);
                                }
@@ -93,6 +92,7 @@
                                window.MouseLeave += new 
EventHandler(window_MouseLeave);
                                control.SizeChanged += new 
EventHandler(control_SizeLocationChanged);
                                control.LocationChanged += new 
EventHandler(control_SizeLocationChanged);
+                               control.ParentChanged += new EventHandler 
(control_ParentChanged);
                                // Do we want to block mouse clicks? if so we 
need a few more events handled
 
                                CalculateAlignment();
@@ -104,19 +104,28 @@
                                }
 
                                set {
+                                       if (value == null)
+                                               value = string.Empty;
+
+                                       bool differentError = text != value;
                                        text = value;
+
                                        if (text != String.Empty) {
                                                window.Visible = true;
                                        } else {
                                                window.Visible = false;
+                                               return;
                                        }
 
-                                       if (ep.blinkstyle != 
ErrorBlinkStyle.NeverBlink) {
+                                       // even if blink style is NeverBlink we 
need it to allow
+                                       // the timer to elapse at least once to 
get the icon to 
+                                       // display
+                                       if (differentError || ep.blinkstyle == 
ErrorBlinkStyle.AlwaysBlink) {
                                                if (timer == null) {
                                                        timer = new 
System.Windows.Forms.Timer();
+                                                       timer.Tick += tick;
                                                }
                                                timer.Interval = ep.blinkrate;
-                                               timer.Tick += tick;
                                                blink_count = 0;
                                                timer.Enabled = true;
                                        }
@@ -244,13 +253,20 @@
                                CalculateAlignment();
                        }
 
+                       private void control_ParentChanged (object sender, 
EventArgs e)
+                       {
+                               if (ep.container != null)
+                                       return;
+                               control.Parent.Controls.Add (window);
+                               control.Parent.Controls.SetChildIndex (window, 
0);
+                       }
+
                        private void window_Tick(object sender, EventArgs e) {
-                               if (timer.Enabled) {
+                               if (timer.Enabled && control.IsHandleCreated && 
control.Visible) {
                                        Graphics g;
 
                                        blink_count++;
 
-                                       // Dunno why this POS doesn't reliably 
blink
                                        g = window.CreateGraphics();
                                        if ((blink_count % 2) == 0) {
                                                
g.FillRectangle(ThemeEngine.Current.ResPool.GetSolidBrush(window.Parent.BackColor),
 window.ClientRectangle);
@@ -259,10 +275,20 @@
                                        }
                                        g.Dispose();
 
-                                       if ((blink_count > 6) && (ep.blinkstyle 
== ErrorBlinkStyle.BlinkIfDifferentError)) {
-                                               timer.Stop();
-                                               blink_count = 0;
+                                       switch (ep.blinkstyle) {
+                                       case ErrorBlinkStyle.AlwaysBlink:
+                                               break;
+                                       case 
ErrorBlinkStyle.BlinkIfDifferentError:
+                                               if (blink_count > 10)
+                                                       timer.Stop();
+                                               break;
+                                       case ErrorBlinkStyle.NeverBlink:
+                                               timer.Stop ();
+                                               break;
                                        }
+
+                                       if (blink_count == 11)
+                                               blink_count = 1;
                                }
                        }
                }
@@ -295,13 +321,13 @@
                        tooltip = new ToolTip.ToolTipWindow();
                }
 
-               public ErrorProvider(ContainerControl parentControl) : this()
+               public ErrorProvider(ContainerControl parentControl) : this ()
                {
                        container = parentControl;
                }
                
 #if NET_2_0
-               public ErrorProvider (IContainer container)
+               public ErrorProvider (IContainer container) : this ()
                {
                        container.Add (this);
                }
@@ -468,14 +494,11 @@
 
                #region Private Methods
                private ErrorProperty GetErrorProperty(Control control) {
-                       ErrorProperty ep;
-
-                       ep = (ErrorProperty)controls[control];
+                       ErrorProperty ep = (ErrorProperty)controls[control];
                        if (ep == null) {
                                ep = new ErrorProperty(this, control);
                                controls[control] = ep;
                        }
-
                        return ep;
                }
                #endregion      // Private Methods

Modified: 
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog   
2007-03-14 19:01:54 UTC (rev 74292)
+++ trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog   
2007-03-14 19:19:13 UTC (rev 74293)
@@ -1,3 +1,7 @@
+2007-03-14  Gert Driesen  <[EMAIL PROTECTED]>
+
+       * ErrorProviderTest.cs: Enabled previously failing tests.
+
 2007-03-14  Andreia Gaita  <[EMAIL PROTECTED]>
 
        * TabControlTest.cs: Add tests for Deselecting, Deselected, 

Modified: 
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ErrorProviderTest.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ErrorProviderTest.cs
        2007-03-14 19:01:54 UTC (rev 74292)
+++ 
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ErrorProviderTest.cs
        2007-03-14 19:19:13 UTC (rev 74293)
@@ -69,7 +69,6 @@
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void GetandSetErrorTest ()
                {
                        Form myForm = new Form ();
@@ -90,7 +89,6 @@
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void GetandSetIconAlignmentTest ()
                {
                        TextBox myTextBox = new TextBox ();
@@ -100,7 +98,6 @@
                }
 
                [Test]
-               [Category ("NotWorking")]
                public void GetandSetIconPaddingTest ()
                {
                        Form myForm = new Form ();

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to