Author: rolf
Date: 2007-03-26 13:50:31 -0500 (Mon, 26 Mar 2007)
New Revision: 74988

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ProgressBar.cs
   
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
Log:
* ProgressBar.cs, ThemeWin32Classic.cs: Implemented drawing of Marquee
  and Continuous styles. Fixes #79469.

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-03-26 18:49:42 UTC (rev 74987)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-03-26 18:50:31 UTC (rev 74988)
@@ -1,3 +1,8 @@
+2007-03-26  Rolf Bjarne Kvinge <[EMAIL PROTECTED]> 
+
+       * ProgressBar.cs, ThemeWin32Classic.cs: Implemented drawing of Marquee
+         and Continuous styles. Fixes #79469.
+
 2007-03-26  Jonathan Pobst  <[EMAIL PROTECTED]>
 
        * ToolStrip.cs: Implement Tooltips.

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ProgressBar.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ProgressBar.cs   
2007-03-26 18:49:42 UTC (rev 74987)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ProgressBar.cs   
2007-03-26 18:50:31 UTC (rev 74988)
@@ -51,9 +51,11 @@
                private int minimum;
                internal int step;
                internal int val;
+               internal DateTime start = DateTime.Now;
                internal Rectangle client_area = new Rectangle ();
 #if NET_2_0
                internal ProgressBarStyle style;
+               Timer marquee_timer;
 #endif         
                #endregion      // Local Variables
 
@@ -327,11 +329,6 @@
                }
 
 #if NET_2_0
-               [MonoTODO("Currently only implements the 1.1 behavior")]
-               //
-               // This means that we must implement Blocks, Continuous and 
Marquee
-               // rendering modes
-               //
                [Browsable (true)]
                [DefaultValue (ProgressBarStyle.Blocks)]
                [EditorBrowsable (EditorBrowsableState.Always)]
@@ -342,11 +339,28 @@
 
                        set {
                                style = value;
+                               
+                               if (style == ProgressBarStyle.Marquee) {
+                                       if (marquee_timer == null) {
+                                               marquee_timer = new Timer ();
+                                               marquee_timer.Interval = 10;
+                                               marquee_timer.Tick += new 
EventHandler (marquee_timer_Tick);
+                                       }
+                                       marquee_timer.Start ();
+                               } else {
+                                       if (marquee_timer != null) {
+                                               marquee_timer.Stop ();
+                                       }
+                               }
                        }
                }
+
+               void marquee_timer_Tick (object sender, EventArgs e)
+               {
+                       Invalidate ();
+               }
                
                int marquee_animation_speed = 350;
-               [MonoTODO("Currently does nothing")]
                [DefaultValue (100)]
                public int MarqueeAnimationSpeed {
                        get {

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs 
    2007-03-26 18:49:42 UTC (rev 74987)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs 
    2007-03-26 18:50:31 UTC (rev 74988)
@@ -3561,29 +3561,70 @@
                #region ProgressBar
                public override void DrawProgressBar (Graphics dc, Rectangle 
clip_rect, ProgressBar ctrl) 
                {
-                       Rectangle       block_rect;
-                       Rectangle       client_area = ctrl.client_area;
-                       int             space_betweenblocks     = 2;            
        
-                       int             block_width;
-                       int             increment;
-                       int             barpos_pixels;
+                       Rectangle client_area = ctrl.client_area;
                        
-                       block_width = (client_area.Height * 2 ) / 3;
-                       barpos_pixels = ((ctrl.Value - ctrl.Minimum) * 
client_area.Width) / (ctrl.Maximum - ctrl.Minimum);
-                       increment = block_width + space_betweenblocks;
-
                        /* Draw border */
                        CPDrawBorder3D (dc, ctrl.ClientRectangle, 
Border3DStyle.SunkenOuter, Border3DSide.Left | Border3DSide.Right | 
Border3DSide.Top | Border3DSide.Bottom & ~Border3DSide.Middle, ColorControl);
                        
                        /* Draw Blocks */
-                       block_rect = new Rectangle (client_area.X, 
client_area.Y, block_width, client_area.Height);
-                       while ((block_rect.X - client_area.X) < barpos_pixels) {
+                       int draw_mode = 0;
+                       int max_blocks = int.MaxValue;
+                       int start_pixel = client_area.X;
+#if NET_2_0
+                       draw_mode = (int) ctrl.Style;
+#endif
+                       switch (draw_mode) {
+#if NET_2_0
+                       case 1: { // Continuous
+                               int pixels_to_draw;
+                               pixels_to_draw = (int)(client_area.Width * 
((double)(ctrl.Value - ctrl.Minimum) / (double)(ctrl.Maximum - ctrl.Minimum)));
+                               dc.FillRectangle (ResPool.GetSolidBrush 
(progressbarblock_color), new Rectangle (client_area.X, client_area.Y, 
pixels_to_draw, client_area.Height));
+                               break;
+                       }
+                       case 2: // Marquee
+                               if (XplatUI.ThemesEnabled) {
+                                       int ms_diff = (int) (DateTime.Now - 
ctrl.start).TotalMilliseconds;
+                                       double percent_done = (double) ms_diff 
% (double)ctrl.MarqueeAnimationSpeed / (double)ctrl.MarqueeAnimationSpeed;
+                                       max_blocks = 5;
+                                       start_pixel = client_area.X + (int) 
(client_area.Width * percent_done);
+                               }
                                
-                               if (clip_rect.IntersectsWith (block_rect) == 
true) {                            
-                                       dc.FillRectangle (ResPool.GetSolidBrush 
(progressbarblock_color), block_rect);
-                               }                               
+                               goto case 0;
+#endif
+                       case 0:
+                       default:  // Blocks
+                               Rectangle block_rect;
+                               int space_betweenblocks = 2;
+                               int block_width;
+                               int increment;
+                               int barpos_pixels;
+                               int block_count = 0;
                                
-                               block_rect.X  += increment;
+                               block_width = (client_area.Height * 2) / 3;
+                               barpos_pixels = ((ctrl.Value - ctrl.Minimum) * 
client_area.Width) / (ctrl.Maximum - ctrl.Minimum);
+                               increment = block_width + space_betweenblocks;
+                               
+                               block_rect = new Rectangle (start_pixel, 
client_area.Y, block_width, client_area.Height);
+                               while (true) {
+                                       if (max_blocks != int.MaxValue) {
+                                               if (block_count >= max_blocks)
+                                                       break;
+                                               if (block_rect.X > 
client_area.Width)
+                                                       block_rect.X -= 
client_area.Width;
+                                       } else {
+                                               if ((block_rect.X - 
client_area.X) >= barpos_pixels)
+                                                       break;
+                                       }
+                                       
+                                       if (clip_rect.IntersectsWith 
(block_rect) == true) {                            
+                                               dc.FillRectangle 
(ResPool.GetSolidBrush (progressbarblock_color), block_rect);
+                                       }                               
+                                       
+                                       block_rect.X  += increment;
+                                       block_count++;
+                               }
+                               break;
+                       
                        }
                }
                

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

Reply via email to