OSDN Git Service

TweetThumbnail.ScrollUp/ScrollDownメソッドが正しく機能していないバグを修正
authorKimura Youichi <kim.upsilon@bucyou.net>
Mon, 7 Jan 2013 15:50:13 +0000 (00:50 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sat, 12 Jan 2013 16:15:13 +0000 (01:15 +0900)
OpenTween.Tests/TweetThumbnailTest.cs
OpenTween/TweetThumbnail.Designer.cs
OpenTween/TweetThumbnail.cs

index 0c53649..2bf7033 100644 (file)
@@ -238,5 +238,50 @@ namespace OpenTween
                 Assert.That(eventCalled, Is.True);
             }
         }
+
+        [Test]
+        public void ScrollTest()
+        {
+            var post = new PostClass
+            {
+                TextFromApi = "てすと http://foo.example.com/abcd http://foo.example.com/efgh",
+                Media = new Dictionary<string, string>
+                {
+                    {"http://foo.example.com/abcd", "http://foo.example.com/abcd"},
+                    {"http://foo.example.com/efgh", "http://foo.example.com/efgh"},
+                },
+            };
+
+            using (var thumbbox = new TweetThumbnail())
+            {
+                SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
+                thumbbox.ShowThumbnailAsync(post).Wait();
+
+                Assert.That(thumbbox.scrollBar.Minimum, Is.EqualTo(0));
+                Assert.That(thumbbox.scrollBar.Maximum, Is.EqualTo(1));
+
+                thumbbox.scrollBar.Value = 0;
+
+                thumbbox.ScrollUp();
+                Assert.That(thumbbox.scrollBar.Value, Is.EqualTo(1));
+                Assert.That(thumbbox.pictureBox[0].Visible, Is.False);
+                Assert.That(thumbbox.pictureBox[1].Visible, Is.True);
+
+                thumbbox.ScrollUp();
+                Assert.That(thumbbox.scrollBar.Value, Is.EqualTo(1));
+                Assert.That(thumbbox.pictureBox[0].Visible, Is.False);
+                Assert.That(thumbbox.pictureBox[1].Visible, Is.True);
+
+                thumbbox.ScrollDown();
+                Assert.That(thumbbox.scrollBar.Value, Is.EqualTo(0));
+                Assert.That(thumbbox.pictureBox[0].Visible, Is.True);
+                Assert.That(thumbbox.pictureBox[1].Visible, Is.False);
+
+                thumbbox.ScrollDown();
+                Assert.That(thumbbox.scrollBar.Value, Is.EqualTo(0));
+                Assert.That(thumbbox.pictureBox[0].Visible, Is.True);
+                Assert.That(thumbbox.pictureBox[1].Visible, Is.False);
+            }
+        }
     }
 }
index 81451c9..33e5026 100644 (file)
@@ -42,7 +42,7 @@
             this.scrollBar.Name = "scrollBar";
             this.scrollBar.Size = new System.Drawing.Size(17, 188);
             this.scrollBar.TabIndex = 0;
-            this.scrollBar.Scroll += new System.Windows.Forms.ScrollEventHandler(this.scrollBar_Scroll);
+            this.scrollBar.ValueChanged += new System.EventHandler(this.scrollBar_ValueChanged);
             // 
             // TweetThumbnail
             // 
index 294db80..4609907 100644 (file)
@@ -188,12 +188,17 @@ namespace OpenTween
             this.scrollBar.Value = newval;
         }
 
-        private void scrollBar_Scroll(object sender, ScrollEventArgs e)
+        private void scrollBar_ValueChanged(object sender, EventArgs e)
         {
-            if (e.NewValue == e.OldValue) return;
+            for (var i = 0; i < this.pictureBox.Count; i++)
+            {
+                var picbox = this.pictureBox[i];
 
-            this.pictureBox[e.NewValue].Visible = true;
-            this.pictureBox[e.OldValue].Visible = false;
+                if (this.scrollBar.Value == i)
+                    picbox.Visible = true;
+                else
+                    picbox.Visible = false;
+            }
         }
 
         private void pictureBox_DoubleClick(object sender, EventArgs e)