List:Commits« Previous MessageNext Message »
From:Iggy Galarza Date:June 30 2011 9:43pm
Subject:bzr commit into wex-installer-1.0 branch (iggy:538)
View as plain text  
#At file:///C:/src/bzr.mysql/wex/installer/ based on revid:iggy@stripped

  538 Iggy Galarza	2011-06-30
      Avoid out of bounds error when ListViewWex has no rows/items.

    modified:
      WexInstaller/Controls/ListViewWex.cs
=== modified file 'WexInstaller/Controls/ListViewWex.cs'
--- a/WexInstaller/Controls/ListViewWex.cs	2011-06-30 16:30:52 +0000
+++ b/WexInstaller/Controls/ListViewWex.cs	2011-06-30 21:42:59 +0000
@@ -54,31 +54,34 @@ namespace WexInstaller.Core
 
     private void PositionProgressBar()
     {
+      if (Items.Count > ProgressBarRow)
+      {
         Rectangle rowRect = this.GetItemRect(ProgressBarRow, ItemBoundsPortion.Entire);
 
         int progressBarColLeft = 0;
         int progressBarColWidth = 0;
         foreach (ColumnHeader col in this.Columns)
         {
-            if (col.DisplayIndex == ProgressBarCol)
-            {
-                progressBarColWidth = col.Width;
-                break;
-            }
-            progressBarColLeft += col.Width;
+          if (col.DisplayIndex == ProgressBarCol)
+          {
+            progressBarColWidth = col.Width;
+            break;
+          }
+          progressBarColLeft += col.Width;
         }
 
         ProgressBar.Height = 17;
         ProgressBar.Width = progressBarColWidth - 4;
         ProgressBar.Location = new Point(rowRect.Left + progressBarColLeft + 2,
-                                          rowRect.Top + (rowRect.Height - ProgressBar.Height)/2);
+                                          rowRect.Top + (rowRect.Height - ProgressBar.Height) / 2);
+      }
 
-        return;
+      return;
     }
 
     protected override void WndProc(ref Message m)
     {
-      switch ((WM) m.Msg)
+      switch ((WM)m.Msg)
       {
         case WM.PAINT:
           if (View == View.Details)
@@ -100,47 +103,47 @@ namespace WexInstaller.Core
 
     public int ProgressBarRow
     {
-        get
-        {
-            return progressbarrow;
-        }
-        set
-        {
-            progressbarrow = (value < this.Items.Count) ? value : this.Items.Count;
-            if (progressbarrow < 0)
-                progressbarrow = 0;
-        }
+      get
+      {
+        return progressbarrow;
+      }
+      set
+      {
+        progressbarrow = (value < this.Items.Count) ? value : this.Items.Count;
+        if (progressbarrow < 0)
+          progressbarrow = 0;
+      }
     }
     public int ProgressBarCol
     {
-        get
-        {
-            return progressbarcol;
-        }
-        set
-        {
-            progressbarcol = (value < this.Columns.Count) ? value : this.Columns.Count;
-            if (progressbarcol < 0)
-                progressbarcol = 0;
-        }
+      get
+      {
+        return progressbarcol;
+      }
+      set
+      {
+        progressbarcol = (value < this.Columns.Count) ? value : this.Columns.Count;
+        if (progressbarcol < 0)
+          progressbarcol = 0;
+      }
     }
     public ProgressBar ProgressBar { get; set; }
 
     public void ShowProgressBar(bool visible)
     {
-        if (ProgressBar == null)
-        {
-            ProgressBar = new ProgressBar();
-            ProgressBar.BackColor = this.BackColor;
-            ProgressBar.Name = "ListViewProgressBar";
-            ProgressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
-            Controls.Add(this.ProgressBar);
-        }
+      if (ProgressBar == null)
+      {
+        ProgressBar = new ProgressBar();
+        ProgressBar.BackColor = this.BackColor;
+        ProgressBar.Name = "ListViewProgressBar";
+        ProgressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
+        Controls.Add(this.ProgressBar);
+      }
 
-        ProgressBar.Visible = visible;
-        ProgressBar.Enabled = visible;
-        PositionProgressBar();
-        ProgressBar.Refresh();
+      ProgressBar.Visible = visible;
+      ProgressBar.Enabled = visible;
+      PositionProgressBar();
+      ProgressBar.Refresh();
     }
 
     #region Drawing
@@ -293,17 +296,17 @@ namespace WexInstaller.Core
 
     private Image GhostIcon(Image image)
     {
-        Bitmap b = new Bitmap(image);
-        for (int y = 0; y < b.Height; y++)
-            for (int x = 0; x < b.Width; x++)
-            {
-                Color c = b.GetPixel(x, y);
-                int red = c.R + (255 - c.R)*3/4;
-                int green = c.G + (255 - c.G)*3/4;
-                int blue = c.B + (255 - c.B)*3/4;
-                b.SetPixel(x, y, Color.FromArgb(red, green, blue));
-            }
-        return b;
+      Bitmap b = new Bitmap(image);
+      for (int y = 0; y < b.Height; y++)
+        for (int x = 0; x < b.Width; x++)
+        {
+          Color c = b.GetPixel(x, y);
+          int red = c.R + (255 - c.R) * 3 / 4;
+          int green = c.G + (255 - c.G) * 3 / 4;
+          int blue = c.B + (255 - c.B) * 3 / 4;
+          b.SetPixel(x, y, Color.FromArgb(red, green, blue));
+        }
+      return b;
     }
 
     /// <summary>


Attachment: [text/bzr-bundle] bzr/iggy@mysql.com-20110630214259-14cddsbsl9555dw6.bundle
Thread
bzr commit into wex-installer-1.0 branch (iggy:538) Iggy Galarza4 Jul